;;; 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:
-(defgroup fast-lock nil
- "Automagic text properties caching for fast Font Lock mode"
- :group 'faces)
-
-
(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.
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'."
- :type '(repeat (choice (cons regexp directory) directory))
+ :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)
((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."
- :type '(choice (integer :tag "Size") (repeat (cons (symbol :tag "Major Mode")
- (integer :tag "Size"))))
+ :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)
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."
- :type '(set (const kill-buffer) (const save-buffer) (const kill-emacs))
+ :type '(set (const :tag "buffer saving" save-buffer)
+ (const :tag "buffer killing" kill-buffer)
+ (const :tag "emacs killing" kill-emacs))
:group 'fast-lock)
(defcustom fast-lock-save-others t
: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)))
;; XEmacs uses extents for everything, so we have to pick the right ones.
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.")
-
-(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 integer boolean)
- :group 'fast-lock)
\f
;; User Functions:
;; 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.
(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)))))