emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/subr.el


From: Stefan Monnier
Subject: [Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/subr.el
Date: Tue, 08 Sep 2009 19:42:26 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/09/08 19:42:25

Modified files:
        etc            : NEWS 
        lisp           : ChangeLog subr.el 

Log message:
        (with-silent-modifications): New macro.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/etc/NEWS?cvsroot=emacs&r1=1.2076&r2=1.2077
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16111&r2=1.16112
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/subr.el?cvsroot=emacs&r1=1.648&r2=1.649

Patches:
Index: etc/NEWS
===================================================================
RCS file: /sources/emacs/emacs/etc/NEWS,v
retrieving revision 1.2076
retrieving revision 1.2077
diff -u -b -r1.2076 -r1.2077
--- etc/NEWS    5 Sep 2009 19:11:24 -0000       1.2076
+++ etc/NEWS    8 Sep 2009 19:42:21 -0000       1.2077
@@ -200,6 +200,8 @@
 
 * Lisp changes in Emacs 23.2
 
+** New macro with-silent-modifications to tweak text properties without
+affecting the buffer's modification state.
 ** All the default-FOO variables that hold the default value of the FOO
 variable, are now declared obsolete.
 

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16111
retrieving revision 1.16112
diff -u -b -r1.16111 -r1.16112
--- lisp/ChangeLog      7 Sep 2009 15:23:09 -0000       1.16111
+++ lisp/ChangeLog      8 Sep 2009 19:42:22 -0000       1.16112
@@ -1,3 +1,7 @@
+2009-09-08  Stefan Monnier  <address@hidden>
+
+       * subr.el (with-silent-modifications): New macro.
+
 2009-09-07  Juanma Barranquero  <address@hidden>
 
        * files.el (top-level): Require `cl' when compiling.

Index: lisp/subr.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/subr.el,v
retrieving revision 1.648
retrieving revision 1.649
diff -u -b -r1.648 -r1.649
--- lisp/subr.el        30 Aug 2009 18:17:22 -0000      1.648
+++ lisp/subr.el        8 Sep 2009 19:42:25 -0000       1.649
@@ -2749,6 +2749,29 @@
            (and (buffer-name ,temp-buffer)
                 (kill-buffer ,temp-buffer)))))))
 
+(defmacro with-silent-modifications (&rest body)
+  "Execute BODY, pretending it does not modifies the buffer.
+If BODY performs real modifications to the buffer's text, other
+than cosmetic ones, undo data may become corrupted.
+Typically used around modifications of text-properties which do not really
+affect the buffer's content."
+  (declare (debug t) (indent 0))
+  (let ((modified (make-symbol "modified")))
+    `(let* ((,modified (buffer-modified-p))
+            (buffer-undo-list t)
+            (inhibit-read-only t)
+            (inhibit-modification-hooks t)
+            deactivate-mark
+            ;; Avoid setting and removing file locks and checking
+            ;; buffer's uptodate-ness w.r.t the underlying file.
+            buffer-file-name
+            buffer-file-truename)
+       (unwind-protect
+           (progn
+             ,@body)
+         (unless ,modified
+           (restore-buffer-modified-p nil))))))
+
 (defmacro with-output-to-string (&rest body)
   "Execute BODY, return the text it sent to `standard-output', as a string."
   (declare (indent 0) (debug t))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]