]> code.delx.au - gnu-emacs/blobdiff - lisp/fast-lock.el
(timezone-parse-date): Match forms 1 and 2 first.
[gnu-emacs] / lisp / fast-lock.el
index aa3a57b9e41170dad3680555fec884f698f07716..09ecd27d4e0295e16df2ab6f75b57c45baebe18e 100644 (file)
@@ -1,10 +1,10 @@
 ;;; fast-lock.el --- Automagic text properties caching for fast Font Lock mode.
 
-;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
 ;; Author: Simon Marshall <simon@gnu.ai.mit.edu>
 ;; Keywords: faces files
-;; Version: 3.11
+;; Version: 3.12.01
 
 ;;; This file is part of GNU Emacs.
 
 ;; - Added `fast-lock-verbose'
 ;; - XEmacs: Add `font-lock-value-in-major-mode' if necessary
 ;; - Removed `fast-lock-submit-bug-report' and bade farewell
+;; 3.11--3.12:
+;; - Added Custom support (Hrvoje Niksic help)
+;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks'
+;; - Made `fast-lock-cache-data' simplify calls of `font-lock-compile-keywords'
+;; 3.12--3.13:
+;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint)
 \f
 ;;; Code:
 
   ;; We don't do this at the top-level as we only use non-autoloaded macros.
   (require 'cl)
   ;;
-  ;; I prefer lazy code---and lazy mode.
-  (setq byte-compile-dynamic t byte-compile-dynamic-docstrings t)
-  ;; But, we make sure that the code is as zippy as can be.
-  (setq byte-optimize t)
-  ;;
   ;; We use this to preserve or protect things when modifying text properties.
   (defmacro save-buffer-state (varlist &rest body)
     "Bind variables according to VARLIST and eval BODY restoring buffer state."
     (` (let* ((,@ (append varlist
-                  '((modified (buffer-modified-p))
-                    (inhibit-read-only t) (buffer-undo-list t)
+                  '((modified (buffer-modified-p)) (buffer-undo-list t)
+                    (inhibit-read-only t) (inhibit-point-motion-hooks t)
                     before-change-functions after-change-functions
                     deactivate-mark buffer-file-name buffer-file-truename))))
         (,@ body)
             (let ((faces (, face)))
               (while (unless (memq (car faces) fast-lock-save-faces)
                        (setq faces (cdr faces))))
-              faces))))))
+              faces)))))
+  ;;
+  ;; We use this for compatibility with a future Emacs.
+  (or (fboundp 'defcustom)
+      (defmacro defcustom (symbol value doc &rest args) 
+       (` (defvar (, symbol) (, value) (, doc))))))
 
 ;(defun fast-lock-submit-bug-report ()
 ;  "Submit via mail a bug report on fast-lock.el."
 ;  (interactive)
 ;  (let ((reporter-prompt-for-summary-p t))
-;    (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.11"
+;    (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "fast-lock 3.12.01"
 ;     '(fast-lock-cache-directories fast-lock-minimum-size
 ;       fast-lock-save-others fast-lock-save-events fast-lock-save-faces
 ;       fast-lock-verbose)
 ;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'.
 ;In the `*scratch*' buffer, evaluate:"))))
 
-(defvar fast-lock-mode nil)
-(defvar fast-lock-cache-timestamp nil) ; for saving/reading
-(defvar fast-lock-cache-filename nil)  ; for deleting
+(defvar fast-lock-mode nil)            ; Whether we are turned on.
+(defvar fast-lock-cache-timestamp nil) ; For saving/reading.
+(defvar fast-lock-cache-filename nil)  ; For deleting.
 \f
 ;; User Variables:
 
-(defvar fast-lock-cache-directories '("." "~/.emacs-flc")
+(defcustom fast-lock-cache-directories '("." "~/.emacs-flc")
 ; - `internal', keep each file's Font Lock cache file in the same file.
 ; - `external', keep each file's Font Lock cache file in the same directory.
   "*Directories in which Font Lock cache files are saved and read.
@@ -244,9 +250,14 @@ For example:
  ((\"^/your/true/home/directory/\" . \".\") \"~/.emacs-flc\")
 
 would cause a file's current directory to be used if the file is under your
-home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'.")
-
-(defvar fast-lock-minimum-size (* 25 1024)
+home directory hierarchy, or otherwise the absolute directory `~/.emacs-flc'."
+  :type '(repeat (radio (directory :tag "directory")
+                       (cons :tag "Matching"
+                             (regexp :tag "regexp")
+                             (directory :tag "directory"))))
+  :group 'fast-lock)
+
+(defcustom fast-lock-minimum-size (* 25 1024)
   "*Minimum size of a buffer for cached fontification.
 Only buffers more than this can have associated Font Lock cache files saved.
 If nil, means cache files are never created.
@@ -254,18 +265,44 @@ If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
 where MAJOR-MODE is a symbol or t (meaning the default).  For example:
  ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576))
 means that the minimum size is 25K for buffers in C or C++ modes, one megabyte
