aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/fast-lock.el184
1 files changed, 149 insertions, 35 deletions
diff --git a/lisp/fast-lock.el b/lisp/fast-lock.el
index e8227dffcec..09ecd27d4e0 100644
--- a/lisp/fast-lock.el
+++ b/lisp/fast-lock.el
@@ -4,7 +4,7 @@
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.12 7;; Version: 3.12.01
8 8
9;;; This file is part of GNU Emacs. 9;;; This file is part of GNU Emacs.
10 10
@@ -53,6 +53,120 @@
53;; Version control packages are likely to stamp all over file modification 53;; Version control packages are likely to stamp all over file modification
54;; times. Therefore the act of checking out may invalidate a cache. 54;; times. Therefore the act of checking out may invalidate a cache.
55 55
56;; History:
57;;
58;; 0.02--1.00:
59;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only
60;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode
61;; 1.00--1.01:
62;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p'
63;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil
64;; - Moved save-all conditions to `fast-lock-save-cache'
65;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook'
66;; 1.01--2.00: complete rewrite---not worth the space to document
67;; - Changed structure of text properties cache and threw out file mod checks
68;; 2.00--2.01:
69;; - Made `condition-case' forms understand `quit'.
70;; - Made `fast-lock' require `font-lock'
71;; - Made `fast-lock-cache-name' chase links (from Ben Liblit)
72;; 2.01--3.00:
73;; - Changed structure of cache to include `font-lock-keywords' (from rms)
74;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories'
75;; - Removed `fast-lock-read-others'
76;; - Made `fast-lock-read-cache' ignore cache owner
77;; - Made `fast-lock-save-cache-external' create cache directory
78;; - Made `fast-lock-save-cache-external' save `font-lock-keywords'
79;; - Made `fast-lock-cache-data' check `font-lock-keywords'
80;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw
81;; - Package now provides itself
82;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p'
83;; - Lucid: Use `list-faces' for `face-list'
84;; - Lucid: Added `set-text-properties'
85;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode'
86;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache'
87;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties'
88;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw
89;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera)
90;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw)
91;; - Lucid: Separated handlers for `error' and `quit' for `condition-case'
92;; 3.02--3.03:
93;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data'
94;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties'
95;; 3.03--3.04:
96;; - Corrected `subrp' test of Lucid code
97;; - Replaced `font-lock-any-properties-p' with `text-property-not-all'
98;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents
99;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty)
100;; - Made `fast-lock-cache-directory' to return a usable cache file directory
101;; 3.04--3.05:
102;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all'
103;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match'
104;; - Made `byte-compile-warnings' omit `unresolved' on compilation
105;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey)
106;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey)
107;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig)
108;; - Reverted to 3.04 version of `fast-lock-get-face-properties'
109;; - XEmacs: Removed `list-faces' `defalias'
110;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies
111;; - Added `fast-lock-submit-bug-report'
112;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size'
113;; - Made `fast-lock-save-cache' output a message if no save ever attempted
114;; - Made `fast-lock-save-cache-data' output a message if save attempted
115;; - Made `fast-lock-cache-data' output a message if load attempted
116;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect'
117;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing
118;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig)
119;; - Added `fast-lock-save-events'
120;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig)
121;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook'
122;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook'
123;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook'
124;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig)
125;; - Made `visited-file-modtime' be the basis of the timestamp (Stig)
126;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it
127;; - Added `fast-lock-cache-filename' to keep track of the cache file name
128;; - Added `fast-lock-after-fontify-buffer'
129;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor)
130;; - Made `fast-lock-get-face-properties' functions use it
131;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way
132;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped)
133;; - Made `fast-lock-mode' ensure `font-lock-mode' is on
134;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster)
135;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster)
136;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym)
137;; - Made `fast-lock-cache-data' check `buffer-modified-p'
138;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary
139;; - XEmacs: Made `font-lock-compile-keywords' `defalias'
140;; 3.06--3.07:
141;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook
142;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist'
143;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name'
144;; 3.07--3.08:
145;; - Made `fast-lock-read-cache' set `fast-lock-cache-filename'
146;; 3.08--3.09:
147;; - Made `fast-lock-save-cache' cope if `fast-lock-minimum-size' is an a list
148;; - Made `fast-lock-mode' respect the value of `font-lock-inhibit-thing-lock'
149;; - Added `fast-lock-after-unfontify-buffer'
150;; 3.09--3.10:
151;; - Rewrite for Common Lisp macros
152;; - Made fast-lock.el barf on a crap 8+3 pseudo-OS (Eli Zaretskii help)
153;; - XEmacs: Made `add-minor-mode' succeed `autoload' cookie
154;; - XEmacs: Made `fast-lock-save-faces' default to `font-lock-face-list'
155;; - Made `fast-lock-save-cache' use `font-lock-value-in-major-mode'
156;; - Wrap with `save-buffer-state' (Ray Van Tassle report)
157;; - Made `fast-lock-mode' wrap `font-lock-support-mode'
158;; 3.10--3.11:
159;; - Made `fast-lock-get-face-properties' cope with face lists
160;; - Added `fast-lock-verbose'
161;; - XEmacs: Add `font-lock-value-in-major-mode' if necessary
162;; - Removed `fast-lock-submit-bug-report' and bade farewell
163;; 3.11--3.12:
164;; - Added Custom support (Hrvoje Niksic help)
165;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks'
166;; - Made `fast-lock-cache-data' simplify calls of `font-lock-compile-keywords'
167;; 3.12--3.13:
168;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint)
169
56;;; Code: 170;;; Code:
57 171
58(require 'font-lock) 172(require 'font-lock)
@@ -64,37 +178,42 @@
64(eval-when-compile 178(eval-when-compile
65 ;; 179 ;;
66 ;; We don't do this at the top-level as we only use non-autoloaded macros. 180 ;; We don't do this at the top-level as we only use non-autoloaded macros.
67 (require 'cl)) 181 (require 'cl)
68 182 ;;
69;; We use this to preserve or protect things when modifying text properties. 183 ;; We use this to preserve or protect things when modifying text properties.
70(defmacro save-buffer-state (varlist &rest body) 184 (defmacro save-buffer-state (varlist &rest body)
71 "Bind variables according to VARLIST and eval BODY restoring buffer state." 185 "Bind variables according to VARLIST and eval BODY restoring buffer state."
72 (` (let* ((,@ (append varlist 186 (` (let* ((,@ (append varlist
73 '((modified (buffer-modified-p)) (buffer-undo-list t) 187 '((modified (buffer-modified-p)) (buffer-undo-list t)
74 (inhibit-read-only t) (inhibit-point-motion-hooks t) 188 (inhibit-read-only t) (inhibit-point-motion-hooks t)
75 before-change-functions after-change-functions 189 before-change-functions after-change-functions
76 deactivate-mark buffer-file-name buffer-file-truename)))) 190 deactivate-mark buffer-file-name buffer-file-truename))))
77 (,@ body) 191 (,@ body)
78 (when (and (not modified) (buffer-modified-p)) 192 (when (and (not modified) (buffer-modified-p))
79 (set-buffer-modified-p nil))))) 193 (set-buffer-modified-p nil)))))
80(put 'save-buffer-state 'lisp-indent-function 1) 194 (put 'save-buffer-state 'lisp-indent-function 1)
81 195 ;;
82;; We use this to verify that a face should be saved. 196 ;; We use this to verify that a face should be saved.
83(defmacro fast-lock-save-facep (face) 197 (defmacro fast-lock-save-facep (face)
84 "Return non-nil if FACE is one of `fast-lock-save-faces'." 198 "Return non-nil if FACE is one of `fast-lock-save-faces'."
85 (` (or (null fast-lock-save-faces) 199 (` (or (null fast-lock-save-faces)
86 (if (symbolp (, face)) 200 (if (symbolp (, face))
87 (memq (, face) fast-lock-save-faces) 201 (memq (, face) fast-lock-save-faces)
88 (let ((faces (, face))) 202 (let ((faces (, face)))
89 (while (unless (memq (car faces) fast-lock-save-faces) 203 (while (unless (memq (car faces) fast-lock-save-faces)
90 (setq faces (cdr faces)))) 204 (setq faces (cdr faces))))
91 faces))))) 205 faces)))))
206 ;;
207 ;; We use this for compatibility with a future Emacs.
208 (or (fboundp 'defcustom)
209 (defmacro defcustom (symbol value doc &rest args)
210 (` (defvar (, symbol) (, value) (, doc))))))
92 211
93;(defun fast-lock-submit-bug-report () 212;(defun fast-lock-submit-bug-report ()
94; "Submit via mail a bug report on fast-lock.el." 213; "Submit via mail a bug report on fast-lock.el."
95; (interactive) 214; (interactive)
96; (let ((reporter-prompt-for-summary-p t)) 215; (let ((reporter-prompt-for-summary-p t))
97; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.12" 216; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.12.01"
98; '(fast-lock-cache-directories fast-lock-minimum-size 217; '(fast-lock-cache-directories fast-lock-minimum-size
99; fast-lock-save-others fast-lock-save-events fast-lock-save-faces 218; fast-lock-save-others fast-lock-save-events fast-lock-save-faces
100; fast-lock-verbose) 219; fast-lock-verbose)
@@ -113,11 +232,6 @@
113 232
114;; User Variables: 233;; User Variables:
115 234
116(defgroup fast-lock nil
117 "Font Lock support mode to cache fontification."
118 :link '(custom-manual "(emacs)Support Modes")
119 :group 'font-lock)
120
121(defcustom fast-lock-cache-directories '("." "~/.emacs-flc") 235(defcustom fast-lock-cache-directories '("." "~/.emacs-flc")
122; - `internal', keep each file's Font Lock cache file in the same file. 236; - `internal', keep each file's Font Lock cache file in the same file.
123; - `external', keep each file's Font Lock cache file in the same directory. 237; - `external', keep each file's Font Lock cache file in the same directory.
@@ -137,10 +251,10 @@ For example:
137 251
138would cause a file's current directory to be used if the file is under your 252would cause a file's current directory to be used if the file is under your
139home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'." 253home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'."
140 :type '(repeat (radio (cons :tag "Matching" 254 :type '(repeat (radio (directory :tag "directory")
255 (cons :tag "Matching"
141 (regexp :tag "regexp") 256 (regexp :tag "regexp")
142 (directory :tag "directory")) 257 (directory :tag "directory"))))
143 (directory :tag "directory")))
144 :group 'fast-lock) 258 :group 'fast-lock)
145 259
146(defcustom fast-lock-minimum-size (* 25 1024) 260(defcustom fast-lock-minimum-size (* 25 1024)