changeset 17498:5ea11c278a57

Customise.
author Simon Marshall <simon@gnu.org>
date Thu, 17 Apr 1997 07:35:54 +0000
parents 3ee027d263c6
children 77604d2454dc
files lisp/fast-lock.el lisp/lazy-lock.el
diffstat 2 files changed, 127 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/fast-lock.el	Thu Apr 17 07:35:38 1997 +0000
+++ b/lisp/fast-lock.el	Thu Apr 17 07:35:54 1997 +0000
@@ -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
 
 ;;; This file is part of GNU Emacs.
 
@@ -160,6 +160,9 @@
 ;; - 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 `fast-lock-cache-data' simplify calls of `font-lock-compile-keywords'
 
 ;;; Code:
 
@@ -183,8 +186,8 @@
   (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)
@@ -207,7 +210,7 @@
 ;  "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"
 ;     '(fast-lock-cache-directories fast-lock-minimum-size
 ;       fast-lock-save-others fast-lock-save-events fast-lock-save-faces
 ;       fast-lock-verbose)
@@ -220,16 +223,16 @@
 ;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.
 
 ;; User Variables:
 
 (defgroup fast-lock nil
-  "Automagic text properties caching for fast Font Lock mode"
-  :group 'faces)
-
+  "Font Lock support mode to cache fontification."
+  :link '(custom-manual "(emacs)Support Modes")
+  :group 'font-lock)
 
 (defcustom fast-lock-cache-directories '("." "~/.emacs-flc")
 ; - `internal', keep each file's Font Lock cache file in the same file.
@@ -250,7 +253,7 @@
 
 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 (cons regexp directory) directory))
   :group 'fast-lock)
 
 (defcustom fast-lock-minimum-size (* 25 1024)
@@ -262,8 +265,10 @@
  ((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 '(radio (const :tag "None" nil)
+		(integer :tag "Size")
+		(repeat (cons (symbol :tag "Major Mode")
+			      (integer :tag "Size"))))
   :group 'fast-lock)
 
 (defcustom fast-lock-save-events '(kill-buffer kill-emacs)
@@ -281,18 +286,20 @@
   :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 '(radio (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)
 
 ;; User Functions:
 
@@ -559,10 +566,9 @@
   ;; 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.
@@ -739,7 +745,9 @@
 (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)))))
--- a/lisp/lazy-lock.el	Thu Apr 17 07:35:38 1997 +0000
+++ b/lisp/lazy-lock.el	Thu Apr 17 07:35:54 1997 +0000
@@ -1,10 +1,10 @@
 ;;; lazy-lock.el --- Lazy demand-driven fontification 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: 2.07
+;; Version: 2.08
 
 ;;; This file is part of GNU Emacs.
 
@@ -25,6 +25,8 @@
 
 ;;; Commentary:
 
+;; Purpose:
+;;
 ;; Lazy Lock mode is a Font Lock support mode.
 ;; It makes visiting buffers in Font Lock mode faster by making fontification
 ;; be demand-driven, deferred and stealthy, so that fontification only occurs
@@ -111,7 +113,7 @@
 ;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions'
 ;; were added for these circumstances.
 ;;
-;; Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented
+;; (Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented
 ;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14.
 ;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather
 ;; than `post-command-hook'.  Whereas functions on `post-command-hook' are
@@ -128,6 +130,9 @@
 ;; point in making this version of lazy-lock.el work with it.  Anyway, that's
 ;; Lit 30 of my humble opinion.
 ;;
+;; Steve Baur reverted to a non-hacked version 1 lazy-lock.el for XEmacs 19.15
+;; and 20.0.  Obviously, the above `post-command-hook' problems still apply.)
+;;
 ;; - Version 1 stealth fontification is also implemented by placing a function
 ;; on `post-command-hook'.  This function waits for a given amount of time,
 ;; and, if Emacs remains idle, fontifies where necessary.  Again, there are a
@@ -149,6 +154,21 @@
 ;; by functions on Idle Timers.  (A function on XEmacs' `pre-idle-hook' is
 ;; similar to an Emacs Idle Timer function with a fixed zero second timeout.)
 
+;; - Version 1 has the following problems (relative to version 2):
+;;
+;; (a) It is slow when it does its job.
+;; (b) It does not always do its job when it should.
+;; (c) It slows all interaction (when it doesn't need to do its job).
+;; (d) It interferes with other package functions on `post-command-hook'.
+;; (e) It interferes with Emacs things within the read-eval loop.
+;;
+;; Ben's hacked-up lazy-lock.el 1.14 almost solved (b) but made (c) worse.
+;;
+;; - Version 2 has the following additional features (relative to version 1):
+;;
+;; (a) It can defer fontification (both on-the-fly and on-scrolling).
+;; (b) It can fontify contextually (syntactically true on-the-fly).
+
 ;; Caveats:
 ;;
 ;; Lazy Lock mode does not work efficiently with Outline mode.
@@ -230,6 +250,9 @@
 ;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time'
 ;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling'
 ;; - Removed `lazy-lock-submit-bug-report' and bade farewell
+;; 2.07--2.08:
+;; - Made `lazy-lock-fontify-conservatively' fontify around `window-point'
+;; - Added Custom support
 
 ;;; Code:
 
@@ -241,11 +264,6 @@
       (and (= emacs-major-version 19) (< emacs-minor-version 30)))
     (error "`lazy-lock' was written for Emacs 19.30 or later"))
 
-;; Flush out those lusers who didn't read all of the Commentary.
-(if (or (memq 'turn-on-defer-lock font-lock-mode-hook)
-	(memq 'defer-lock-mode font-lock-mode-hook))
-    (error "`lazy-lock' was written for use without `defer-lock'"))
-  
 (eval-when-compile
   ;;
   ;; We don't do this at the top-level as idle timers are not necessarily used.
@@ -262,8 +280,8 @@
   (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)
@@ -291,7 +309,7 @@
 ;  "Submit via mail a bug report on lazy-lock.el."
 ;  (interactive)
 ;  (let ((reporter-prompt-for-summary-p t))
-;    (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.07"
+;    (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.08"
 ;     '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly
 ;       lazy-lock-defer-on-scrolling lazy-lock-defer-contextually
 ;       lazy-lock-defer-time lazy-lock-stealth-time
@@ -306,13 +324,18 @@
 ;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'.
 ;In the `*scratch*' buffer, evaluate:"))))
 
-(defvar lazy-lock-mode nil)
-(defvar lazy-lock-buffers nil)			; for deferral
-(defvar lazy-lock-timers (cons nil nil))	; for deferral and stealth
+(defvar lazy-lock-mode nil)			; Whether we are turned on.
+(defvar lazy-lock-buffers nil)			; For deferral.
+(defvar lazy-lock-timers (cons nil nil))	; For deferral and stealth.
 
 ;; User Variables:
 
-(defvar lazy-lock-minimum-size (* 25 1024)
+(defgroup lazy-lock nil
+  "Font Lock support mode to fontify lazily."
+  :link '(custom-manual "(emacs)Support Modes")
+  :group 'font-lock)
+
+(defcustom lazy-lock-minimum-size (* 25 1024)
   "*Minimum size of a buffer for demand-driven fontification.
 On-demand fontification occurs if the buffer size is greater than this value.
 If nil, means demand-driven fontification is never performed.
@@ -322,9 +345,14 @@
 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.
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "None" nil)
+		(integer :tag "Size")
+		(repeat (cons (symbol :tag "Major Mode")
+			      (integer :tag "Size"))))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-defer-on-the-fly t
+(defcustom lazy-lock-defer-on-the-fly t
   "*If non-nil, means fontification after a change should be deferred.
 If nil, means on-the-fly fontification is performed.  This means when changes
 occur in the buffer, those areas are immediately fontified.
@@ -335,9 +363,13 @@
 means that on-the-fly fontification is deferred for buffers in C and C++ modes
 only, and deferral does not occur otherwise.
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "Never" nil)
+		(const :tag "Always" t)
+		(repeat (symbol :tag "Major Mode")))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-defer-on-scrolling nil
+(defcustom lazy-lock-defer-on-scrolling nil
   "*If non-nil, means fontification after a scroll should be deferred.
 If nil, means demand-driven fontification is performed.  This means when
 scrolling into unfontified areas of the buffer, those areas are immediately
@@ -356,9 +388,13 @@
 become faster.  (But, since contextual changes continually occur, such a value
 makes little sense if `lazy-lock-defer-contextually' is non-nil.)
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "Never" nil)
+		(const :tag "Always" t)
+		(const :tag "Eventually" eventually))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-defer-contextually 'syntax-driven
+(defcustom lazy-lock-defer-contextually 'syntax-driven
   "*If non-nil, means deferred fontification should be syntactically true.
 If nil, means deferred fontification occurs only on those lines modified.  This
 means where modification on a line causes syntactic change on subsequent lines,
@@ -370,9 +406,13 @@
 fontification occurs only if syntactic fontification is performed using the
 buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil.
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "Never" nil)
+		(const :tag "Always" t)
+		(const :tag "Syntax driven" syntax-driven))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-defer-time
+(defcustom lazy-lock-defer-time
   (if (featurep 'lisp-float-type) (/ (float 1) (float 3)) 1)
   "*Time in seconds to delay before beginning deferred fontification.
 Deferred fontification occurs if there is no input within this time.
@@ -380,23 +420,32 @@
 variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and
 `lazy-lock-defer-contextually'.
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "Never" nil)
+		(number :tag "Seconds"))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-stealth-time 30
+(defcustom lazy-lock-stealth-time 30
   "*Time in seconds to delay before beginning stealth fontification.
 Stealth fontification occurs if there is no input within this time.
 If nil, means stealth fontification is never performed.
 
-The value of this variable is used when Lazy Lock mode is turned on.")
+The value of this variable is used when Lazy Lock mode is turned on."
+  :type '(radio (const :tag "Never" nil)
+		(number :tag "Seconds"))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250)
+(defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250)
   "*Maximum size of a chunk of stealth fontification.
 Each iteration of stealth fontification can fontify this number of lines.
 To speed up input response during stealth fontification, at the cost of stealth
-taking longer to fontify, you could reduce the value of this variable.")
+taking longer to fontify, you could reduce the value of this variable."
+  :type '(integer :tag "Lines")
+  :group 'lazy-lock)
 
-(defvar lazy-lock-stealth-load
-  (when (condition-case nil (load-average) (error)) 200)
+(defcustom lazy-lock-stealth-load
+  (when (condition-case nil (load-average) (error))
+    200)
   "*Load in percentage above which stealth fontification is suspended.
 Stealth fontification pauses when the system short-term load average (as
 returned by the function `load-average' if supported) goes above this level,
@@ -404,9 +453,12 @@
 If nil, means stealth fontification is never suspended.
 To reduce machine load during stealth fontification, at the cost of stealth
 taking longer to fontify, you could reduce the value of this variable.
-See also `lazy-lock-stealth-nice'.")
+See also `lazy-lock-stealth-nice'."
+  :type '(radio (const :tag "Never" nil)
+		(integer :tag "Load"))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-stealth-nice
+(defcustom lazy-lock-stealth-nice
   (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1)
   "*Time in seconds to pause between chunks of stealth fontification.
 Each iteration of stealth fontification is separated by this amount of time,
@@ -414,12 +466,17 @@
 If nil, means stealth fontification is never paused.
 To reduce machine load during stealth fontification, at the cost of stealth
 taking longer to fontify, you could increase the value of this variable.
-See also `lazy-lock-stealth-load'.")
+See also `lazy-lock-stealth-load'."
+  :type '(radio (const :tag "Never" nil)
+		(number :tag "Seconds"))
+  :group 'lazy-lock)
 
-(defvar lazy-lock-stealth-verbose
+(defcustom lazy-lock-stealth-verbose
   (when (featurep 'lisp-float-type)
     (and font-lock-verbose (not lazy-lock-defer-contextually)))
-  "*If non-nil, means stealth fontification should show status messages.")
+  "*If non-nil, means stealth fontification should show status messages."
+  :type 'boolean
+  :group 'lazy-lock)
 
 ;; User Functions:
 
@@ -904,8 +961,10 @@
   (with-current-buffer (window-buffer window)
     (lazy-lock-fontify-region
      (save-excursion
+       (goto-char (window-point window))
        (vertical-motion (- (window-height window)) window) (point))
      (save-excursion
+       (goto-char (window-point window))
        (vertical-motion (window-height window) window) (point)))))
 
 (defun lazy-lock-unfontified-p ()