-for buffers in Rmail mode, and size is irrelevant otherwise.")
-
-(defvar fast-lock-save-events '(kill-buffer kill-emacs)
+for buffers in Rmail mode, and size is irrelevant otherwise."
+  :type '(choice (const :tag "none" nil)
+                (integer :tag "size")
+                (repeat :menu-tag "mode specific" :tag "mode specific"
+                        :value ((t . nil))
+                        (cons :tag "Instance"
+                              (radio :tag "Mode"
+                                     (const :tag "all" t)
+                                     (symbol :tag "name"))
+                              (radio :tag "Size"
+                                     (const :tag "none" nil)
+                                     (integer :tag "size")))))
+  :group 'fast-lock)
+
+(defcustom fast-lock-save-events '(kill-buffer kill-emacs)
   "*Events under which caches will be saved.
 Valid events are `save-buffer', `kill-buffer' and `kill-emacs'.
 If concurrent editing sessions use the same associated cache file for a file's
-buffer, then you should add `save-buffer' to this list.")
+buffer, then you should add `save-buffer' to this list."
+  :type '(set (const :tag "buffer saving" save-buffer)
+             (const :tag "buffer killing" kill-buffer)
+             (const :tag "emacs killing" kill-emacs))
+  :group 'fast-lock)
 
-(defvar fast-lock-save-others t
+(defcustom fast-lock-save-others t
   "*If non-nil, save Font Lock cache files irrespective of file owner.
 If nil, means only buffer files known to be owned by you can have associated
-Font Lock cache files saved.  Ownership may be unknown for networked files.")
+Font Lock cache files saved.  Ownership may be unknown for networked files."
+  :type 'boolean
+  :group 'fast-lock)
+
+(defcustom fast-lock-verbose font-lock-verbose
+  "*If non-nil, means show status messages for cache processing.
+If a number, only buffers greater than this size have processing messages."
+  :type '(choice (const :tag "never" nil)
+                (const :tag "always" t)
+                (integer :tag "size"))
+  :group 'fast-lock)
 
 (defvar fast-lock-save-faces
   (when (save-match-data (string-match "XEmacs" (emacs-version)))
@@ -273,10 +310,6 @@ Font Lock cache files saved.  Ownership may be unknown for networked files.")
     font-lock-face-list)
   "Faces that will be saved in a Font Lock cache file.
 If nil, means information for all faces will be saved.")
-
-(defvar fast-lock-verbose font-lock-verbose
-  "*If non-nil, means show status messages for cache processing.
-If a number, only buffers greater than this size have processing messages.")
 \f
 ;; User Functions:
 
@@ -543,10 +576,9 @@ See `fast-lock-cache-directory'."
   ;; Change from (HIGH LOW) for back compatibility.  Remove for version 3!
   (when (consp (cdr-safe timestamp))
     (setcdr timestamp (nth 1 timestamp)))
-  ;; Compile KEYWORDS and `font-lock-keywords' in case one is and one isn't.
-  (let ((current font-lock-keywords))
-    (setq keywords (font-lock-compile-keywords keywords)
-         font-lock-keywords (font-lock-compile-keywords current)))
+  ;; Compile `font-lock-keywords' and KEYWORDS in case one is and one isn't.
+  (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords)
+       keywords (font-lock-compile-keywords keywords))
   ;; Use the Font Lock cache PROPERTIES if we're using cache VERSION format 2,
   ;; the current buffer's file timestamp matches the TIMESTAMP, and the current
   ;; buffer's font-lock-keywords are the same as KEYWORDS.
@@ -723,7 +755,9 @@ See `fast-lock-get-face-properties' for the format of PROPERTIES."
 (add-hook 'kill-emacs-hook 'fast-lock-save-caches-before-kill-emacs)
 
 ;;;###autoload
-(if (fboundp 'add-minor-mode) (add-minor-mode 'fast-lock-mode nil))
+(when (fboundp 'add-minor-mode)
+  (defvar fast-lock-mode nil)
+  (add-minor-mode 'fast-lock-mode nil))
 ;;;###dont-autoload
 (unless (assq 'fast-lock-mode minor-mode-alist)
   (setq minor-mode-alist (append minor-mode-alist '((fast-lock-mode nil)))))