diff options
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/composite.el | 21 | ||||
| -rw-r--r-- | lisp/font-lock.el | 78 | ||||
| -rw-r--r-- | lisp/jit-lock.el | 26 |
4 files changed, 40 insertions, 91 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 74f4c73fb7d..ab0b9744048 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2010-08-30 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-08-30 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * composite.el (save-buffer-state): Delete, unused. | ||
| 4 | * font-lock.el (save-buffer-state): Use with-silent-modifications. | ||
| 5 | (font-lock-default-fontify-region): Use with-syntax-table. | ||
| 6 | * jit-lock.el (with-buffer-unmodified): Remove. | ||
| 7 | (with-buffer-prepared-for-jit-lock): Use with-silent-modifications. | ||
| 8 | |||
| 3 | Use `declare' in defmacros. | 9 | Use `declare' in defmacros. |
| 4 | * window.el (save-selected-window): | 10 | * window.el (save-selected-window): |
| 5 | * subr.el (with-temp-file, with-temp-message, with-syntax-table): | 11 | * subr.el (with-temp-file, with-temp-message, with-syntax-table): |
diff --git a/lisp/composite.el b/lisp/composite.el index 9fdf528d601..1ecfec86b5d 100644 --- a/lisp/composite.el +++ b/lisp/composite.el | |||
| @@ -413,27 +413,6 @@ after a sequence of character events." | |||
| 413 | 413 | ||
| 414 | ;;; Automatic character composition. | 414 | ;;; Automatic character composition. |
| 415 | 415 | ||
| 416 | ;; Copied from font-lock.el. | ||
| 417 | (eval-when-compile | ||
| 418 | ;; Borrowed from lazy-lock.el. | ||
| 419 | ;; We use this to preserve or protect things when modifying text properties. | ||
| 420 | (defmacro save-buffer-state (varlist &rest body) | ||
| 421 | "Bind variables according to VARLIST and eval BODY restoring buffer state." | ||
| 422 | `(let* ,(append varlist | ||
| 423 | '((modified (buffer-modified-p)) (buffer-undo-list t) | ||
| 424 | (inhibit-read-only t) (inhibit-point-motion-hooks t) | ||
| 425 | (inhibit-modification-hooks t) | ||
| 426 | deactivate-mark buffer-file-name buffer-file-truename)) | ||
| 427 | ,@body | ||
| 428 | (unless modified | ||
| 429 | (restore-buffer-modified-p nil)))) | ||
| 430 | ;; Fixme: This makes bootstrapping fail with this error. | ||
| 431 | ;; Symbol's function definition is void: eval-defun | ||
| 432 | ;;(def-edebug-spec save-buffer-state let) | ||
| 433 | ) | ||
| 434 | |||
| 435 | (put 'save-buffer-state 'lisp-indent-function 1) | ||
| 436 | |||
| 437 | ;; These macros must match with C macros LGSTRING_XXX and LGLYPH_XXX in font.h | 416 | ;; These macros must match with C macros LGSTRING_XXX and LGLYPH_XXX in font.h |
| 438 | (defsubst lgstring-header (gstring) (aref gstring 0)) | 417 | (defsubst lgstring-header (gstring) (aref gstring 0)) |
| 439 | (defsubst lgstring-set-header (gstring header) (aset gstring 0 header)) | 418 | (defsubst lgstring-set-header (gstring header) (aset gstring 0 header)) |
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index f54bf21d2d8..bfea0dabfe2 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -615,21 +615,10 @@ Major/minor modes can set this variable if they know which option applies.") | |||
| 615 | (defmacro save-buffer-state (varlist &rest body) | 615 | (defmacro save-buffer-state (varlist &rest body) |
| 616 | "Bind variables according to VARLIST and eval BODY restoring buffer state." | 616 | "Bind variables according to VARLIST and eval BODY restoring buffer state." |
| 617 | (declare (indent 1) (debug let)) | 617 | (declare (indent 1) (debug let)) |
| 618 | (let ((modified (make-symbol "modified"))) | 618 | `(let* ,(append varlist |
| 619 | `(let* ,(append varlist | 619 | `((inhibit-point-motion-hooks t))) |
| 620 | `((,modified (buffer-modified-p)) | 620 | (with-silent-modifications |
| 621 | (buffer-undo-list t) | 621 | ,@body))) |
| 622 | (inhibit-read-only t) | ||
| 623 | (inhibit-point-motion-hooks t) | ||
| 624 | (inhibit-modification-hooks t) | ||
| 625 | deactivate-mark | ||
| 626 | buffer-file-name | ||
| 627 | buffer-file-truename)) | ||
| 628 | (unwind-protect | ||
| 629 | (progn | ||
| 630 | ,@body) | ||
| 631 | (unless ,modified | ||
| 632 | (restore-buffer-modified-p nil)))))) | ||
| 633 | ;; | 622 | ;; |
| 634 | ;; Shut up the byte compiler. | 623 | ;; Shut up the byte compiler. |
| 635 | (defvar font-lock-face-attributes)) ; Obsolete but respected if set. | 624 | (defvar font-lock-face-attributes)) ; Obsolete but respected if set. |
| @@ -1125,38 +1114,33 @@ Put first the functions more likely to cause a change and cheaper to compute.") | |||
| 1125 | (defun font-lock-default-fontify-region (beg end loudly) | 1114 | (defun font-lock-default-fontify-region (beg end loudly) |
| 1126 | (save-buffer-state | 1115 | (save-buffer-state |
| 1127 | ((parse-sexp-lookup-properties | 1116 | ((parse-sexp-lookup-properties |
| 1128 | (or parse-sexp-lookup-properties font-lock-syntactic-keywords)) | 1117 | (or parse-sexp-lookup-properties font-lock-syntactic-keywords))) |
| 1129 | (old-syntax-table (syntax-table))) | 1118 | ;; Use the fontification syntax table, if any. |
| 1130 | (unwind-protect | 1119 | (with-syntax-table (or font-lock-syntax-table (syntax-table)) |
| 1131 | (save-restriction | 1120 | (save-restriction |
| 1132 | (unless font-lock-dont-widen (widen)) | 1121 | (unless font-lock-dont-widen (widen)) |
| 1133 | ;; Use the fontification syntax table, if any. | 1122 | ;; Extend the region to fontify so that it starts and ends at |
| 1134 | (when font-lock-syntax-table | 1123 | ;; safe places. |
| 1135 | (set-syntax-table font-lock-syntax-table)) | 1124 | (let ((funs font-lock-extend-region-functions) |
| 1136 | ;; Extend the region to fontify so that it starts and ends at | 1125 | (font-lock-beg beg) |
| 1137 | ;; safe places. | 1126 | (font-lock-end end)) |
| 1138 | (let ((funs font-lock-extend-region-functions) | 1127 | (while funs |
| 1139 | (font-lock-beg beg) | 1128 | (setq funs (if (or (not (funcall (car funs))) |
| 1140 | (font-lock-end end)) | 1129 | (eq funs font-lock-extend-region-functions)) |
| 1141 | (while funs | 1130 | (cdr funs) |
| 1142 | (setq funs (if (or (not (funcall (car funs))) | 1131 | ;; If there's been a change, we should go through |
| 1143 | (eq funs font-lock-extend-region-functions)) | 1132 | ;; the list again since this new position may |
| 1144 | (cdr funs) | 1133 | ;; warrant a different answer from one of the fun |
| 1145 | ;; If there's been a change, we should go through | 1134 | ;; we've already seen. |
| 1146 | ;; the list again since this new position may | 1135 | font-lock-extend-region-functions))) |
| 1147 | ;; warrant a different answer from one of the fun | 1136 | (setq beg font-lock-beg end font-lock-end)) |
| 1148 | ;; we've already seen. | 1137 | ;; Now do the fontification. |
| 1149 | font-lock-extend-region-functions))) | 1138 | (font-lock-unfontify-region beg end) |
| 1150 | (setq beg font-lock-beg end font-lock-end)) | 1139 | (when font-lock-syntactic-keywords |
| 1151 | ;; Now do the fontification. | 1140 | (font-lock-fontify-syntactic-keywords-region beg end)) |
| 1152 | (font-lock-unfontify-region beg end) | 1141 | (unless font-lock-keywords-only |
| 1153 | (when font-lock-syntactic-keywords | 1142 | (font-lock-fontify-syntactically-region beg end loudly)) |
| 1154 | (font-lock-fontify-syntactic-keywords-region beg end)) | 1143 | (font-lock-fontify-keywords-region beg end loudly))))) |
| 1155 | (unless font-lock-keywords-only | ||
| 1156 | (font-lock-fontify-syntactically-region beg end loudly)) | ||
| 1157 | (font-lock-fontify-keywords-region beg end loudly)) | ||
| 1158 | ;; Clean up. | ||
| 1159 | (set-syntax-table old-syntax-table)))) | ||
| 1160 | 1144 | ||
| 1161 | ;; The following must be rethought, since keywords can override fontification. | 1145 | ;; The following must be rethought, since keywords can override fontification. |
| 1162 | ;; ;; Now scan for keywords, but not if we are inside a comment now. | 1146 | ;; ;; Now scan for keywords, but not if we are inside a comment now. |
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 1bc61d8d9fc..cc250567ad8 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el | |||
| @@ -32,33 +32,13 @@ | |||
| 32 | (eval-when-compile | 32 | (eval-when-compile |
| 33 | (require 'cl) | 33 | (require 'cl) |
| 34 | 34 | ||
| 35 | (defmacro with-buffer-unmodified (&rest body) | ||
| 36 | "Eval BODY, preserving the current buffer's modified state." | ||
| 37 | (declare (debug t)) | ||
| 38 | (let ((modified (make-symbol "modified"))) | ||
| 39 | `(let ((,modified (buffer-modified-p))) | ||
| 40 | (unwind-protect | ||
| 41 | (progn ,@body) | ||
| 42 | (unless ,modified | ||
| 43 | (restore-buffer-modified-p nil)))))) | ||
| 44 | |||
| 45 | (defmacro with-buffer-prepared-for-jit-lock (&rest body) | 35 | (defmacro with-buffer-prepared-for-jit-lock (&rest body) |
| 46 | "Execute BODY in current buffer, overriding several variables. | 36 | "Execute BODY in current buffer, overriding several variables. |
| 47 | Preserves the `buffer-modified-p' state of the current buffer." | 37 | Preserves the `buffer-modified-p' state of the current buffer." |
| 48 | (declare (debug t)) | 38 | (declare (debug t)) |
| 49 | `(let ((buffer-undo-list t) | 39 | `(let ((inhibit-point-motion-hooks t)) |
| 50 | (inhibit-read-only t) | 40 | (with-silent-modifications |
| 51 | (inhibit-point-motion-hooks t) | 41 | ,@body)))) |
| 52 | (inhibit-modification-hooks t) | ||
| 53 | deactivate-mark | ||
| 54 | buffer-file-name | ||
| 55 | buffer-file-truename) | ||
| 56 | ;; Do reset the modification status from within the let, since | ||
| 57 | ;; otherwise set-buffer-modified-p may try to unlock the file. | ||
| 58 | (with-buffer-unmodified | ||
| 59 | ,@body)))) | ||
| 60 | |||
| 61 | |||
| 62 | 42 | ||
| 63 | ;;; Customization. | 43 | ;;; Customization. |
| 64 | 44 | ||