aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1995-08-21 12:02:23 +0000
committerSimon Marshall1995-08-21 12:02:23 +0000
commitebdee0a0df02bcc5606be884fd03bfd44a3d9478 (patch)
tree03200904eb808c37648e0fa874e35c21dad019dc
parent9a1221bc9c3ab3130e2734f76930c2bfcef7f880 (diff)
downloademacs-ebdee0a0df02bcc5606be884fd03bfd44a3d9478.tar.gz
emacs-ebdee0a0df02bcc5606be884fd03bfd44a3d9478.zip
New version 3.07. Made fast-lock-mode use buffer-file-truename, not buffer-file-name.
-rw-r--r--lisp/fast-lock.el137
1 files changed, 123 insertions, 14 deletions
diff --git a/lisp/fast-lock.el b/lisp/fast-lock.el
index c6c268bbfb5..92cae9ecedb 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.06 7;; Version: 3.07
8 8
9;;; This file is part of GNU Emacs. 9;;; This file is part of GNU Emacs.
10 10
@@ -60,6 +60,95 @@
60;; 60;;
61;; M-x fast-lock-submit-bug-report RET 61;; M-x fast-lock-submit-bug-report RET
62 62
63;; History:
64;;
65;; 0.02--1.00:
66;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only.
67;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode.
68;; 1.00--1.01:
69;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p'.
70;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil.
71;; - Moved save-all conditions to `fast-lock-save-cache'.
72;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook'.
73;; 1.01--2.00: complete rewrite---not worth the space to document.
74;; - Changed structure of text properties cache and threw out file mod checks.
75;; 2.00--2.01:
76;; - Made `condition-case' forms understand `quit'.
77;; - Made `fast-lock' require `font-lock'.
78;; - Made `fast-lock-cache-name' chase links (from Ben Liblit).
79;; 2.01--3.00:
80;; - Changed structure of cache to include `font-lock-keywords' (from rms).
81;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories'.
82;; - Removed `fast-lock-read-others'.
83;; - Made `fast-lock-read-cache' ignore cache owner.
84;; - Made `fast-lock-save-cache-external' create cache directory.
85;; - Made `fast-lock-save-cache-external' save `font-lock-keywords'.
86;; - Made `fast-lock-cache-data' check `font-lock-keywords'.
87;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw.
88;; - Package now provides itself.
89;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p'.
90;; - Lucid: Use `list-faces' for `face-list'.
91;; - Lucid: Added `set-text-properties'.
92;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode'.
93;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache'.
94;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties'.
95;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw.
96;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera).
97;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw).
98;; - Lucid: Separated handlers for `error' and `quit' for `condition-case'.
99;; 3.02--3.03:
100;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data'.
101;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties'.
102;; 3.03--3.04:
103;; - Corrected `subrp' test of Lucid code.
104;; - Replaced `font-lock-any-properties-p' with `text-property-not-all'.
105;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents.
106;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty).
107;; - Made `fast-lock-cache-directory' to return a usable cache file directory.
108;; 3.04--3.05:
109;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all'.
110;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match'.
111;; - Made `byte-compile-warnings' omit `unresolved' on compilation.
112;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey).
113;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey).
114;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig).
115;; - Reverted to 3.04 version of `fast-lock-get-face-properties'.
116;; - XEmacs: Removed `list-faces' `defalias'.
117;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies.
118;; - Added `lazy-lock-submit-bug-report'.
119;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size'.
120;; - Made `fast-lock-save-cache' output a message if no save ever attempted.
121;; - Made `fast-lock-save-cache-data' output a message if save attempted.
122;; - Made `fast-lock-cache-data' output a message if load attempted.
123;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect'.
124;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing.
125;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig).
126;; - Added `fast-lock-save-events'.
127;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig).
128;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook'.
129;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook'.
130;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook'.
131;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig).
132;; - Made `visited-file-modtime' be the basis of the timestamp (Stig).
133;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it.
134;; - Added `fast-lock-cache-filename' to keep track of the cache file name.
135;; - Added `fast-lock-after-fontify-buffer'.
136;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor).
137;; - Made `fast-lock-get-face-properties' functions use it.
138;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way.
139;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped).
140;; - Made `fast-lock-mode' ensure `font-lock-mode' is on.
141;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster).
142;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster).
143;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym).
144;; - Made `fast-lock-cache-data' check `buffer-modified-p'.
145;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary.
146;; - XEmacs: Made `font-lock-compile-keywords' `defalias'.
147;; 3.06--3.07:
148;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook.
149;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist'.
150;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name'.
151
63(require 'font-lock) 152(require 'font-lock)
64 153
65(eval-when-compile 154(eval-when-compile
@@ -70,7 +159,7 @@
70 "Submit via mail a bug report on fast-lock.el." 159 "Submit via mail a bug report on fast-lock.el."
71 (interactive) 160 (interactive)
72 (let ((reporter-prompt-for-summary-p t)) 161 (let ((reporter-prompt-for-summary-p t))
73 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.06" 162 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.07"
74 '(fast-lock-cache-directories fast-lock-minimum-size 163 '(fast-lock-cache-directories fast-lock-minimum-size
75 fast-lock-save-others fast-lock-save-events fast-lock-save-faces) 164 fast-lock-save-others fast-lock-save-events fast-lock-save-faces)
76 nil nil 165 nil nil
@@ -101,8 +190,10 @@ until one succeeds (i.e., until a readable or writable one is found). If an
101item contains REGEXP, DIR is used only if the buffer file name matches REGEXP. 190item contains REGEXP, DIR is used only if the buffer file name matches REGEXP.
102For example: 191For example:
103 192
104 (list (cons (concat \"^\" (regexp-quote (expand-file-name \"~\"))) \".\") 193 (let ((home (expand-file-name (abbreviate-file-name (file-truename \"~/\")))))
105 \"~/.emacs-flc\") 194 (list (cons (concat \"^\" (regexp-quote home)) \".\") \"~/.emacs-flc\"))
195 =>
196 ((\"^/your/true/home/directory/\" . \".\") \"~/.emacs-flc\")
106 197
107would cause a file's current directory to be used if the file is under your 198would cause a file's current directory to be used if the file is under your
108home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'.") 199home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'.")
@@ -125,14 +216,13 @@ Font Lock cache files saved. Ownership may be unknown for networked files.")
125 216
126(defvar fast-lock-save-faces 217(defvar fast-lock-save-faces
127 ;; Since XEmacs uses extents for everything, we have to pick the right ones. 218 ;; Since XEmacs uses extents for everything, we have to pick the right ones.
128 ;; In XEmacs 19.12 we can't identify which text properties are font-lock's. 219 ;; In XEmacs 19.13 we can't identify which text properties are Font Lock's.
129 (if (save-match-data (string-match "XEmacs" (emacs-version))) 220 (if (save-match-data (string-match "XEmacs" (emacs-version)))
130 '(font-lock-string-face font-lock-doc-string-face font-lock-type-face 221 '(font-lock-string-face font-lock-doc-string-face font-lock-type-face
131 font-lock-function-name-face font-lock-comment-face 222 font-lock-function-name-face font-lock-comment-face
132 font-lock-keyword-face) 223 font-lock-keyword-face font-lock-preprocessor-face)
133 ;; For Emacs 19.29 I don't think this is generally necessary. 224 ;; For Emacs 19.30 I don't think this is generally necessary.
134 ;(mapcar 'eval (mapcar 'car font-lock-face-attributes)) 225 nil)
135 )
136 "A list of faces that will be saved in a Font Lock cache file. 226 "A list of faces that will be saved in a Font Lock cache file.
137If nil, means information for all faces will be saved.") 227If nil, means information for all faces will be saved.")
138 228
@@ -167,13 +257,13 @@ For saving, see variables `fast-lock-minimum-size', `fast-lock-save-events',
167Use \\[fast-lock-submit-bug-report] to send bug reports or feedback." 257Use \\[fast-lock-submit-bug-report] to send bug reports or feedback."
168 (interactive "P") 258 (interactive "P")
169 (set (make-local-variable 'fast-lock-mode) 259 (set (make-local-variable 'fast-lock-mode)
170 (and (buffer-file-name) 260 (and buffer-file-truename
171 (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode)))) 261 (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode))))
172 (if (and fast-lock-mode (not font-lock-mode)) 262 (if (and fast-lock-mode (not font-lock-mode))
173 ;; Turned on `fast-lock-mode' rather than using `font-lock-mode-hook'. 263 ;; Turned on `fast-lock-mode' rather than using `font-lock-mode-hook'.
174 (progn 264 (progn
175 (add-hook 'font-lock-mode-hook 'turn-on-fast-lock) 265 (add-hook 'font-lock-mode-hook 'turn-on-fast-lock)
176 (font-lock-mode 1)) 266 (font-lock-mode t))
177 ;; Let's get down to business. 267 ;; Let's get down to business.
178 (set (make-local-variable 'fast-lock-cache-timestamp) nil) 268 (set (make-local-variable 'fast-lock-cache-timestamp) nil)
179 (set (make-local-variable 'fast-lock-cache-filename) nil) 269 (set (make-local-variable 'fast-lock-cache-filename) nil)
@@ -262,7 +352,7 @@ See `fast-lock-mode'."
262;;;###autoload 352;;;###autoload
263(defun turn-on-fast-lock () 353(defun turn-on-fast-lock ()
264 "Unconditionally turn on Fast Lock mode." 354 "Unconditionally turn on Fast Lock mode."
265 (fast-lock-mode 1)) 355 (fast-lock-mode t))
266 356
267;;; API Functions: 357;;; API Functions:
268 358
@@ -319,6 +409,11 @@ See `fast-lock-cache-directories'."
319 (progn (make-directory dir t) dir) 409 (progn (make-directory dir t) dir)
320 (error nil)))))) 410 (error nil))))))
321 411
412;; If you are wondering why we only hash if the directory is not ".", rather
413;; than if `file-name-absolute-p', it is because if we just appended ".flc" for
414;; relative cache directories (that are not ".") then it is possible that more
415;; than one file would have the same cache name in that directory, if the luser
416;; made a link from one relative cache directory to another. (Phew!)
322(defun fast-lock-cache-name (directory) 417(defun fast-lock-cache-name (directory)
323 "Return full cache path name using caching DIRECTORY. 418 "Return full cache path name using caching DIRECTORY.
324If DIRECTORY is `.', the path is the buffer file name appended with `.flc'. 419If DIRECTORY is `.', the path is the buffer file name appended with `.flc'.
@@ -326,7 +421,15 @@ Otherwise, the path name is constructed from DIRECTORY and the buffer's true
326abbreviated file name, with all `/' characters in the name replaced with `#' 421abbreviated file name, with all `/' characters in the name replaced with `#'
327characters, and appended with `.flc'. 422characters, and appended with `.flc'.
328 423
329See `fast-lock-mode'." 424If the same file has different cache path names when edited on different
425machines, e.g., on one machine the cache file name has the prefix `#home',
426perhaps due to automount, try putting in your `~/.emacs' something like:
427
428 (setq directory-abbrev-alist (cons '(\"^/home/\" . \"/\") directory-abbrev-alist))
429
430Emacs automagically removes the common `/tmp_mnt' automount prefix by default.
431
432See `fast-lock-cache-directory'."
330 (if (string-equal directory ".") 433 (if (string-equal directory ".")
331 (concat buffer-file-name ".flc") 434 (concat buffer-file-name ".flc")
332 (let* ((bufile (expand-file-name buffer-file-truename)) 435 (let* ((bufile (expand-file-name buffer-file-truename))
@@ -509,13 +612,19 @@ See `fast-lock-get-face-properties' for the format of PROPERTIES."
509 (setq regions (nthcdr 2 regions))) 612 (setq regions (nthcdr 2 regions)))
510 (setq properties (cdr properties))))))) 613 (setq properties (cdr properties)))))))
511 614
615(if (save-match-data (string-match "XEmacs" (emacs-version)))
616 ;; XEmacs 19.12 font-lock.el's `font-lock-fontify-buffer' runs a hook.
617 (add-hook 'font-lock-after-fontify-buffer-hook
618 'fast-lock-after-fontify-buffer))
619
512(or (fboundp 'font-lock-compile-keywords) 620(or (fboundp 'font-lock-compile-keywords)
513 (defalias 'font-lock-compile-keywords 'identity)) 621 (defalias 'font-lock-compile-keywords 'identity))
514 622
515;; Install ourselves: 623;; Install ourselves:
516 624
517;; We don't install ourselves on `font-lock-mode-hook' as packages with similar 625;; We don't install ourselves on `font-lock-mode-hook' as packages with similar
518;; functionality exist, and fast-lock.el should be dumpable. 626;; functionality exist, and fast-lock.el should be dumpable without forcing
627;; people to use caches or making it difficult for people to use alternatives.
519(add-hook 'after-save-hook 'fast-lock-after-save-hook) 628(add-hook 'after-save-hook 'fast-lock-after-save-hook)
520(add-hook 'kill-buffer-hook 'fast-lock-kill-buffer-hook) 629(add-hook 'kill-buffer-hook 'fast-lock-kill-buffer-hook)
521(add-hook 'kill-emacs-hook 'fast-lock-kill-emacs-hook) 630(add-hook 'kill-emacs-hook 'fast-lock-kill-emacs-hook)