aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/lazy-lock.el103
1 files changed, 64 insertions, 39 deletions
diff --git a/lisp/lazy-lock.el b/lisp/lazy-lock.el
index e195fe95434..e2a48fbe3cd 100644
--- a/lisp/lazy-lock.el
+++ b/lisp/lazy-lock.el
@@ -1,10 +1,10 @@
1;;; lazy-lock.el --- Lazy demand-driven fontification for fast Font Lock mode. 1;;; lazy-lock.el --- Lazy demand-driven fontification for fast Font Lock mode.
2 2
3;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Simon Marshall <simon@gnu.org> 5;; Author: Simon Marshall <simon@gnu.org>
6;; Keywords: faces files 6;; Keywords: faces files
7;; Version: 2.10 7;; Version: 2.11
8 8
9;;; This file is part of GNU Emacs. 9;;; This file is part of GNU Emacs.
10 10
@@ -257,10 +257,12 @@
257;; - Made `lazy-lock-fontify-after-idle' wrap `minibuffer-auto-raise' 257;; - Made `lazy-lock-fontify-after-idle' wrap `minibuffer-auto-raise'
258;; - Made `lazy-lock-fontify-after-defer' paranoid about deferred buffers 258;; - Made `lazy-lock-fontify-after-defer' paranoid about deferred buffers
259;; 2.09--2.10: 259;; 2.09--2.10:
260;; - Use `window-end' UPDATE arg for Emacs 20.3 and later. 260;; - Use `window-end' UPDATE arg for Emacs 20.4 and later.
261;; - Made deferral `widen' before unfontifying (Dan Nicolaescu report) 261;; - Made deferral `widen' before unfontifying (Dan Nicolaescu report)
262;; - Use `lazy-lock-fontify-after-visage' for hideshow.el (Dan Nicolaescu hint) 262;; - Use `lazy-lock-fontify-after-visage' for hideshow.el (Dan Nicolaescu hint)
263;; - Use `other' widget where possible (Andreas Schwab fix) 263;; - Use `other' widget where possible (Andreas Schwab fix)
264;; 2.10--2.11:
265;; - Used `with-temp-message' where possible to make messages temporary.
264 266
265;;; Code: 267;;; Code:
266 268
@@ -309,6 +311,14 @@ The value returned is the value of the last form in BODY."
309 (put 'with-current-buffer 'lisp-indent-function 1) 311 (put 'with-current-buffer 'lisp-indent-function 1)
310 ;; 312 ;;
311 ;; We use this for compatibility with a future Emacs. 313 ;; We use this for compatibility with a future Emacs.
314 (or (fboundp 'with-temp-message)
315 (defmacro with-temp-message (message &rest body)
316 (` (let ((current-message (current-message)))
317 (unwind-protect
318 (progn (message (, message)) (,@ body))
319 (message current-message))))))
320 ;;
321 ;; We use this for compatibility with a future Emacs.
312 (or (fboundp 'defcustom) 322 (or (fboundp 'defcustom)
313 (defmacro defcustom (symbol value doc &rest args) 323 (defmacro defcustom (symbol value doc &rest args)
314 (` (defvar (, symbol) (, value) (, doc)))))) 324 (` (defvar (, symbol) (, value) (, doc))))))
@@ -317,7 +327,7 @@ The value returned is the value of the last form in BODY."
317; "Submit via mail a bug report on lazy-lock.el." 327; "Submit via mail a bug report on lazy-lock.el."
318; (interactive) 328; (interactive)
319; (let ((reporter-prompt-for-summary-p t)) 329; (let ((reporter-prompt-for-summary-p t))
320; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.10" 330; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.11"
321; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly 331; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly
322; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually 332; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually
323; lazy-lock-defer-time lazy-lock-stealth-time 333; lazy-lock-defer-time lazy-lock-stealth-time
@@ -338,7 +348,7 @@ The value returned is the value of the last form in BODY."
338 348
339;; User Variables: 349;; User Variables:
340 350
341(defcustom lazy-lock-minimum-size (* 25 1024) 351(defcustom lazy-lock-minimum-size 25600
342 "*Minimum size of a buffer for demand-driven fontification. 352 "*Minimum size of a buffer for demand-driven fontification.
343On-demand fontification occurs if the buffer size is greater than this value. 353On-demand fontification occurs if the buffer size is greater than this value.
344If nil, means demand-driven fontification is never performed. 354If nil, means demand-driven fontification is never performed.
@@ -669,13 +679,14 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
669 (let ((verbose (if (numberp font-lock-verbose) 679 (let ((verbose (if (numberp font-lock-verbose)
670 (> (buffer-size) font-lock-verbose) 680 (> (buffer-size) font-lock-verbose)
671 font-lock-verbose))) 681 font-lock-verbose)))
672 (if verbose (message "Fontifying %s..." (buffer-name))) 682 (with-temp-message
673 ;; Make sure we fontify etc. in the whole buffer. 683 (if verbose
674 (save-restriction 684 (format "Fontifying %s..." (buffer-name))
675 (widen) 685 (current-message))
676 (lazy-lock-fontify-region (point-min) (point-max))) 686 ;; Make sure we fontify etc. in the whole buffer.
677 (if verbose (message "Fontifying %s...%s" (buffer-name) 687 (save-restriction
678 (if (lazy-lock-unfontified-p) "quit" "done"))))) 688 (widen)
689 (lazy-lock-fontify-region (point-min) (point-max))))))
679 (add-hook 'after-change-functions 'font-lock-after-change-function nil t)) 690 (add-hook 'after-change-functions 'font-lock-after-change-function nil t))
680 ;; 691 ;;
681 ;; Remove the text properties. 692 ;; Remove the text properties.
@@ -863,27 +874,29 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
863 (if (not (and lazy-lock-mode (lazy-lock-unfontified-p))) 874 (if (not (and lazy-lock-mode (lazy-lock-unfontified-p)))
864 (setq continue (not (input-pending-p))) 875 (setq continue (not (input-pending-p)))
865 ;; Fontify regions in this buffer while there is no input. 876 ;; Fontify regions in this buffer while there is no input.
866 (do-while (and (lazy-lock-unfontified-p) continue) 877 (with-temp-message
867 (if (and lazy-lock-stealth-load 878 (if lazy-lock-stealth-verbose
868 (> (car (load-average)) lazy-lock-stealth-load)) 879 "Fontifying stealthily..."
869 ;; Wait a while before continuing with the loop. 880 (current-message))
870 (progn 881 (do-while (and (lazy-lock-unfontified-p) continue)
871 (when message 882 (if (and lazy-lock-stealth-load
872 (message "Fontifying stealthily...suspended") 883 (> (car (load-average)) lazy-lock-stealth-load))
873 (setq message nil)) 884 ;; Wait a while before continuing with the loop.
874 (setq continue (sit-for (or lazy-lock-stealth-time 30)))) 885 (progn
875 ;; Fontify a chunk. 886 (when message
876 (when lazy-lock-stealth-verbose 887 (message "Fontifying stealthily...suspended")
877 (if message 888 (setq message nil))
878 (message "Fontifying stealthily... %2d%% of %s" 889 (setq continue (sit-for (or lazy-lock-stealth-time 30))))
879 (lazy-lock-percent-fontified) (buffer-name)) 890 ;; Fontify a chunk.
880 (message "Fontifying stealthily...") 891 (when lazy-lock-stealth-verbose
881 (setq message t))) 892 (if message
882 (lazy-lock-fontify-chunk) 893 (message "Fontifying stealthily... %2d%% of %s"
883 (setq continue (sit-for (or lazy-lock-stealth-nice 0)))))) 894 (lazy-lock-percent-fontified) (buffer-name))
884 (setq buffers (cdr buffers)))) 895 (message "Fontifying stealthily...")
885 (when message 896 (setq message t)))
886 (message "Fontifying stealthily...%s" (if continue "done" "quit")))))) 897 (lazy-lock-fontify-chunk)
898 (setq continue (sit-for (or lazy-lock-stealth-nice 0)))))))
899 (setq buffers (cdr buffers)))))))
887 900
888;; 4. Special circumstances. 901;; 4. Special circumstances.
889 902
@@ -1049,7 +1062,7 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1049 1062
1050(when (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version))) 1063(when (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version)))
1051 nil 1064 nil
1052 (or (and (= emacs-major-version 20) (< emacs-minor-version 3)) 1065 (or (and (= emacs-major-version 20) (< emacs-minor-version 4))
1053 (= emacs-major-version 19))) 1066 (= emacs-major-version 19)))
1054 ;; 1067 ;;
1055 ;; We use `vertical-motion' rather than `window-end' UPDATE arg. 1068 ;; We use `vertical-motion' rather than `window-end' UPDATE arg.
@@ -1080,8 +1093,10 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1080 (princ "The value of the variable `lazy-lock-defer-time' was\n ") 1093 (princ "The value of the variable `lazy-lock-defer-time' was\n ")
1081 (princ lazy-lock-defer-time) 1094 (princ lazy-lock-defer-time)
1082 (princ "\n") 1095 (princ "\n")
1083 (princ "This variable cannot now be a list of modes and time, ") 1096 (princ "This variable cannot now be a list of modes and time,\n")
1084 (princ "so instead use the forms:\n") 1097 (princ "so instead use ")
1098 (princ (substitute-command-keys "\\[customize-option]"))
1099 (princ " to modify the variables, or put the forms:\n")
1085 (princ " (setq lazy-lock-defer-time ") 1100 (princ " (setq lazy-lock-defer-time ")
1086 (princ (cdr lazy-lock-defer-time)) 1101 (princ (cdr lazy-lock-defer-time))
1087 (princ ")\n") 1102 (princ ")\n")
@@ -1090,7 +1105,9 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1090 (princ ")\n") 1105 (princ ")\n")
1091 (princ "in your ~/.emacs. ") 1106 (princ "in your ~/.emacs. ")
1092 (princ "The above forms have been evaluated for this editor session,\n") 1107 (princ "The above forms have been evaluated for this editor session,\n")
1093 (princ "but you should change your ~/.emacs now.")) 1108 (princ "but you should use ")
1109 (princ (substitute-command-keys "\\[customize-option]"))
1110 (princ " or change your ~/.emacs now."))
1094 (setq lazy-lock-defer-on-the-fly (car lazy-lock-defer-time) 1111 (setq lazy-lock-defer-on-the-fly (car lazy-lock-defer-time)
1095 lazy-lock-defer-time (cdr lazy-lock-defer-time))) 1112 lazy-lock-defer-time (cdr lazy-lock-defer-time)))
1096 1113
@@ -1106,7 +1123,9 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1106 (princ "'")) 1123 (princ "'"))
1107 (princ ".\n") 1124 (princ ".\n")
1108 (princ "This variable is now called `lazy-lock-defer-on-scrolling',\n") 1125 (princ "This variable is now called `lazy-lock-defer-on-scrolling',\n")
1109 (princ "so instead use the form:\n") 1126 (princ "so instead use ")
1127 (princ (substitute-command-keys "\\[customize-option]"))
1128 (princ " to modify the variable, or put the form:\n")
1110 (princ " (setq lazy-lock-defer-on-scrolling ") 1129 (princ " (setq lazy-lock-defer-on-scrolling ")
1111 (unless (memq lazy-lock-defer-driven '(nil t)) 1130 (unless (memq lazy-lock-defer-driven '(nil t))
1112 (princ "'")) 1131 (princ "'"))
@@ -1114,7 +1133,9 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1114 (princ ")\n") 1133 (princ ")\n")
1115 (princ "in your ~/.emacs. ") 1134 (princ "in your ~/.emacs. ")
1116 (princ "The above form has been evaluated for this editor session,\n") 1135 (princ "The above form has been evaluated for this editor session,\n")
1117 (princ "but you should change your ~/.emacs now.")) 1136 (princ "but you should use ")
1137 (princ (substitute-command-keys "\\[customize-option]"))
1138 (princ " or change your ~/.emacs now."))
1118 (setq lazy-lock-defer-on-scrolling lazy-lock-defer-driven)) 1139 (setq lazy-lock-defer-on-scrolling lazy-lock-defer-driven))
1119 1140
1120;; Possibly absent. 1141;; Possibly absent.
@@ -1147,6 +1168,10 @@ verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
1147 (push window windows)))) 1168 (push window windows))))
1148 minibuf frame) 1169 minibuf frame)
1149 windows))) 1170 windows)))
1171
1172(unless (fboundp 'current-message)
1173 (defun current-message ()
1174 ""))
1150 1175
1151;; Install ourselves: 1176;; Install ourselves:
1152 1177