emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r101222: Use with-silent-modification


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101222: Use with-silent-modifications.
Date: Mon, 30 Aug 2010 15:57:42 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101222
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2010-08-30 15:57:42 +0200
message:
  Use with-silent-modifications.
  * lisp/composite.el (save-buffer-state): Delete, unused.
  * lisp/font-lock.el (save-buffer-state): Use with-silent-modifications.
  (font-lock-default-fontify-region): Use with-syntax-table.
  * lisp/jit-lock.el (with-buffer-unmodified): Remove.
  (with-buffer-prepared-for-jit-lock): Use with-silent-modifications.
modified:
  lisp/ChangeLog
  lisp/composite.el
  lisp/font-lock.el
  lisp/jit-lock.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-08-30 13:03:05 +0000
+++ b/lisp/ChangeLog    2010-08-30 13:57:42 +0000
@@ -1,5 +1,11 @@
 2010-08-30  Stefan Monnier  <address@hidden>
 
+       * composite.el (save-buffer-state): Delete, unused.
+       * font-lock.el (save-buffer-state): Use with-silent-modifications.
+       (font-lock-default-fontify-region): Use with-syntax-table.
+       * jit-lock.el (with-buffer-unmodified): Remove.
+       (with-buffer-prepared-for-jit-lock): Use with-silent-modifications.
+
        Use `declare' in defmacros.
        * window.el (save-selected-window):
        * subr.el (with-temp-file, with-temp-message, with-syntax-table):

=== modified file 'lisp/composite.el'
--- a/lisp/composite.el 2010-08-29 16:17:13 +0000
+++ b/lisp/composite.el 2010-08-30 13:57:42 +0000
@@ -413,27 +413,6 @@
 
 ;;; Automatic character composition.
 
-;; Copied from font-lock.el.
-(eval-when-compile
-  ;; Borrowed from lazy-lock.el.
-  ;; We use this to preserve or protect things when modifying text properties.
-  (defmacro save-buffer-state (varlist &rest body)
-    "Bind variables according to VARLIST and eval BODY restoring buffer state."
-    `(let* ,(append varlist
-                   '((modified (buffer-modified-p)) (buffer-undo-list t)
-                     (inhibit-read-only t) (inhibit-point-motion-hooks t)
-                     (inhibit-modification-hooks t)
-                     deactivate-mark buffer-file-name buffer-file-truename))
-       ,@body
-       (unless modified
-        (restore-buffer-modified-p nil))))
-  ;; Fixme: This makes bootstrapping fail with this error.
-  ;;   Symbol's function definition is void: eval-defun
-  ;;(def-edebug-spec save-buffer-state let)
-  )
-
-(put 'save-buffer-state 'lisp-indent-function 1)
-
 ;; These macros must match with C macros LGSTRING_XXX and LGLYPH_XXX in font.h
 (defsubst lgstring-header (gstring) (aref gstring 0))
 (defsubst lgstring-set-header (gstring header) (aset gstring 0 header))

=== modified file 'lisp/font-lock.el'
--- a/lisp/font-lock.el 2010-08-29 16:17:13 +0000
+++ b/lisp/font-lock.el 2010-08-30 13:57:42 +0000
@@ -615,21 +615,10 @@
   (defmacro save-buffer-state (varlist &rest body)
     "Bind variables according to VARLIST and eval BODY restoring buffer state."
     (declare (indent 1) (debug let))
-    (let ((modified (make-symbol "modified")))
-      `(let* ,(append varlist
-                     `((,modified (buffer-modified-p))
-                       (buffer-undo-list t)
-                       (inhibit-read-only t)
-                       (inhibit-point-motion-hooks t)
-                       (inhibit-modification-hooks t)
-                       deactivate-mark
-                       buffer-file-name
-                       buffer-file-truename))
-        (unwind-protect
-            (progn
-              ,@body)
-          (unless ,modified
-            (restore-buffer-modified-p nil))))))
+    `(let* ,(append varlist
+                    `((inhibit-point-motion-hooks t)))
+       (with-silent-modifications
+         ,@body)))
   ;;
   ;; Shut up the byte compiler.
   (defvar font-lock-face-attributes))  ; Obsolete but respected if set.
