aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1996-01-26 08:26:58 +0000
committerSimon Marshall1996-01-26 08:26:58 +0000
commit271c888a358af617b3ac79e9034c0bebbda2f64d (patch)
treef09b3494e7a43d58200397662c60617d774b1d81
parent26adca1bd9c38f8088dcdcba608cb5ca193384d0 (diff)
downloademacs-271c888a358af617b3ac79e9034c0bebbda2f64d.tar.gz
emacs-271c888a358af617b3ac79e9034c0bebbda2f64d.zip
Support for local fontification.
-rw-r--r--lisp/fast-lock.el198
-rw-r--r--lisp/font-lock.el14
-rw-r--r--lisp/mail/rmail.el33
3 files changed, 151 insertions, 94 deletions
diff --git a/lisp/fast-lock.el b/lisp/fast-lock.el
index 24c4a302d83..f7132904cbd 100644
--- a/lisp/fast-lock.el
+++ b/lisp/fast-lock.el
@@ -4,9 +4,9 @@
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.08 7;; Version: 3.09
8 8
9;; This file is part of GNU Emacs. 9;;; This file is part of GNU Emacs.
10 10
11;; GNU Emacs is free software; you can redistribute it and/or modify 11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by 12;; it under the terms of the GNU General Public License as published by
@@ -64,93 +64,97 @@
64;; History: 64;; History:
65;; 65;;
66;; 0.02--1.00: 66;; 0.02--1.00:
67;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only. 67;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only
68;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode. 68;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode
69;; 1.00--1.01: 69;; 1.00--1.01:
70;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p'. 70;; - Turn on `fast-lock-mode' only if `buffer-file-name' or `interactive-p'
71;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil. 71;; - Made `fast-lock-file-name' use `buffer-name' if `buffer-file-name' is nil
72;; - Moved save-all conditions to `fast-lock-save-cache'. 72;; - Moved save-all conditions to `fast-lock-save-cache'
73;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook'. 73;; - Added `fast-lock-save-text-properties' to `kill-buffer-hook'
74;; 1.01--2.00: complete rewrite---not worth the space to document. 74;; 1.01--2.00: complete rewrite---not worth the space to document
75;; - Changed structure of text properties cache and threw out file mod checks. 75;; - Changed structure of text properties cache and threw out file mod checks
76;; 2.00--2.01: 76;; 2.00--2.01:
77;; - Made `condition-case' forms understand `quit'. 77;; - Made `condition-case' forms understand `quit'.
78;; - Made `fast-lock' require `font-lock'. 78;; - Made `fast-lock' require `font-lock'
79;; - Made `fast-lock-cache-name' chase links (from Ben Liblit). 79;; - Made `fast-lock-cache-name' chase links (from Ben Liblit)
80;; 2.01--3.00: 80;; 2.01--3.00:
81;; - Changed structure of cache to include `font-lock-keywords' (from rms). 81;; - Changed structure of cache to include `font-lock-keywords' (from rms)
82;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories'. 82;; - Changed `fast-lock-cache-mechanisms' to `fast-lock-cache-directories'
83;; - Removed `fast-lock-read-others'. 83;; - Removed `fast-lock-read-others'
84;; - Made `fast-lock-read-cache' ignore cache owner. 84;; - Made `fast-lock-read-cache' ignore cache owner
85;; - Made `fast-lock-save-cache-external' create cache directory. 85;; - Made `fast-lock-save-cache-external' create cache directory
86;; - Made `fast-lock-save-cache-external' save `font-lock-keywords'. 86;; - Made `fast-lock-save-cache-external' save `font-lock-keywords'
87;; - Made `fast-lock-cache-data' check `font-lock-keywords'. 87;; - Made `fast-lock-cache-data' check `font-lock-keywords'
88;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw. 88;; 3.00--3.01: incorporated port of 2.00 to Lucid, made by Barry Warsaw
89;; - Package now provides itself. 89;; - Package now provides itself
90;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p'. 90;; - Lucid: Use `font-lock-any-extents-p' for `font-lock-any-properties-p'
91;; - Lucid: Use `list-faces' for `face-list'. 91;; - Lucid: Use `list-faces' for `face-list'
92;; - Lucid: Added `set-text-properties'. 92;; - Lucid: Added `set-text-properties'
93;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode'. 93;; - Lucid: Made `turn-on-fast-lock' pass 1 not t to `fast-lock-mode'
94;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache'. 94;; - Removed test for `fast-lock-mode' from `fast-lock-read-cache'
95;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties'. 95;; - Lucid: Added Lucid-specific `fast-lock-get-face-properties'
96;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw. 96;; 3.01--3.02: now works with Lucid Emacs, thanks to Barry Warsaw
97;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera). 97;; - Made `fast-lock-cache-name' map ":" to ";" for OS/2 (from Serganova Vera)
98;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw). 98;; - Made `fast-lock-cache-name' use abbreviated file name (from Barry Warsaw)
99;; - Lucid: Separated handlers for `error' and `quit' for `condition-case'. 99;; - Lucid: Separated handlers for `error' and `quit' for `condition-case'
100;; 3.02--3.03: 100;; 3.02--3.03:
101;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data'. 101;; - Changed `fast-lock-save-cache-external' to `fast-lock-save-cache-data'
102;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties'. 102;; - Lucid: Added Lucid-specific `fast-lock-set-face-properties'
103;; 3.03--3.04: 103;; 3.03--3.04:
104;; - Corrected `subrp' test of Lucid code. 104;; - Corrected `subrp' test of Lucid code
105;; - Replaced `font-lock-any-properties-p' with `text-property-not-all'. 105;; - Replaced `font-lock-any-properties-p' with `text-property-not-all'
106;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents. 106;; - Lucid: Made `fast-lock-set-face-properties' put `text-prop' on extents
107;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty). 107;; - Made `fast-lock-cache-directories' a regexp alist (from Colin Rafferty)
108;; - Made `fast-lock-cache-directory' to return a usable cache file directory. 108;; - Made `fast-lock-cache-directory' to return a usable cache file directory
109;; 3.04--3.05: 109;; 3.04--3.05:
110;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all'. 110;; - Lucid: Fix for XEmacs 19.11 `text-property-not-all'
111;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match'. 111;; - Replaced `subrp' test of Lucid code with `emacs-version' `string-match'
112;; - Made `byte-compile-warnings' omit `unresolved' on compilation. 112;; - Made `byte-compile-warnings' omit `unresolved' on compilation
113;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey). 113;; - Made `fast-lock-save-cache-data' use a buffer (from Rick Sladkey)
114;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey). 114;; - Reverted to old `fast-lock-get-face-properties' (from Rick Sladkey)
115;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig). 115;; 3.05--3.06: incorporated hack of 3.03, made by Jonathan Stigelman (Stig)
116;; - Reverted to 3.04 version of `fast-lock-get-face-properties'. 116;; - Reverted to 3.04 version of `fast-lock-get-face-properties'
117;; - XEmacs: Removed `list-faces' `defalias'. 117;; - XEmacs: Removed `list-faces' `defalias'
118;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies. 118;; - Made `fast-lock-mode' and `turn-on-fast-lock' succeed `autoload' cookies
119;; - Added `lazy-lock-submit-bug-report'. 119;; - Added `fast-lock-submit-bug-report'
120;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size'. 120;; - Renamed `fast-lock-save-size' to `fast-lock-minimum-size'
121;; - Made `fast-lock-save-cache' output a message if no save ever attempted. 121;; - Made `fast-lock-save-cache' output a message if no save ever attempted
122;; - Made `fast-lock-save-cache-data' output a message if save attempted. 122;; - Made `fast-lock-save-cache-data' output a message if save attempted
123;; - Made `fast-lock-cache-data' output a message if load attempted. 123;; - Made `fast-lock-cache-data' output a message if load attempted
124;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect'. 124;; - Made `fast-lock-save-cache-data' do `condition-case' not `unwind-protect'
125;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing. 125;; - Made `fast-lock-save-cache' and `fast-lock-read-cache' return nothing
126;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig). 126;; - Made `fast-lock-save-cache' check `buffer-modified-p' (Stig)
127;; - Added `fast-lock-save-events'. 127;; - Added `fast-lock-save-events'
128;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig). 128;; - Added `fast-lock-after-save-hook' to `after-save-hook' (Stig)
129;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook'. 129;; - Added `fast-lock-kill-buffer-hook' to `kill-buffer-hook'
130;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook'. 130;; - Changed `fast-lock-save-caches' to `fast-lock-kill-emacs-hook'
131;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook'. 131;; - Added `fast-lock-kill-emacs-hook' to `kill-emacs-hook'
132;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig). 132;; - Made `fast-lock-save-cache' check `verify-visited-file-modtime' (Stig)
133;; - Made `visited-file-modtime' be the basis of the timestamp (Stig). 133;; - Made `visited-file-modtime' be the basis of the timestamp (Stig)
134;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it. 134;; - Made `fast-lock-save-cache-1' and `fast-lock-cache-data' use/reformat it
135;; - Added `fast-lock-cache-filename' to keep track of the cache file name. 135;; - Added `fast-lock-cache-filename' to keep track of the cache file name
136;; - Added `fast-lock-after-fontify-buffer'. 136;; - Added `fast-lock-after-fontify-buffer'
137;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor). 137;; - Added `fast-lock-save-faces' list of faces to save (idea from Stig/Tibor)
138;; - Made `fast-lock-get-face-properties' functions use it. 138;; - Made `fast-lock-get-face-properties' functions use it
139;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way. 139;; - XEmacs: Made `fast-lock-set-face-properties' do extents the Font Lock way
140;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped). 140;; - XEmacs: Removed fix for `text-property-not-all' (19.11 support dropped)
141;; - Made `fast-lock-mode' ensure `font-lock-mode' is on. 141;; - Made `fast-lock-mode' ensure `font-lock-mode' is on
142;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster). 142;; - Made `fast-lock-save-cache' do `cdr-safe' not `cdr' (from Dave Foster)
143;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster). 143;; - Made `fast-lock-save-cache' do `set-buffer' first (from Dave Foster)
144;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym). 144;; - Made `fast-lock-save-cache' loop until saved or quit (from Georg Nikodym)
145;; - Made `fast-lock-cache-data' check `buffer-modified-p'. 145;; - Made `fast-lock-cache-data' check `buffer-modified-p'
146;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary. 146;; - Made `fast-lock-cache-data' do `font-lock-compile-keywords' if necessary
147;; - XEmacs: Made `font-lock-compile-keywords' `defalias'. 147;; - XEmacs: Made `font-lock-compile-keywords' `defalias'
148;; 3.06--3.07: 148;; 3.06--3.07:
149;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook. 149;; - XEmacs: Add `fast-lock-after-fontify-buffer' to the Font Lock hook
150;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist'. 150;; - Made `fast-lock-cache-name' explain the use of `directory-abbrev-alist'
151;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name'. 151;; - Made `fast-lock-mode' use `buffer-file-truename' not `buffer-file-name'
152;; 3.07--3.08: 152;; 3.07--3.08:
153;; - Made `fast-lock-read-cache' set `fast-lock-cache-filename'. 153;; - Made `fast-lock-read-cache' set `fast-lock-cache-filename'
154;; 3.08--3.09:
155;; - Made `fast-lock-save-cache' cope if `fast-lock-minimum-size' is a list
156;; - Made `fast-lock-mode' respect the value of `font-lock-inhibit-thing-lock'
157;; - Added `fast-lock-after-unfontify-buffer'
154 158
155(require 'font-lock) 159(require 'font-lock)
156 160
@@ -162,7 +166,7 @@
162 "Submit via mail a bug report on fast-lock.el." 166 "Submit via mail a bug report on fast-lock.el."
163 (interactive) 167 (interactive)
164 (let ((reporter-prompt-for-summary-p t)) 168 (let ((reporter-prompt-for-summary-p t))
165 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.08" 169 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.09"
166 '(fast-lock-cache-directories fast-lock-minimum-size 170 '(fast-lock-cache-directories fast-lock-minimum-size
167 fast-lock-save-others fast-lock-save-events fast-lock-save-faces) 171 fast-lock-save-others fast-lock-save-events fast-lock-save-faces)
168 nil nil 172 nil nil
@@ -204,7 +208,12 @@ home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'.")
204(defvar fast-lock-minimum-size (* 25 1024) 208(defvar fast-lock-minimum-size (* 25 1024)
205 "If non-nil, the minimum size for buffers. 209 "If non-nil, the minimum size for buffers.
206Only buffers more than this can have associated Font Lock cache files saved. 210Only buffers more than this can have associated Font Lock cache files saved.
207If nil, means size is irrelevant.") 211If nil, means cache files are never created.
212If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
213where MAJOR-MODE is a symbol or t (meaning the default). For example:
214 ((c++-mode . 25600) (c-mode . 25600) (rmail-mode . 1048576))
215means that the minimum size is 25K for buffers in `c++-mode' or `c-mode', one
216megabyte for buffers in `rmail-mode', and size is irrelevant otherwise.")
208 217
209(defvar fast-lock-save-events '(kill-buffer kill-emacs) 218(defvar fast-lock-save-events '(kill-buffer kill-emacs)
210 "A list of events under which caches will be saved. 219 "A list of events under which caches will be saved.
@@ -223,7 +232,8 @@ Font Lock cache files saved. Ownership may be unknown for networked files.")
223 (if (save-match-data (string-match "XEmacs" (emacs-version))) 232 (if (save-match-data (string-match "XEmacs" (emacs-version)))
224 '(font-lock-string-face font-lock-doc-string-face font-lock-type-face 233 '(font-lock-string-face font-lock-doc-string-face font-lock-type-face
225 font-lock-function-name-face font-lock-comment-face 234 font-lock-function-name-face font-lock-comment-face
226 font-lock-keyword-face font-lock-preprocessor-face) 235 font-lock-keyword-face font-lock-reference-face
236 font-lock-preprocessor-face)
227 ;; For Emacs 19.30 I don't think this is generally necessary. 237 ;; For Emacs 19.30 I don't think this is generally necessary.
228 nil) 238 nil)
229 "A list of faces that will be saved in a Font Lock cache file. 239 "A list of faces that will be saved in a Font Lock cache file.
@@ -263,6 +273,7 @@ Use \\[fast-lock-submit-bug-report] to send bug reports or feedback."
263 ;; but many packages temporarily wrap that to nil when doing their own thing. 273 ;; but many packages temporarily wrap that to nil when doing their own thing.
264 (set (make-local-variable 'fast-lock-mode) 274 (set (make-local-variable 'fast-lock-mode)
265 (and buffer-file-truename 275 (and buffer-file-truename
276 (not (memq 'fast-lock-mode font-lock-inhibit-thing-lock))
266 (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode)))) 277 (if arg (> (prefix-numeric-value arg) 0) (not fast-lock-mode))))
267 (if (and fast-lock-mode (not font-lock-mode)) 278 (if (and fast-lock-mode (not font-lock-mode))
268 ;; Turned on `fast-lock-mode' rather than using `font-lock-mode-hook'. 279 ;; Turned on `fast-lock-mode' rather than using `font-lock-mode-hook'.
@@ -327,7 +338,11 @@ See `fast-lock-mode'."
327 (interactive) 338 (interactive)
328 (save-excursion 339 (save-excursion
329 (and buffer (set-buffer buffer)) 340 (and buffer (set-buffer buffer))
330 (let ((file-timestamp (visited-file-modtime)) (saved nil)) 341 (let ((min-size (if (not (consp fast-lock-minimum-size))
342 fast-lock-minimum-size
343 (cdr (or (assq major-mode fast-lock-minimum-size)
344 (assq t fast-lock-minimum-size)))))
345 (file-timestamp (visited-file-modtime)) (saved nil))
331 (if (and fast-lock-mode 346 (if (and fast-lock-mode
332 ;; 347 ;;
333 ;; "Only save if the buffer matches the file, the file has 348 ;; "Only save if the buffer matches the file, the file has
@@ -344,8 +359,7 @@ See `fast-lock-mode'."
344 (not (equal fast-lock-cache-timestamp file-timestamp)) 359 (not (equal fast-lock-cache-timestamp file-timestamp))
345 ;; 360 ;;
346 ;; Only save if user's restrictions are satisfied. 361 ;; Only save if user's restrictions are satisfied.
347 (or (not fast-lock-minimum-size) 362 (and min-size (>= (buffer-size) min-size))
348 (<= fast-lock-minimum-size (buffer-size)))
349 (or fast-lock-save-others 363 (or fast-lock-save-others
350 (eq (user-uid) (nth 2 (file-attributes buffer-file-name)))) 364 (eq (user-uid) (nth 2 (file-attributes buffer-file-name))))
351 ;; 365 ;;
@@ -375,6 +389,9 @@ See `fast-lock-mode'."
375 (message "File %s font lock cache cannot be deleted" (buffer-name)))) 389 (message "File %s font lock cache cannot be deleted" (buffer-name))))
376 ;; Flag so that a cache will be saved later even if the file is never saved. 390 ;; Flag so that a cache will be saved later even if the file is never saved.
377 (setq fast-lock-cache-timestamp nil)) 391 (setq fast-lock-cache-timestamp nil))
392
393(defalias 'fast-lock-after-unfontify-buffer
394 'ignore)
378 395
379;; Miscellaneous Functions: 396;; Miscellaneous Functions:
380 397
@@ -625,6 +642,10 @@ See `fast-lock-get-face-properties' for the format of PROPERTIES."
625 (add-hook 'font-lock-after-fontify-buffer-hook 642 (add-hook 'font-lock-after-fontify-buffer-hook
626 'fast-lock-after-fontify-buffer)) 643 'fast-lock-after-fontify-buffer))
627 644
645(or (boundp 'font-lock-inhibit-thing-lock)
646 (defvar font-lock-inhibit-thing-lock nil
647 "List of Font Lock mode related modes that should not be turned on."))
648
628(or (fboundp 'font-lock-compile-keywords) 649(or (fboundp 'font-lock-compile-keywords)
629 (defalias 'font-lock-compile-keywords 'identity)) 650 (defalias 'font-lock-compile-keywords 'identity))
630 651
@@ -637,11 +658,8 @@ See `fast-lock-get-face-properties' for the format of PROPERTIES."
637(add-hook 'kill-buffer-hook 'fast-lock-kill-buffer-hook) 658(add-hook 'kill-buffer-hook 'fast-lock-kill-buffer-hook)
638(add-hook 'kill-emacs-hook 'fast-lock-kill-emacs-hook) 659(add-hook 'kill-emacs-hook 'fast-lock-kill-emacs-hook)
639 660
640;; Maybe save on the modeline?
641;;(setcdr (assq 'font-lock-mode minor-mode-alist) '(" Fast"))
642
643(or (assq 'fast-lock-mode minor-mode-alist) 661(or (assq 'fast-lock-mode minor-mode-alist)
644 (setq minor-mode-alist (cons '(fast-lock-mode " Fast") minor-mode-alist))) 662 (setq minor-mode-alist (append minor-mode-alist '((fast-lock-mode nil)))))
645 663
646;; Provide ourselves: 664;; Provide ourselves:
647 665
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index e02ffb11d75..68bb6b310c9 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -589,17 +589,18 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'."
589 (save-match-data 589 (save-match-data
590 (setq font-lock-fontified nil) 590 (setq font-lock-fontified nil)
591 (font-lock-fontify-region (point-min) (point-max) verbose) 591 (font-lock-fontify-region (point-min) (point-max) verbose)
592 (font-lock-after-fontify-buffer)
592 (setq font-lock-fontified t))) 593 (setq font-lock-fontified t)))
593 ;; We don't restore the old fontification, so it's best to unfontify. 594 ;; We don't restore the old fontification, so it's best to unfontify.
594 (quit (font-lock-unfontify-region (point-min) (point-max)))) 595 (quit (font-lock-unfontify-region (point-min) (point-max))))
595 (if verbose (message "Fontifying %s... %s." (buffer-name) 596 (if verbose (message "Fontifying %s... %s." (buffer-name)
596 (if font-lock-fontified "done" "aborted"))) 597 (if font-lock-fontified "done" "aborted"))))))
597 (font-lock-after-fontify-buffer))))
598 598
599(defun font-lock-default-unfontify-buffer () 599(defun font-lock-default-unfontify-buffer ()
600 (save-restriction 600 (save-restriction
601 (widen) 601 (widen)
602 (font-lock-unfontify-region (point-min) (point-max)) 602 (font-lock-unfontify-region (point-min) (point-max))
603 (font-lock-after-unfontify-buffer)
603 (setq font-lock-fontified nil))) 604 (setq font-lock-fontified nil)))
604 605
605;; We use this wrapper. However, `font-lock-fontify-region' used to be the 606;; We use this wrapper. However, `font-lock-fontify-region' used to be the
@@ -941,13 +942,20 @@ START should be at the beginning of a line."
941 ((and (boundp 'lazy-lock-mode) lazy-lock-mode) 942 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
942 (lazy-lock-mode -1)))) 943 (lazy-lock-mode -1))))
943 944
944;; Do something special for these packages after fontifying. I prefer a hook. 945;; Do something special for these packages after fontifying; I prefer a hook.
945(defun font-lock-after-fontify-buffer () 946(defun font-lock-after-fontify-buffer ()
946 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) 947 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
947 (fast-lock-after-fontify-buffer)) 948 (fast-lock-after-fontify-buffer))
948 ((and (boundp 'lazy-lock-mode) lazy-lock-mode) 949 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
949 (lazy-lock-after-fontify-buffer)))) 950 (lazy-lock-after-fontify-buffer))))
950 951
952;; Do something special for these packages after unfontifying; I prefer a hook.
953(defun font-lock-after-unfontify-buffer ()
954 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
955 (fast-lock-after-unfontify-buffer))
956 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
957 (lazy-lock-after-unfontify-buffer))))
958
951;; If the buffer is about to be reverted, it won't be fontified afterward. 959;; If the buffer is about to be reverted, it won't be fontified afterward.
952(defun font-lock-revert-setup () 960(defun font-lock-revert-setup ()
953 (setq font-lock-fontified nil)) 961 (setq font-lock-fontified nil))
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 31be2304bb0..961a94e5276 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -647,7 +647,10 @@ Instead, these commands are available:
647(defun rmail-variables () 647(defun rmail-variables ()
648 (make-local-variable 'revert-buffer-function) 648 (make-local-variable 'revert-buffer-function)
649 (setq revert-buffer-function 'rmail-revert) 649 (setq revert-buffer-function 'rmail-revert)
650 (make-local-variable 'font-lock-defaults) 650 (setq font-lock-defaults
651 '(rmail-font-lock-keywords t nil nil nil
652 (rmail-fontify-buffer-function rmail-unfontify-buffer-function nil nil
653 (fast-lock-mode))))
651 (setq font-lock-defaults '(rmail-font-lock-keywords t)) 654 (setq font-lock-defaults '(rmail-font-lock-keywords t))
652 (make-local-variable 'rmail-last-label) 655 (make-local-variable 'rmail-last-label)
653 (make-local-variable 'rmail-last-regexp) 656 (make-local-variable 'rmail-last-regexp)
@@ -2525,6 +2528,34 @@ This has an effect only if a summary buffer exists.")
2525 (window-height)))) 2528 (window-height))))
2526 (select-window selected))))) 2529 (select-window selected)))))
2527 2530
2531;;;; *** Rmail Local Fontification ***
2532
2533(defun rmail-fontify-buffer-function ()
2534 ;; This function's symbol is bound to font-lock-fontify-buffer-function.
2535 (if (and (boundp 'lazy-lock-mode) lazy-lock-mode)
2536 (setq font-lock-fontify-buffer-function
2537 'font-lock-default-fontify-buffer)
2538 (make-local-hook 'rmail-show-message-hook)
2539 (add-hook 'rmail-show-message-hook 'rmail-fontify-message nil t)
2540 (rmail-fontify-message)))
2541
2542(defun rmail-unfontify-buffer-function ()
2543 ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
2544 (remove-hook 'rmail-show-message-hook 'rmail-fontify-message t)
2545 (font-lock-default-unfontify-buffer))
2546
2547(defun rmail-fontify-message ()
2548 ;; Fontify the current message if it is not already fontified.
2549 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil)
2550 (let ((modified (buffer-modified-p))
2551 (buffer-undo-list t) (inhibit-read-only t)
2552 before-change-functions after-change-functions
2553 buffer-file-name buffer-file-truename)
2554 (save-excursion
2555 (save-match-data
2556 (add-text-properties (point-min) (point-max) '(rmail-fontified t))
2557 (font-lock-fontify-region (point-min) (point-max)))))))
2558
2528;;;; *** Rmail Specify Inbox Files *** 2559;;;; *** Rmail Specify Inbox Files ***
2529 2560
2530(autoload 'set-rmail-inbox-list "rmailmsc" 2561(autoload 'set-rmail-inbox-list "rmailmsc"