diff options
| author | Simon Marshall | 1997-04-28 09:41:02 +0000 |
|---|---|---|
| committer | Simon Marshall | 1997-04-28 09:41:02 +0000 |
| commit | 54d893e33b3d76bb1b222a3d363d4b6ecc7a12cd (patch) | |
| tree | e1e7ce846538461167dda1b53a6b8a0b996848db | |
| parent | fc8d560107be6db7da8ad2e39bcd12bec21d3db0 (diff) | |
| download | emacs-54d893e33b3d76bb1b222a3d363d4b6ecc7a12cd.tar.gz emacs-54d893e33b3d76bb1b222a3d363d4b6ecc7a12cd.zip | |
Version 2.08.01 from author; defgroup happens in font-lock.el; don't prevent from compiling on emacs 19.34 etc.
| -rw-r--r-- | lisp/lazy-lock.el | 128 |
1 files changed, 100 insertions, 28 deletions
diff --git a/lisp/lazy-lock.el b/lisp/lazy-lock.el index 084d797d35a..326683af003 100644 --- a/lisp/lazy-lock.el +++ b/lisp/lazy-lock.el | |||
| @@ -4,7 +4,7 @@ | |||
| 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: 2.08 | 7 | ;; Version: 2.08.01 |
| 8 | 8 | ||
| 9 | ;;; This file is part of GNU Emacs. | 9 | ;;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| @@ -193,6 +193,70 @@ | |||
| 193 | ;; Currently XEmacs does not have the features to support this version of | 193 | ;; Currently XEmacs does not have the features to support this version of |
| 194 | ;; lazy-lock.el. Maybe it will one day. | 194 | ;; lazy-lock.el. Maybe it will one day. |
| 195 | 195 | ||
| 196 | ;; History: | ||
| 197 | ;; | ||
| 198 | ;; 1.15--2.00: | ||
| 199 | ;; - Rewrite for Emacs 19.30 and the features rms added to support lazy-lock.el | ||
| 200 | ;; so that it could work correctly and efficiently. | ||
| 201 | ;; - Many thanks to those who reported bugs, fixed bugs, made suggestions or | ||
| 202 | ;; otherwise contributed in the version 1 cycle; Jari Aalto, Kevin Broadey, | ||
| 203 | ;; Ulrik Dickow, Bill Dubuque, Bob Glickstein, Boris Goldowsky, | ||
| 204 | ;; Jonas Jarnestrom, David Karr, Michael Kifer, Erik Naggum, Rick Sladkey, | ||
| 205 | ;; Jim Thompson, Ben Wing, Ilya Zakharevich, and Richard Stallman. | ||
| 206 | ;; 2.00--2.01: | ||
| 207 | ;; - Made `lazy-lock-fontify-after-command' always `sit-for' and so redisplay | ||
| 208 | ;; - Use `buffer-name' not `buffer-live-p' (Bill Dubuque hint) | ||
| 209 | ;; - Made `lazy-lock-install' do `add-to-list' not `setq' of `current-buffer' | ||
| 210 | ;; - Made `lazy-lock-fontify-after-install' loop over buffer list | ||
| 211 | ;; - Made `lazy-lock-arrange-before-change' to arrange `window-end' triggering | ||
| 212 | ;; - Made `lazy-lock-let-buffer-state' wrap both `befter-change-functions' | ||
| 213 | ;; - Made `lazy-lock-fontify-region' do `condition-case' (Hyman Rosen report) | ||
| 214 | ;; 2.01--2.02: | ||
| 215 | ;; - Use `buffer-live-p' as `buffer-name' can barf (Richard Stanton report) | ||
| 216 | ;; - Made `lazy-lock-install' set `font-lock-fontified' (Kevin Davidson report) | ||
| 217 | ;; - Made `lazy-lock-install' add hooks only if needed | ||
| 218 | ;; - Made `lazy-lock-unstall' add `font-lock-after-change-function' if needed | ||
| 219 | ;; 2.02--2.03: | ||
| 220 | ;; - Made `lazy-lock-fontify-region' do `condition-case' for `quit' too | ||
| 221 | ;; - Made `lazy-lock-mode' respect the value of `font-lock-inhibit-thing-lock' | ||
| 222 | ;; - Added `lazy-lock-after-unfontify-buffer' | ||
| 223 | ;; - Removed `lazy-lock-fontify-after-install' hack | ||
| 224 | ;; - Made `lazy-lock-fontify-after-scroll' not `set-buffer' to `window-buffer' | ||
| 225 | ;; - Made `lazy-lock-fontify-after-trigger' not `set-buffer' to `window-buffer' | ||
| 226 | ;; - Made `lazy-lock-fontify-after-idle' be interruptible (Scott Burson hint) | ||
| 227 | ;; 2.03--2.04: | ||
| 228 | ;; - Rewrite for Emacs 19.31 idle timers | ||
| 229 | ;; - Renamed `buffer-windows' to `get-buffer-window-list' | ||
| 230 | ;; - Removed `buffer-live-p' | ||
| 231 | ;; - Made `lazy-lock-defer-after-change' always save `current-buffer' | ||
| 232 | ;; - Made `lazy-lock-fontify-after-defer' just process buffers | ||
| 233 | ;; - Made `lazy-lock-install-hooks' add hooks correctly (Kevin Broadey report) | ||
| 234 | ;; - Made `lazy-lock-install' cope if `lazy-lock-defer-time' is a list | ||
| 235 | ;; 2.04--2.05: | ||
| 236 | ;; - Rewrite for Common Lisp macros | ||
| 237 | ;; - Added `do-while' macro | ||
| 238 | ;; - Renamed `lazy-lock-let-buffer-state' macro to `save-buffer-state' | ||
| 239 | ;; - Returned `lazy-lock-fontify-after-install' hack (Darren Hall hint) | ||
| 240 | ;; - Added `lazy-lock-defer-on-scrolling' functionality (Scott Byer hint) | ||
| 241 | ;; - Made `lazy-lock-mode' wrap `font-lock-support-mode' | ||
| 242 | ;; 2.05--2.06: | ||
| 243 | ;; - Made `lazy-lock-fontify-after-defer' swap correctly (Scott Byer report) | ||
| 244 | ;; 2.06--2.07: | ||
| 245 | ;; - Added `lazy-lock-stealth-load' functionality (Rob Hooft hint) | ||
| 246 | ;; - Made `lazy-lock-unstall' call `lazy-lock-fontify-region' if needed | ||
| 247 | ;; - Made `lazy-lock-mode' call `lazy-lock-unstall' only if needed | ||
| 248 | ;; - Made `lazy-lock-defer-after-scroll' do `set-window-redisplay-end-trigger' | ||
| 249 | ;; - Added `lazy-lock-defer-contextually' functionality | ||
| 250 | ;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time' | ||
| 251 | ;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling' | ||
| 252 | ;; - Removed `lazy-lock-submit-bug-report' and bade farewell | ||
| 253 | ;; 2.07--2.08: | ||
| 254 | ;; - Made `lazy-lock-fontify-conservatively' fontify around `window-point' | ||
| 255 | ;; - Made `save-buffer-state' wrap `inhibit-point-motion-hooks' | ||
| 256 | ;; - Added Custom support | ||
| 257 | ;; 2.08--2.09: | ||
| 258 | ;; - Removed `byte-*' variables from `eval-when-compile' (Erik Naggum hint) | ||
| 259 | |||
| 196 | ;;; Code: | 260 | ;;; Code: |
| 197 | 261 | ||
| 198 | (require 'font-lock) | 262 | (require 'font-lock) |
| @@ -208,34 +272,47 @@ | |||
| 208 | ;; We don't do this at the top-level as idle timers are not necessarily used. | 272 | ;; We don't do this at the top-level as idle timers are not necessarily used. |
| 209 | (require 'timer) | 273 | (require 'timer) |
| 210 | ;; We don't do this at the top-level as we only use non-autoloaded macros. | 274 | ;; We don't do this at the top-level as we only use non-autoloaded macros. |
| 211 | (require 'cl)) | 275 | (require 'cl) |
| 212 | 276 | ;; | |
| 213 | ;; We use this to preserve or protect things when modifying text properties. | 277 | ;; We use this to preserve or protect things when modifying text properties. |
| 214 | (defmacro save-buffer-state (varlist &rest body) | 278 | (defmacro save-buffer-state (varlist &rest body) |
| 215 | "Bind variables according to VARLIST and eval BODY restoring buffer state." | 279 | "Bind variables according to VARLIST and eval BODY restoring buffer state." |
| 216 | (` (let* ((,@ (append varlist | 280 | (` (let* ((,@ (append varlist |
| 217 | '((modified (buffer-modified-p)) (buffer-undo-list t) | 281 | '((modified (buffer-modified-p)) (buffer-undo-list t) |
| 218 | (inhibit-read-only t) (inhibit-point-motion-hooks t) | 282 | (inhibit-read-only t) (inhibit-point-motion-hooks t) |
| 219 | before-change-functions after-change-functions | 283 | before-change-functions after-change-functions |
| 220 | deactivate-mark buffer-file-name buffer-file-truename)))) | 284 | deactivate-mark buffer-file-name buffer-file-truename)))) |
| 221 | (,@ body) | 285 | (,@ body) |
| 222 | (when (and (not modified) (buffer-modified-p)) | 286 | (when (and (not modified) (buffer-modified-p)) |
| 223 | (set-buffer-modified-p nil))))) | 287 | (set-buffer-modified-p nil))))) |
| 224 | (put 'save-buffer-state 'lisp-indent-function 1) | 288 | (put 'save-buffer-state 'lisp-indent-function 1) |
| 225 | 289 | ;; | |
| 226 | ;; We use this for clarity and speed. Naughty but nice. | 290 | ;; We use this for clarity and speed. Naughty but nice. |
| 227 | (defmacro do-while (test &rest body) | 291 | (defmacro do-while (test &rest body) |
| 228 | "(do-while TEST BODY...): eval BODY... and repeat if TEST yields non-nil. | 292 | "(do-while TEST BODY...): eval BODY... and repeat if TEST yields non-nil. |
| 229 | The order of execution is thus BODY, TEST, BODY, TEST and so on | 293 | The order of execution is thus BODY, TEST, BODY, TEST and so on |
| 230 | until TEST returns nil." | 294 | until TEST returns nil." |
| 231 | (` (while (progn (,@ body) (, test))))) | 295 | (` (while (progn (,@ body) (, test))))) |
| 232 | (put 'do-while 'lisp-indent-function (get 'while 'lisp-indent-function)) | 296 | (put 'do-while 'lisp-indent-function (get 'while 'lisp-indent-function)) |
| 297 | ;; | ||
| 298 | ;; We use this for clarity and speed. Borrowed from a future Emacs. | ||
| 299 | (or (fboundp 'with-current-buffer) | ||
| 300 | (defmacro with-current-buffer (buffer &rest body) | ||
| 301 | "Execute the forms in BODY with BUFFER as the current buffer. | ||
| 302 | The value returned is the value of the last form in BODY." | ||
| 303 | (` (save-excursion (set-buffer (, buffer)) (,@ body))))) | ||
| 304 | (put 'with-current-buffer 'lisp-indent-function 1) | ||
| 305 | ;; | ||
| 306 | ;; We use this for compatibility with a future Emacs. | ||
| 307 | (or (fboundp 'defcustom) | ||
| 308 | (defmacro defcustom (symbol value doc &rest args) | ||
| 309 | (` (defvar (, symbol) (, value) (, doc)))))) | ||
| 233 | 310 | ||
| 234 | ;(defun lazy-lock-submit-bug-report () | 311 | ;(defun lazy-lock-submit-bug-report () |
| 235 | ; "Submit via mail a bug report on lazy-lock.el." | 312 | ; "Submit via mail a bug report on lazy-lock.el." |
| 236 | ; (interactive) | 313 | ; (interactive) |
| 237 | ; (let ((reporter-prompt-for-summary-p t)) | 314 | ; (let ((reporter-prompt-for-summary-p t)) |
| 238 | ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.08" | 315 | ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.08.01" |
| 239 | ; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly | 316 | ; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly |
| 240 | ; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually | 317 | ; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually |
| 241 | ; lazy-lock-defer-time lazy-lock-stealth-time | 318 | ; lazy-lock-defer-time lazy-lock-stealth-time |
| @@ -256,11 +333,6 @@ until TEST returns nil." | |||
| 256 | 333 | ||
| 257 | ;; User Variables: | 334 | ;; User Variables: |
| 258 | 335 | ||
| 259 | (defgroup lazy-lock nil | ||
| 260 | "Font Lock support mode to fontify lazily." | ||
| 261 | :link '(custom-manual "(emacs)Support Modes") | ||
| 262 | :group 'font-lock) | ||
| 263 | |||
| 264 | (defcustom lazy-lock-minimum-size (* 25 1024) | 336 | (defcustom lazy-lock-minimum-size (* 25 1024) |
| 265 | "*Minimum size of a buffer for demand-driven fontification. | 337 | "*Minimum size of a buffer for demand-driven fontification. |
| 266 | On-demand fontification occurs if the buffer size is greater than this value. | 338 | On-demand fontification occurs if the buffer size is greater than this value. |
| @@ -392,7 +464,7 @@ See also `lazy-lock-stealth-nice'." | |||
| 392 | :type (if (condition-case nil (load-average) (error)) | 464 | :type (if (condition-case nil (load-average) (error)) |
| 393 | '(choice (const :tag "never" nil) | 465 | '(choice (const :tag "never" nil) |
| 394 | (integer :tag "load")) | 466 | (integer :tag "load")) |
| 395 | '(const :tag "never" nil)) | 467 | '(const :format "%t: unsupported\n" nil)) |
| 396 | :group 'lazy-lock) | 468 | :group 'lazy-lock) |
| 397 | 469 | ||
| 398 | (defcustom lazy-lock-stealth-nice | 470 | (defcustom lazy-lock-stealth-nice |