@@ -1125,38 +1114,33 @@
 (defun font-lock-default-fontify-region (beg end loudly)
   (save-buffer-state
       ((parse-sexp-lookup-properties
-        (or parse-sexp-lookup-properties font-lock-syntactic-keywords))
-       (old-syntax-table (syntax-table)))
-    (unwind-protect
-       (save-restriction
-         (unless font-lock-dont-widen (widen))
-         ;; Use the fontification syntax table, if any.
-         (when font-lock-syntax-table
-           (set-syntax-table font-lock-syntax-table))
-          ;; Extend the region to fontify so that it starts and ends at
-          ;; safe places.
-          (let ((funs font-lock-extend-region-functions)
-                (font-lock-beg beg)
-                (font-lock-end end))
-            (while funs
-              (setq funs (if (or (not (funcall (car funs)))
-                                 (eq funs font-lock-extend-region-functions))
-                             (cdr funs)
-                           ;; If there's been a change, we should go through
-                           ;; the list again since this new position may
-                           ;; warrant a different answer from one of the fun
-                           ;; we've already seen.
-                           font-lock-extend-region-functions)))
-            (setq beg font-lock-beg end font-lock-end))
-         ;; Now do the fontification.
-         (font-lock-unfontify-region beg end)
-         (when font-lock-syntactic-keywords
-           (font-lock-fontify-syntactic-keywords-region beg end))
-         (unless font-lock-keywords-only
-           (font-lock-fontify-syntactically-region beg end loudly))
-         (font-lock-fontify-keywords-region beg end loudly))
-      ;; Clean up.
-      (set-syntax-table old-syntax-table))))
+        (or parse-sexp-lookup-properties font-lock-syntactic-keywords)))
+    ;; Use the fontification syntax table, if any.
+    (with-syntax-table (or font-lock-syntax-table (syntax-table))
+      (save-restriction
+        (unless font-lock-dont-widen (widen))
+        ;; Extend the region to fontify so that it starts and ends at
+        ;; safe places.
+        (let ((funs font-lock-extend-region-functions)
+              (font-lock-beg beg)
+              (font-lock-end end))
+          (while funs
+            (setq funs (if (or (not (funcall (car funs)))
+                               (eq funs font-lock-extend-region-functions))
+                           (cdr funs)
+                         ;; If there's been a change, we should go through
+                         ;; the list again since this new position may
+                         ;; warrant a different answer from one of the fun
+                         ;; we've already seen.
+                         font-lock-extend-region-functions)))
+          (setq beg font-lock-beg end font-lock-end))
+        ;; Now do the fontification.
+        (font-lock-unfontify-region beg end)
+        (when font-lock-syntactic-keywords
+          (font-lock-fontify-syntactic-keywords-region beg end))
+        (unless font-lock-keywords-only
+          (font-lock-fontify-syntactically-region beg end loudly))
+        (font-lock-fontify-keywords-region beg end loudly)))))
 
 ;; The following must be rethought, since keywords can override fontification.
 ;;    ;; Now scan for keywords, but not if we are inside a comment now.

=== modified file 'lisp/jit-lock.el'
--- a/lisp/jit-lock.el  2010-08-29 16:17:13 +0000
+++ b/lisp/jit-lock.el  2010-08-30 13:57:42 +0000
@@ -32,33 +32,13 @@
 (eval-when-compile
   (require 'cl)
 
-  (defmacro with-buffer-unmodified (&rest body)
-    "Eval BODY, preserving the current buffer's modified state."
-    (declare (debug t))
-    (let ((modified (make-symbol "modified")))
-      `(let ((,modified (buffer-modified-p)))
-        (unwind-protect
-            (progn ,@body)
-          (unless ,modified
-            (restore-buffer-modified-p nil))))))
-
   (defmacro with-buffer-prepared-for-jit-lock (&rest body)
     "Execute BODY in current buffer, overriding several variables.
 Preserves the `buffer-modified-p' state of the current buffer."
     (declare (debug t))
-    `(let ((buffer-undo-list t)
-           (inhibit-read-only t)
-           (inhibit-point-motion-hooks t)
-           (inhibit-modification-hooks t)
-           deactivate-mark
-           buffer-file-name
-           buffer-file-truename)
-       ;; Do reset the modification status from within the let, since
-       ;; otherwise set-buffer-modified-p may try to unlock the file.
-       (with-buffer-unmodified
-           ,@body))))
-
-
+    `(let ((inhibit-point-motion-hooks t))
+       (with-silent-modifications
+         ,@body))))
 
 ;;; Customization.
 


reply via email to

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