comparison lisp/packages/fast-lock.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents 131b0175ea99
children 4be1180a9e89
comparison
equal deleted inserted replaced
97:498bf5da1c90 98:0d2f883870bc
2 2
3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. 3 ;; Copyright (C) 1994, 1995, 1996 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.10.01 7 ;; Version: 3.10.02
8 8
9 ;; This file is part of XEmacs. 9 ;;; This file is part of GNU Emacs.
10 ;; 10
11 ;; XEmacs 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
13 ;; the Free Software Foundation; either version 2 of the License, or 13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; (at your option) any later version. 14 ;; any later version.
15 ;; 15
16 ;; XEmacs is distributed in the hope that it will be useful, 16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
20 ;; 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Synched up with: FSF 19.34.
27 25
28 ;;; Commentary: 26 ;;; Commentary:
29 27
30 ;; Purpose: 28 ;; Purpose:
31 ;; 29 ;;
53 ;; A cache will be saved when visiting a compressed file using crypt++, but not 51 ;; A cache will be saved when visiting a compressed file using crypt++, but not
54 ;; be read. This is a "feature"/"consequence"/"bug" of crypt++. 52 ;; be read. This is a "feature"/"consequence"/"bug" of crypt++.
55 ;; 53 ;;
56 ;; Version control packages are likely to stamp all over file modification 54 ;; Version control packages are likely to stamp all over file modification
57 ;; times. Therefore the act of checking out may invalidate a cache. 55 ;; times. Therefore the act of checking out may invalidate a cache.
58 56 ;;;;;^L
59 ;; Feedback:
60 ;;
61 ;; Feedback is welcome.
62 ;; To submit a bug report (or make comments) please use the mechanism provided:
63 ;;
64 ;; M-x fast-lock-submit-bug-report RET
65
66 ;; History: 57 ;; History:
67 ;; 58 ;;
68 ;; 0.02--1.00: 59 ;; 0.02--1.00:
69 ;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only 60 ;; - Changed name from turbo-prop to fast-lock. Automagic for font-lock only
70 ;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode 61 ;; - Made `fast-lock-mode' a minor mode, like G. Dinesh Dutt's fss-mode
164 ;; - XEmacs: Made `fast-lock-save-faces' default to `font-lock-face-list' 155 ;; - XEmacs: Made `fast-lock-save-faces' default to `font-lock-face-list'
165 ;; - Made `fast-lock-save-cache' use `font-lock-value-in-major-mode' 156 ;; - Made `fast-lock-save-cache' use `font-lock-value-in-major-mode'
166 ;; - Wrap with `save-buffer-state' (Ray Van Tassle report) 157 ;; - Wrap with `save-buffer-state' (Ray Van Tassle report)
167 ;; - Made `fast-lock-mode' wrap `font-lock-support-mode' 158 ;; - Made `fast-lock-mode' wrap `font-lock-support-mode'
168 ;; 3.10--3.11: 159 ;; 3.10--3.11:
169 160 ;; - Made `fast-lock-get-face-properties' cope with face lists
161 ;; - Added `fast-lock-verbose'
162 ;; - XEmacs: Add `font-lock-value-in-major-mode' if necessary
163 ;;;;;^L
170 (require 'font-lock) 164 (require 'font-lock)
171 165
172 ;; Make sure fast-lock.el is supported. 166 ;; Make sure fast-lock.el is supported.
173 (if (and (eq system-type 'ms-dos) (not (msdos-long-file-names))) 167 (if (and (eq system-type 'ms-dos) (not (msdos-long-file-names)))
174 (error "`fast-lock' was written for long file name systems")) 168 (error "`fast-lock' was written for long file name systems"))
192 before-change-functions after-change-functions 186 before-change-functions after-change-functions
193 deactivate-mark buffer-file-name buffer-file-truename)))) 187 deactivate-mark buffer-file-name buffer-file-truename))))
194 (,@ body) 188 (,@ body)
195 (when (and (not modified) (buffer-modified-p)) 189 (when (and (not modified) (buffer-modified-p))
196 (set-buffer-modified-p nil))))) 190 (set-buffer-modified-p nil)))))
197 (put 'save-buffer-state 'lisp-indent-function 1)) 191 (put 'save-buffer-state 'lisp-indent-function 1)
192 ;;
193 ;; We use this to verify that a face should be saved.
194 (defmacro fast-lock-save-facep (face)
195 "Return non-nil if FACE matches `fast-lock-save-faces'."
196 (` (or (null fast-lock-save-faces)
197 (if (symbolp (, face))
198 (memq (, face) fast-lock-save-faces)
199 (let ((list (, face)) found)
200 (while list
201 (if (memq (car list) fast-lock-save-faces)
202 (setq list nil found t)
203 (setq list (cdr list))))
204 found))))))
198 205
199 (defun fast-lock-submit-bug-report () 206 (defun fast-lock-submit-bug-report ()
200 "Submit via mail a bug report on fast-lock.el." 207 "Submit via mail a bug report on fast-lock.el."
201 (interactive) 208 (interactive)
202 (let ((reporter-prompt-for-summary-p t)) 209 (let ((reporter-prompt-for-summary-p t))
203 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.10.01" 210 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.10.02"
204 '(fast-lock-cache-directories fast-lock-minimum-size 211 '(fast-lock-cache-directories fast-lock-minimum-size
205 fast-lock-save-others fast-lock-save-events fast-lock-save-faces) 212 fast-lock-save-others fast-lock-save-events fast-lock-save-faces
213 fast-lock-verbose)
206 nil nil 214 nil nil
207 (concat "Hi Si., 215 (concat "Hi Si.,
208 216
209 I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I 217 I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I
210 know how to make a clear and unambiguous report. To reproduce the bug: 218 know how to make a clear and unambiguous report. To reproduce the bug:
211 219
212 Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'. 220 Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'.
213 In the `*scratch*' buffer, evaluate:")))) 221 In the `*scratch*' buffer, evaluate:"))))
214 222
223 ;; XEmacs menu system requires this to be autoloaded
215 ;;;###autoload 224 ;;;###autoload
216 (defvar fast-lock-mode nil) 225 (defvar fast-lock-mode nil)
217 (defvar fast-lock-cache-timestamp nil) ; for saving/reading 226 (defvar fast-lock-cache-timestamp nil) ; for saving/reading
218 (defvar fast-lock-cache-filename nil) ; for deleting 227 (defvar fast-lock-cache-filename nil) ; for deleting
219 228 ;;;;;^L
220 ;; User Variables: 229 ;; User Variables:
221 230
222 (defvar fast-lock-cache-directories '("." "~/.emacs-flc") 231 (defvar fast-lock-cache-directories '("." "~/.emacs-flc")
223 ; - `internal', keep each file's Font Lock cache file in the same file. 232 ; - `internal', keep each file's Font Lock cache file in the same file.
224 ; - `external', keep each file's Font Lock cache file in the same directory. 233 ; - `external', keep each file's Font Lock cache file in the same directory.
264 (when (save-match-data (string-match "XEmacs" (emacs-version))) 273 (when (save-match-data (string-match "XEmacs" (emacs-version)))
265 ;; XEmacs uses extents for everything, so we have to pick the right ones. 274 ;; XEmacs uses extents for everything, so we have to pick the right ones.
266 font-lock-face-list) 275 font-lock-face-list)
267 "Faces that will be saved in a Font Lock cache file. 276 "Faces that will be saved in a Font Lock cache file.
268 If nil, means information for all faces will be saved.") 277 If nil, means information for all faces will be saved.")
269 278
279 (defvar fast-lock-verbose font-lock-verbose
280 "*If non-nil, means show status messages for cache processing.
281 If a number, only buffers greater than this size have processing messages.")
282 ;;;;;^L
270 ;; User Functions: 283 ;; User Functions:
271 284
272 ;;;###autoload 285 ;;;###autoload
273 (defun fast-lock-mode (&optional arg) 286 (defun fast-lock-mode (&optional arg)
274 "Toggle Fast Lock mode. 287 "Toggle Fast Lock mode.
291 Use \\[font-lock-fontify-buffer] to fontify the buffer if the cache is bad. 304 Use \\[font-lock-fontify-buffer] to fontify the buffer if the cache is bad.
292 305
293 Various methods of control are provided for the Font Lock cache. In general, 306 Various methods of control are provided for the Font Lock cache. In general,
294 see variable `fast-lock-cache-directories' and function `fast-lock-cache-name'. 307 see variable `fast-lock-cache-directories' and function `fast-lock-cache-name'.
295 For saving, see variables `fast-lock-minimum-size', `fast-lock-save-events', 308 For saving, see variables `fast-lock-minimum-size', `fast-lock-save-events',
296 `fast-lock-save-others' and `fast-lock-save-faces'. 309 `fast-lock-save-others' and `fast-lock-save-faces'."
297
298 Use \\[fast-lock-submit-bug-report] to send bug reports or feedback."
299 (interactive "P") 310 (interactive "P")
300 ;; Only turn on if we are visiting a file. We could use `buffer-file-name', 311 ;; Only turn on if we are visiting a file. We could use `buffer-file-name',
301 ;; but many packages temporarily wrap that to nil when doing their own thing. 312 ;; but many packages temporarily wrap that to nil when doing their own thing.
302 (set (make-local-variable 'fast-lock-mode) 313 (set (make-local-variable 'fast-lock-mode)
303 (and buffer-file-truename 314 (and buffer-file-truename
401 412
402 ;;;###autoload 413 ;;;###autoload
403 (defun turn-on-fast-lock () 414 (defun turn-on-fast-lock ()
404 "Unconditionally turn on Fast Lock mode." 415 "Unconditionally turn on Fast Lock mode."
405 (fast-lock-mode t)) 416 (fast-lock-mode t))
406 417 ;;;;;^L
407 ;;; API Functions: 418 ;;; API Functions:
408 419
409 (defun fast-lock-after-fontify-buffer () 420 (defun fast-lock-after-fontify-buffer ()
410 ;; Delete the Font Lock cache file used to restore fontification, if any. 421 ;; Delete the Font Lock cache file used to restore fontification, if any.
411 (when fast-lock-cache-filename 422 (when fast-lock-cache-filename
415 ;; Flag so that a cache will be saved later even if the file is never saved. 426 ;; Flag so that a cache will be saved later even if the file is never saved.
416 (setq fast-lock-cache-timestamp nil)) 427 (setq fast-lock-cache-timestamp nil))
417 428
418 (defalias 'fast-lock-after-unfontify-buffer 429 (defalias 'fast-lock-after-unfontify-buffer
419 'ignore) 430 'ignore)
420 431 ;;;;;^L
421 ;; Miscellaneous Functions: 432 ;; Miscellaneous Functions:
422 433
423 (defun fast-lock-save-cache-after-save-file () 434 (defun fast-lock-save-cache-after-save-file ()
424 ;; Do `fast-lock-save-cache' if `save-buffer' is on `fast-lock-save-events'. 435 ;; Do `fast-lock-save-cache' if `save-buffer' is on `fast-lock-save-events'.
425 (when (memq 'save-buffer fast-lock-save-events) 436 (when (memq 'save-buffer fast-lock-save-events)
494 (function (lambda (c) (or (cdr (assq c chars-alist)) (list c)))))) 505 (function (lambda (c) (or (cdr (assq c chars-alist)) (list c))))))
495 (concat 506 (concat
496 (file-name-as-directory (expand-file-name directory)) 507 (file-name-as-directory (expand-file-name directory))
497 (mapconcat 'char-to-string (apply 'append (mapcar mapchars bufile)) "") 508 (mapconcat 'char-to-string (apply 'append (mapcar mapchars bufile)) "")
498 ".flc")))) 509 ".flc"))))
499 510 ;;;;;^L
500 ;; Font Lock Cache Processing Functions: 511 ;; Font Lock Cache Processing Functions:
501 512
502 (defun fast-lock-save-cache-1 (file timestamp) 513 (defun fast-lock-save-cache-1 (file timestamp)
503 ;; Save the FILE with the TIMESTAMP as: 514 ;; Save the FILE with the TIMESTAMP as:
504 ;; (fast-lock-cache-data Version=2 TIMESTAMP font-lock-keywords PROPERTIES). 515 ;; (fast-lock-cache-data Version=2 TIMESTAMP font-lock-keywords PROPERTIES).
505 ;; Returns non-nil if a save was attempted to a writable cache file. 516 ;; Returns non-nil if a save was attempted to a writable cache file.
506 (let ((tpbuf (generate-new-buffer " *fast-lock*")) 517 (let ((tpbuf (generate-new-buffer " *fast-lock*"))
507 (buname (buffer-name)) (saved t)) 518 (verbose (if (numberp fast-lock-verbose)
508 (message "Saving %s font lock cache..." buname) 519 (> (buffer-size) fast-lock-verbose)
520 fast-lock-verbose))
521 (saved t))
522 (if verbose (message "Saving %s font lock cache..." (buffer-name)))
509 (condition-case nil 523 (condition-case nil
510 (save-excursion 524 (save-excursion
511 (print (list 'fast-lock-cache-data 2 525 (print (list 'fast-lock-cache-data 2
512 (list 'quote timestamp) 526 (list 'quote timestamp)
513 (list 'quote font-lock-keywords) 527 (list 'quote font-lock-keywords)
517 (write-region (point-min) (point-max) file nil 'quietly) 531 (write-region (point-min) (point-max) file nil 'quietly)
518 (setq fast-lock-cache-timestamp timestamp 532 (setq fast-lock-cache-timestamp timestamp
519 fast-lock-cache-filename file)) 533 fast-lock-cache-filename file))
520 (error (setq saved 'error)) (quit (setq saved 'quit))) 534 (error (setq saved 'error)) (quit (setq saved 'quit)))
521 (kill-buffer tpbuf) 535 (kill-buffer tpbuf)
522 (message "Saving %s font lock cache...%s" buname 536 (if verbose (message "Saving %s font lock cache...%s" (buffer-name)
523 (cond ((eq saved 'error) "failed") 537 (cond ((eq saved 'error) "failed")
524 ((eq saved 'quit) "aborted") 538 ((eq saved 'quit) "aborted")
525 (t "done"))) 539 (t "done"))))
526 ;; We return non-nil regardless of whether a failure occurred. 540 ;; We return non-nil regardless of whether a failure occurred.
527 saved)) 541 saved))
528 542
529 (defun fast-lock-cache-data (version timestamp keywords properties 543 (defun fast-lock-cache-data (version timestamp keywords properties
530 &rest ignored) 544 &rest ignored)
537 font-lock-keywords (font-lock-compile-keywords current))) 551 font-lock-keywords (font-lock-compile-keywords current)))
538 ;; Use the Font Lock cache PROPERTIES if we're using cache VERSION format 2, 552 ;; Use the Font Lock cache PROPERTIES if we're using cache VERSION format 2,
539 ;; the current buffer's file timestamp matches the TIMESTAMP, and the current 553 ;; the current buffer's file timestamp matches the TIMESTAMP, and the current
540 ;; buffer's font-lock-keywords are the same as KEYWORDS. 554 ;; buffer's font-lock-keywords are the same as KEYWORDS.
541 (let ((buf-timestamp (visited-file-modtime)) 555 (let ((buf-timestamp (visited-file-modtime))
542 (buname (buffer-name)) (loaded t)) 556 (verbose (if (numberp fast-lock-verbose)
557 (> (buffer-size) fast-lock-verbose)
558 fast-lock-verbose))
559 (loaded t))
543 (if (or (/= version 2) 560 (if (or (/= version 2)
544 (buffer-modified-p) 561 (buffer-modified-p)
545 (not (equal timestamp buf-timestamp)) 562 (not (equal timestamp buf-timestamp))
546 (not (equal keywords font-lock-keywords))) 563 (not (equal keywords font-lock-keywords)))
547 (setq loaded nil) 564 (setq loaded nil)
548 (message "Loading %s font lock cache..." buname) 565 (if verbose (message "Loading %s font lock cache..." (buffer-name)))
549 (condition-case nil 566 (condition-case nil
550 (fast-lock-set-face-properties properties) 567 (fast-lock-set-face-properties properties)
551 (error (setq loaded 'error)) (quit (setq loaded 'quit))) 568 (error (setq loaded 'error)) (quit (setq loaded 'quit)))
552 (message "Loading %s font lock cache...%s" buname 569 (if verbose (message "Loading %s font lock cache...%s" (buffer-name)
553 (cond ((eq loaded 'error) "failed") 570 (cond ((eq loaded 'error) "failed")
554 ((eq loaded 'quit) "aborted") 571 ((eq loaded 'quit) "aborted")
555 (t "done")))) 572 (t "done")))))
556 (setq font-lock-fontified (eq loaded t) 573 (setq font-lock-fontified (eq loaded t)
557 fast-lock-cache-timestamp (and (eq loaded t) timestamp)))) 574 fast-lock-cache-timestamp (and (eq loaded t) timestamp))))
558 575 ;;;;;^L
559 ;; Text Properties Processing Functions: 576 ;; Text Properties Processing Functions:
560 577
561 ;; This is faster, but fails if adjacent characters have different `face' text 578 ;; This is faster, but fails if adjacent characters have different `face' text
562 ;; properties. Maybe that's why I dropped it in the first place? 579 ;; properties. Maybe that's why I dropped it in the first place?
563 ;(defun fast-lock-get-face-properties () 580 ;(defun fast-lock-get-face-properties ()
576 ; (setcdr cell (cons start (cons end (cdr cell)))) 593 ; (setcdr cell (cons start (cons end (cdr cell))))
577 ; (setq properties (cons (list value start end) properties))) 594 ; (setq properties (cons (list value start end) properties)))
578 ; (setq start (next-single-property-change end 'face))) 595 ; (setq start (next-single-property-change end 'face)))
579 ; properties))) 596 ; properties)))
580 597
598 ;; This copes if adjacent characters have different `face' text properties, but
599 ;; fails if they are lists.
600 ;(defun fast-lock-get-face-properties ()
601 ; "Return a list of all `face' text properties in the current buffer.
602 ;Each element of the list is of the form (VALUE START1 END1 START2 END2 ...)
603 ;where VALUE is a `face' property value and STARTx and ENDx are positions.
604 ;Only those `face' VALUEs in `fast-lock-save-faces' are returned."
605 ; (save-restriction
606 ; (widen)
607 ; (let ((faces (or fast-lock-save-faces (face-list))) (limit (point-max))
608 ; properties regions face start end)
609 ; (while faces
610 ; (setq face (car faces) faces (cdr faces) regions () end (point-min))
611 ; ;; Make a list of start/end regions with `face' property face.
612 ; (while (setq start (text-property-any end limit 'face face))
613 ; (setq end (or (text-property-not-all start limit 'face face) limit)
614 ; regions (cons start (cons end regions))))
615 ; ;; Add `face' face's regions, if any, to properties.
616 ; (when regions
617 ; (push (cons face regions) properties)))
618 ; properties)))
619
581 (defun fast-lock-get-face-properties () 620 (defun fast-lock-get-face-properties ()
582 "Return a list of all `face' text properties in the current buffer. 621 "Return a list of all `face' text properties in the current buffer.
583 Each element of the list is of the form (VALUE START1 END1 START2 END2 ...) 622 Each element of the list is of the form (VALUE START1 END1 START2 END2 ...)
584 where VALUE is a `face' property value and STARTx and ENDx are positions. 623 where VALUE is a `face' property value and STARTx and ENDx are positions."
585 Only those `face' VALUEs in `fast-lock-save-faces' are returned."
586 (save-restriction 624 (save-restriction
587 (widen) 625 (widen)
588 (let ((faces (or fast-lock-save-faces (face-list))) (limit (point-max)) 626 (let ((start (text-property-not-all (point-min) (point-max) 'face nil))
589 properties regions face start end) 627 (limit (point-max)) end properties value cell)
590 (while faces 628 (while start
591 (setq face (car faces) faces (cdr faces) regions () end (point-min)) 629 (setq end (next-single-property-change start 'face nil limit)
592 ;; Make a list of start/end regions with `face' property face. 630 value (get-text-property start 'face))
593 (while (setq start (text-property-any end limit 'face face)) 631 ;; Make, or add to existing, list of regions with same `face'.
594 (setq end (or (text-property-not-all start limit 'face face) limit) 632 (cond ((setq cell (assoc value properties))
595 regions (cons start (cons end regions)))) 633 (setcdr cell (cons start (cons end (cdr cell)))))
596 ;; Add `face' face's regions, if any, to properties. 634 ((fast-lock-save-facep value)
597 (when regions 635 (push (list value start end) properties)))
598 (push (cons face regions) properties))) 636 (setq start (if (get-text-property end 'face)
637 end
638 (next-single-property-change end 'face))))
599 properties))) 639 properties)))
600 640
601 (defun fast-lock-set-face-properties (properties) 641 (defun fast-lock-set-face-properties (properties)
602 "Set all `face' text properties to PROPERTIES in the current buffer. 642 "Set all `face' text properties to PROPERTIES in the current buffer.
603 Any existing `face' text properties are removed first. 643 Any existing `face' text properties are removed first.
612 properties (cdr properties)) 652 properties (cdr properties))
613 ;; Set the `face' property for each start/end region. 653 ;; Set the `face' property for each start/end region.
614 (while regions 654 (while regions
615 (set-text-properties (nth 0 regions) (nth 1 regions) plist) 655 (set-text-properties (nth 0 regions) (nth 1 regions) plist)
616 (setq regions (nthcdr 2 regions))))))) 656 (setq regions (nthcdr 2 regions)))))))
617 657 ;;;;;^L
618 ;; Functions for XEmacs: 658 ;; Functions for XEmacs:
619 659
620 (when (save-match-data (string-match "XEmacs" (emacs-version))) 660 (when (save-match-data (string-match "XEmacs" (emacs-version)))
621 ;; 661 ;;
622 ;; It would be better to use XEmacs' `map-extents' over extents with a 662 ;; It would be better to use XEmacs' `map-extents' over extents with a
631 (let ((properties ()) cell) 671 (let ((properties ()) cell)
632 (map-extents 672 (map-extents
633 (function (lambda (extent ignore) 673 (function (lambda (extent ignore)
634 (let ((value (extent-face extent))) 674 (let ((value (extent-face extent)))
635 ;; We're only interested if it's one of `fast-lock-save-faces'. 675 ;; We're only interested if it's one of `fast-lock-save-faces'.
636 (when (and value (or (null fast-lock-save-faces) 676 (when (and value (fast-lock-save-facep value))
637 (memq value fast-lock-save-faces)))
638 (let ((start (extent-start-position extent)) 677 (let ((start (extent-start-position extent))
639 (end (extent-end-position extent))) 678 (end (extent-end-position extent)))
640 ;; Make or add to existing list of regions with the same 679 ;; Make or add to existing list of regions with the same
641 ;; `face' property value. 680 ;; `face' property value.
642 (if (setq cell (assq value properties)) 681 (if (setq cell (assoc value properties))
643 (setcdr cell (cons start (cons end (cdr cell)))) 682 (setcdr cell (cons start (cons end (cdr cell))))
644 (push (list value start end) properties)))) 683 (push (list value start end) properties))))
645 ;; Return nil to keep `map-extents' going. 684 ;; Return nil to keep `map-extents' going.
646 nil)))) 685 nil))))
647 properties))) 686 properties)))
678 (cdr (or (assq major-mode alist) (assq t alist))) 717 (cdr (or (assq major-mode alist) (assq t alist)))
679 alist))) 718 alist)))
680 719
681 (unless (fboundp 'font-lock-compile-keywords) 720 (unless (fboundp 'font-lock-compile-keywords)
682 (defalias 'font-lock-compile-keywords 'identity)) 721 (defalias 'font-lock-compile-keywords 'identity))
683 722 ;;;;;^L
684 ;; Install ourselves: 723 ;; Install ourselves:
685 724
686 (add-hook 'after-save-hook 'fast-lock-save-cache-after-save-file) 725 (add-hook 'after-save-hook 'fast-lock-save-cache-after-save-file)
687 (add-hook 'kill-buffer-hook 'fast-lock-save-cache-before-kill-buffer) 726 (add-hook 'kill-buffer-hook 'fast-lock-save-cache-before-kill-buffer)
688 (add-hook 'kill-emacs-hook 'fast-lock-save-caches-before-kill-emacs) 727 (add-hook 'kill-emacs-hook 'fast-lock-save-caches-before-kill-emacs)