From f9b03f274f93c81e9de2ec874fcc666a61e8b750 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Sun, 24 Feb 2013 11:02:57 +0100 Subject: [PATCH 2/2] =?UTF-8?q?make=20org-unmodified=20an=20alias=20for=20?= =?UTF-8?q?`with-silent-modifications=C2=B4=20or=20re-implement=20as=20a?= =?UTF-8?q?=20macro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-macs.el (org-unmodified): If `with-silent-modifications´ is fbound, make org-unmodified an alias to it. If not, implement it as a macro as before. Additionally to the original implementation, let-bind `deactivate-mark´, `buffer-file-name´ and `buffer-file-truename´ to nil. (with-silent-modifications): Do not define, even when not fbound. --- lisp/org-macs.el | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lisp/org-macs.el b/lisp/org-macs.el index c46ad56..36fc86c 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -63,14 +63,6 @@ (defmacro org-called-interactively-p (&optional kind) `(interactive-p)))) (def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp))) -(when (and (not (fboundp 'with-silent-modifications)) - (or (< emacs-major-version 23) - (and (= emacs-major-version 23) - (< emacs-minor-version 2)))) - (defmacro with-silent-modifications (&rest body) - `(org-unmodified ,@body)) - (def-edebug-spec with-silent-modifications (body))) - (defmacro org-bound-and-true-p (var) "Return the value of symbol VAR if it is bound, else nil." `(and (boundp (quote ,var)) ,var)) @@ -116,17 +108,21 @@ (defmacro org-preserve-lc (&rest body) (org-move-to-column ,col))))) (def-edebug-spec org-preserve-lc (body)) -;; Copied from bookmark.el -(defmacro org-unmodified (&rest body) - "Run BODY while preserving the buffer's `buffer-modified-p' state." - (org-with-gensyms (was-modified) - `(let ((,was-modified (buffer-modified-p))) - (unwind-protect - (let ((buffer-undo-list t) - (inhibit-modification-hooks t)) - ,@body) - (set-buffer-modified-p ,was-modified))))) -(def-edebug-spec org-unmodified (body)) +(eval-and-compile + (if (fboundp 'with-silent-modifications) + (defalias 'org-unmodified 'with-silent-modifications) + ;; originally copied from bookmark.el + (defmacro org-unmodified (&rest body) + "Execute body without changing `buffer-modified-p'. +Also, do not record undo information." + `(set-buffer-modified-p + (prog1 (buffer-modified-p) + (let ((buffer-undo-list t) + (inhibit-read-only t) + (inhibit-modification-hooks t) + deactivate-mark buffer-file-name buffer-file-truename) + ,@body)))) + (def-edebug-spec org-unmodified (body)))) (defmacro org-without-partial-completion (&rest body) `(if (and (boundp 'partial-completion-mode) -- 1.8.1.4