diff options
| -rw-r--r-- | lisp/fast-lock.el | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/lisp/fast-lock.el b/lisp/fast-lock.el index 6fec142edea..b9308a8265f 100644 --- a/lisp/fast-lock.el +++ b/lisp/fast-lock.el | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | ;;; fast-lock.el --- Automagic text properties caching for fast Font Lock mode. | 1 | ;;; fast-lock.el --- Automagic text properties caching for fast Font Lock mode. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Simon Marshall <simon@gnu.ai.mit.edu> | 5 | ;; Author: Simon Marshall <simon@gnu.ai.mit.edu> |
| 6 | ;; Keywords: faces files | 6 | ;; Keywords: faces files |
| 7 | ;; Version: 3.13 | 7 | ;; Version: 3.14 |
| 8 | 8 | ||
| 9 | ;;; This file is part of GNU Emacs. | 9 | ;;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| @@ -172,6 +172,10 @@ | |||
| 172 | ;; - Added `fast-lock-get-syntactic-properties' | 172 | ;; - Added `fast-lock-get-syntactic-properties' |
| 173 | ;; - Renamed `fast-lock-set-face-properties' to `fast-lock-add-properties' | 173 | ;; - Renamed `fast-lock-set-face-properties' to `fast-lock-add-properties' |
| 174 | ;; - Made `fast-lock-add-properties' add syntactic and face fontification data | 174 | ;; - Made `fast-lock-add-properties' add syntactic and face fontification data |
| 175 | ;; 3.13--3.14: | ||
| 176 | ;; - Made `fast-lock-cache-name' cope with `windowsnt' (Geoff Voelker fix) | ||
| 177 | ;; - Made `fast-lock-verbose' use `other' widget (Andreas Schwab fix) | ||
| 178 | ;; - Used `with-temp-message' where possible to make messages temporary. | ||
| 175 | 179 | ||
| 176 | ;;; Code: | 180 | ;;; Code: |
| 177 | 181 | ||
| @@ -211,6 +215,14 @@ | |||
| 211 | faces))))) | 215 | faces))))) |
| 212 | ;; | 216 | ;; |
| 213 | ;; We use this for compatibility with a future Emacs. | 217 | ;; We use this for compatibility with a future Emacs. |
| 218 | (or (fboundp 'with-temp-message) | ||
| 219 | (defmacro with-temp-message (message &rest body) | ||
| 220 | (` (let ((current-message (current-message))) | ||
| 221 | (unwind-protect | ||
| 222 | (progn (message (, message)) (,@ body)) | ||
| 223 | (message current-message)))))) | ||
| 224 | ;; | ||
| 225 | ;; We use this for compatibility with a future Emacs. | ||
| 214 | (or (fboundp 'defcustom) | 226 | (or (fboundp 'defcustom) |
| 215 | (defmacro defcustom (symbol value doc &rest args) | 227 | (defmacro defcustom (symbol value doc &rest args) |
| 216 | (` (defvar (, symbol) (, value) (, doc)))))) | 228 | (` (defvar (, symbol) (, value) (, doc)))))) |
| @@ -219,7 +231,7 @@ | |||
| 219 | ; "Submit via mail a bug report on fast-lock.el." | 231 | ; "Submit via mail a bug report on fast-lock.el." |
| 220 | ; (interactive) | 232 | ; (interactive) |
| 221 | ; (let ((reporter-prompt-for-summary-p t)) | 233 | ; (let ((reporter-prompt-for-summary-p t)) |
| 222 | ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.13" | 234 | ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.14" |
| 223 | ; '(fast-lock-cache-directories fast-lock-minimum-size | 235 | ; '(fast-lock-cache-directories fast-lock-minimum-size |
| 224 | ; fast-lock-save-others fast-lock-save-events fast-lock-save-faces | 236 | ; fast-lock-save-others fast-lock-save-events fast-lock-save-faces |
| 225 | ; fast-lock-verbose) | 237 | ; fast-lock-verbose) |
| @@ -238,7 +250,7 @@ | |||
| 238 | 250 | ||
| 239 | ;; User Variables: | 251 | ;; User Variables: |
| 240 | 252 | ||
| 241 | (defcustom fast-lock-minimum-size (* 25 1024) | 253 | (defcustom fast-lock-minimum-size 25600 |
| 242 | "*Minimum size of a buffer for cached fontification. | 254 | "*Minimum size of a buffer for cached fontification. |
| 243 | Only buffers more than this can have associated Font Lock cache files saved. | 255 | Only buffers more than this can have associated Font Lock cache files saved. |
| 244 | If nil, means cache files are never created. | 256 | If nil, means cache files are never created. |
| @@ -306,8 +318,8 @@ Font Lock cache files saved. Ownership may be unknown for networked files." | |||
| 306 | "*If non-nil, means show status messages for cache processing. | 318 | "*If non-nil, means show status messages for cache processing. |
| 307 | If a number, only buffers greater than this size have processing messages." | 319 | If a number, only buffers greater than this size have processing messages." |
| 308 | :type '(choice (const :tag "never" nil) | 320 | :type '(choice (const :tag "never" nil) |
| 309 | (integer :tag "size") | 321 | (other :tag "always" t) |
| 310 | (other :tag "always" t)) | 322 | (integer :tag "size")) |
| 311 | :group 'fast-lock) | 323 | :group 'fast-lock) |
| 312 | 324 | ||
| 313 | (defvar fast-lock-save-faces | 325 | (defvar fast-lock-save-faces |
| @@ -561,26 +573,29 @@ See `fast-lock-cache-directory'." | |||
| 561 | (> (buffer-size) fast-lock-verbose) | 573 | (> (buffer-size) fast-lock-verbose) |
| 562 | fast-lock-verbose)) | 574 | fast-lock-verbose)) |
| 563 | (saved t)) | 575 | (saved t)) |
| 564 | (if verbose (message "Saving %s font lock cache..." (buffer-name))) | 576 | (with-temp-message |
| 565 | (condition-case nil | 577 | (if verbose |
| 566 | (save-excursion | 578 | (format "Saving %s font lock cache..." (buffer-name)) |
| 567 | (print (list 'fast-lock-cache-data 3 | 579 | (current-message)) |
| 568 | (list 'quote timestamp) | 580 | (condition-case nil |
| 569 | (list 'quote font-lock-syntactic-keywords) | 581 | (save-excursion |
| 570 | (list 'quote (fast-lock-get-syntactic-properties)) | 582 | (print (list 'fast-lock-cache-data 3 |
| 571 | (list 'quote font-lock-keywords) | 583 | (list 'quote timestamp) |
| 572 | (list 'quote (fast-lock-get-face-properties))) | 584 | (list 'quote font-lock-syntactic-keywords) |
| 573 | tpbuf) | 585 | (list 'quote (fast-lock-get-syntactic-properties)) |
| 574 | (set-buffer tpbuf) | 586 | (list 'quote font-lock-keywords) |
| 575 | (write-region (point-min) (point-max) file nil 'quietly) | 587 | (list 'quote (fast-lock-get-face-properties))) |
| 576 | (setq fast-lock-cache-timestamp timestamp | 588 | tpbuf) |
| 577 | fast-lock-cache-filename file)) | 589 | (set-buffer tpbuf) |
| 578 | (error (setq saved 'error)) (quit (setq saved 'quit))) | 590 | (write-region (point-min) (point-max) file nil 'quietly) |
| 579 | (kill-buffer tpbuf) | 591 | (setq fast-lock-cache-timestamp timestamp |
| 580 | (if verbose (message "Saving %s font lock cache...%s" (buffer-name) | 592 | fast-lock-cache-filename file)) |
| 581 | (cond ((eq saved 'error) "failed") | 593 | (error (setq saved 'error)) (quit (setq saved 'quit))) |
| 582 | ((eq saved 'quit) "aborted") | 594 | (kill-buffer tpbuf)) |
| 583 | (t "done")))) | 595 | (cond ((eq saved 'quit) |
| 596 | (message "Saving %s font lock cache...quit" (buffer-name))) | ||
| 597 | ((eq saved 'error) | ||
| 598 | (message "Saving %s font lock cache...failed" (buffer-name)))) | ||
| 584 | ;; We return non-nil regardless of whether a failure occurred. | 599 | ;; We return non-nil regardless of whether a failure occurred. |
| 585 | saved)) | 600 | saved)) |
| 586 | 601 | ||
| @@ -615,14 +630,17 @@ See `fast-lock-cache-directory'." | |||
| 615 | (not (equal syntactic-keywords font-lock-syntactic-keywords)) | 630 | (not (equal syntactic-keywords font-lock-syntactic-keywords)) |
| 616 | (not (equal keywords font-lock-keywords))) | 631 | (not (equal keywords font-lock-keywords))) |
| 617 | (setq loaded nil) | 632 | (setq loaded nil) |
| 618 | (if verbose (message "Loading %s font lock cache..." (buffer-name))) | 633 | (with-temp-message |
| 619 | (condition-case nil | 634 | (if verbose |
| 620 | (fast-lock-add-properties syntactic-properties face-properties) | 635 | (format "Loading %s font lock cache..." (buffer-name)) |
| 621 | (error (setq loaded 'error)) (quit (setq loaded 'quit))) | 636 | (current-message)) |
| 622 | (if verbose (message "Loading %s font lock cache...%s" (buffer-name) | 637 | (condition-case nil |
| 623 | (cond ((eq loaded 'error) "failed") | 638 | (fast-lock-add-properties syntactic-properties face-properties) |
| 624 | ((eq loaded 'quit) "aborted") | 639 | (error (setq loaded 'error)) (quit (setq loaded 'quit)))) |
| 625 | (t "done"))))) | 640 | (cond ((eq loaded 'quit) |
| 641 | (message "Loading %s font lock cache...quit" (buffer-name))) | ||
| 642 | ((eq loaded 'error) | ||
| 643 | (message "Loading %s font lock cache...failed" (buffer-name))))) | ||
| 626 | (setq font-lock-fontified (eq loaded t) | 644 | (setq font-lock-fontified (eq loaded t) |
| 627 | fast-lock-cache-timestamp (and (eq loaded t) timestamp)))) | 645 | fast-lock-cache-timestamp (and (eq loaded t) timestamp)))) |
| 628 | 646 | ||
| @@ -814,6 +832,10 @@ See `fast-lock-get-face-properties'." | |||
| 814 | (if (consp alist) | 832 | (if (consp alist) |
| 815 | (cdr (or (assq major-mode alist) (assq t alist))) | 833 | (cdr (or (assq major-mode alist) (assq t alist))) |
| 816 | alist))) | 834 | alist))) |
| 835 | |||
| 836 | (unless (fboundp 'current-message) | ||
| 837 | (defun current-message () | ||
| 838 | "")) | ||
| 817 | 839 | ||
| 818 | ;; Install ourselves: | 840 | ;; Install ourselves: |
| 819 | 841 | ||