Mercurial > emacs
comparison lisp/lazy-lock.el @ 17498:5ea11c278a57
Customise.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Thu, 17 Apr 1997 07:35:54 +0000 |
parents | f4429e6fe33c |
children | fd87760f20cd |
comparison
equal
deleted
inserted
replaced
17497:3ee027d263c6 | 17498:5ea11c278a57 |
---|---|
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 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
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.07 | 7 ;; Version: 2.08 |
8 | 8 |
9 ;;; This file is part of GNU Emacs. | 9 ;;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
12 ;; it under the terms of the GNU General Public License as published by | 12 ;; it under the terms of the GNU General Public License as published by |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02111-1307, USA. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; Purpose: | |
29 ;; | |
28 ;; Lazy Lock mode is a Font Lock support mode. | 30 ;; Lazy Lock mode is a Font Lock support mode. |
29 ;; It makes visiting buffers in Font Lock mode faster by making fontification | 31 ;; It makes visiting buffers in Font Lock mode faster by making fontification |
30 ;; be demand-driven, deferred and stealthy, so that fontification only occurs | 32 ;; be demand-driven, deferred and stealthy, so that fontification only occurs |
31 ;; when, and where, necessary. | 33 ;; when, and where, necessary. |
32 ;; | 34 ;; |
109 ;; become visible without changing `window-start'. Arguably, these events are | 111 ;; become visible without changing `window-start'. Arguably, these events are |
110 ;; not scrolling events, but fontification must occur for lazy-lock.el to work. | 112 ;; not scrolling events, but fontification must occur for lazy-lock.el to work. |
111 ;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions' | 113 ;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions' |
112 ;; were added for these circumstances. | 114 ;; were added for these circumstances. |
113 ;; | 115 ;; |
114 ;; Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented | 116 ;; (Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented |
115 ;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14. | 117 ;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14. |
116 ;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather | 118 ;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather |
117 ;; than `post-command-hook'. Whereas functions on `post-command-hook' are | 119 ;; than `post-command-hook'. Whereas functions on `post-command-hook' are |
118 ;; called almost as often as possible, functions on `pre-idle-hook' really are | 120 ;; called almost as often as possible, functions on `pre-idle-hook' really are |
119 ;; called as often as possible, even when the mouse moves and, on some systems, | 121 ;; called as often as possible, even when the mouse moves and, on some systems, |
126 ;; the result is faster and smaller, less intrusive and more targeted, code. | 128 ;; the result is faster and smaller, less intrusive and more targeted, code. |
127 ;; Since `pre-idle-hook' is pretty much like `post-command-hook', there is no | 129 ;; Since `pre-idle-hook' is pretty much like `post-command-hook', there is no |
128 ;; point in making this version of lazy-lock.el work with it. Anyway, that's | 130 ;; point in making this version of lazy-lock.el work with it. Anyway, that's |
129 ;; Lit 30 of my humble opinion. | 131 ;; Lit 30 of my humble opinion. |
130 ;; | 132 ;; |
133 ;; Steve Baur reverted to a non-hacked version 1 lazy-lock.el for XEmacs 19.15 | |
134 ;; and 20.0. Obviously, the above `post-command-hook' problems still apply.) | |
135 ;; | |
131 ;; - Version 1 stealth fontification is also implemented by placing a function | 136 ;; - Version 1 stealth fontification is also implemented by placing a function |
132 ;; on `post-command-hook'. This function waits for a given amount of time, | 137 ;; on `post-command-hook'. This function waits for a given amount of time, |
133 ;; and, if Emacs remains idle, fontifies where necessary. Again, there are a | 138 ;; and, if Emacs remains idle, fontifies where necessary. Again, there are a |
134 ;; number of problems with using `post-command-hook': | 139 ;; number of problems with using `post-command-hook': |
135 ;; | 140 ;; |
146 ;; Timers for Emacs 19.31. Functions can be run independently at given times | 151 ;; Timers for Emacs 19.31. Functions can be run independently at given times |
147 ;; or after given amounts of idle time. Thus, the feature deals with the above | 152 ;; or after given amounts of idle time. Thus, the feature deals with the above |
148 ;; problems (a), (b) and (c). Version 2 deferral and stealth are implemented | 153 ;; problems (a), (b) and (c). Version 2 deferral and stealth are implemented |
149 ;; by functions on Idle Timers. (A function on XEmacs' `pre-idle-hook' is | 154 ;; by functions on Idle Timers. (A function on XEmacs' `pre-idle-hook' is |
150 ;; similar to an Emacs Idle Timer function with a fixed zero second timeout.) | 155 ;; similar to an Emacs Idle Timer function with a fixed zero second timeout.) |
156 | |
157 ;; - Version 1 has the following problems (relative to version 2): | |
158 ;; | |
159 ;; (a) It is slow when it does its job. | |
160 ;; (b) It does not always do its job when it should. | |
161 ;; (c) It slows all interaction (when it doesn't need to do its job). | |
162 ;; (d) It interferes with other package functions on `post-command-hook'. | |
163 ;; (e) It interferes with Emacs things within the read-eval loop. | |
164 ;; | |
165 ;; Ben's hacked-up lazy-lock.el 1.14 almost solved (b) but made (c) worse. | |
166 ;; | |
167 ;; - Version 2 has the following additional features (relative to version 1): | |
168 ;; | |
169 ;; (a) It can defer fontification (both on-the-fly and on-scrolling). | |
170 ;; (b) It can fontify contextually (syntactically true on-the-fly). | |
151 | 171 |
152 ;; Caveats: | 172 ;; Caveats: |
153 ;; | 173 ;; |
154 ;; Lazy Lock mode does not work efficiently with Outline mode. | 174 ;; Lazy Lock mode does not work efficiently with Outline mode. |
155 ;; This is because when in Outline mode, although text may be not visible to | 175 ;; This is because when in Outline mode, although text may be not visible to |
228 ;; - Made `lazy-lock-defer-after-scroll' do `set-window-redisplay-end-trigger' | 248 ;; - Made `lazy-lock-defer-after-scroll' do `set-window-redisplay-end-trigger' |
229 ;; - Added `lazy-lock-defer-contextually' functionality | 249 ;; - Added `lazy-lock-defer-contextually' functionality |
230 ;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time' | 250 ;; - Added `lazy-lock-defer-on-the-fly' from `lazy-lock-defer-time' |
231 ;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling' | 251 ;; - Renamed `lazy-lock-defer-driven' to `lazy-lock-defer-on-scrolling' |
232 ;; - Removed `lazy-lock-submit-bug-report' and bade farewell | 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 ;; - Added Custom support | |
233 | 256 |
234 ;;; Code: | 257 ;;; Code: |
235 | 258 |
236 (require 'font-lock) | 259 (require 'font-lock) |
237 | 260 |
239 (if (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version))) | 262 (if (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version))) |
240 t | 263 t |
241 (and (= emacs-major-version 19) (< emacs-minor-version 30))) | 264 (and (= emacs-major-version 19) (< emacs-minor-version 30))) |
242 (error "`lazy-lock' was written for Emacs 19.30 or later")) | 265 (error "`lazy-lock' was written for Emacs 19.30 or later")) |
243 | 266 |
244 ;; Flush out those lusers who didn't read all of the Commentary. | |
245 (if (or (memq 'turn-on-defer-lock font-lock-mode-hook) | |
246 (memq 'defer-lock-mode font-lock-mode-hook)) | |
247 (error "`lazy-lock' was written for use without `defer-lock'")) | |
248 | |
249 (eval-when-compile | 267 (eval-when-compile |
250 ;; | 268 ;; |
251 ;; We don't do this at the top-level as idle timers are not necessarily used. | 269 ;; We don't do this at the top-level as idle timers are not necessarily used. |
252 (require 'timer) | 270 (require 'timer) |
253 ;; We don't do this at the top-level as we only use non-autoloaded macros. | 271 ;; We don't do this at the top-level as we only use non-autoloaded macros. |
260 ;; | 278 ;; |
261 ;; We use this to preserve or protect things when modifying text properties. | 279 ;; We use this to preserve or protect things when modifying text properties. |
262 (defmacro save-buffer-state (varlist &rest body) | 280 (defmacro save-buffer-state (varlist &rest body) |
263 "Bind variables according to VARLIST and eval BODY restoring buffer state." | 281 "Bind variables according to VARLIST and eval BODY restoring buffer state." |
264 (` (let* ((,@ (append varlist | 282 (` (let* ((,@ (append varlist |
265 '((modified (buffer-modified-p)) | 283 '((modified (buffer-modified-p)) (buffer-undo-list t) |
266 (inhibit-read-only t) (buffer-undo-list t) | 284 (inhibit-read-only t) (inhibit-point-motion-hooks t) |
267 before-change-functions after-change-functions | 285 before-change-functions after-change-functions |
268 deactivate-mark buffer-file-name buffer-file-truename)))) | 286 deactivate-mark buffer-file-name buffer-file-truename)))) |
269 (,@ body) | 287 (,@ body) |
270 (when (and (not modified) (buffer-modified-p)) | 288 (when (and (not modified) (buffer-modified-p)) |
271 (set-buffer-modified-p nil))))) | 289 (set-buffer-modified-p nil))))) |
289 | 307 |
290 ;(defun lazy-lock-submit-bug-report () | 308 ;(defun lazy-lock-submit-bug-report () |
291 ; "Submit via mail a bug report on lazy-lock.el." | 309 ; "Submit via mail a bug report on lazy-lock.el." |
292 ; (interactive) | 310 ; (interactive) |
293 ; (let ((reporter-prompt-for-summary-p t)) | 311 ; (let ((reporter-prompt-for-summary-p t)) |
294 ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.07" | 312 ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.08" |
295 ; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly | 313 ; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly |
296 ; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually | 314 ; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually |
297 ; lazy-lock-defer-time lazy-lock-stealth-time | 315 ; lazy-lock-defer-time lazy-lock-stealth-time |
298 ; lazy-lock-stealth-load lazy-lock-stealth-nice lazy-lock-stealth-lines | 316 ; lazy-lock-stealth-load lazy-lock-stealth-nice lazy-lock-stealth-lines |
299 ; lazy-lock-stealth-verbose) | 317 ; lazy-lock-stealth-verbose) |
304 ;know how to make a clear and unambiguous report. To reproduce the bug: | 322 ;know how to make a clear and unambiguous report. To reproduce the bug: |
305 ; | 323 ; |
306 ;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'. | 324 ;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'. |
307 ;In the `*scratch*' buffer, evaluate:")))) | 325 ;In the `*scratch*' buffer, evaluate:")))) |
308 | 326 |
309 (defvar lazy-lock-mode nil) | 327 (defvar lazy-lock-mode nil) ; Whether we are turned on. |
310 (defvar lazy-lock-buffers nil) ; for deferral | 328 (defvar lazy-lock-buffers nil) ; For deferral. |
311 (defvar lazy-lock-timers (cons nil nil)) ; for deferral and stealth | 329 (defvar lazy-lock-timers (cons nil nil)) ; For deferral and stealth. |
312 | 330 |
313 ;; User Variables: | 331 ;; User Variables: |
314 | 332 |
315 (defvar lazy-lock-minimum-size (* 25 1024) | 333 (defgroup lazy-lock nil |
334 "Font Lock support mode to fontify lazily." | |
335 :link '(custom-manual "(emacs)Support Modes") | |
336 :group 'font-lock) | |
337 | |
338 (defcustom lazy-lock-minimum-size (* 25 1024) | |
316 "*Minimum size of a buffer for demand-driven fontification. | 339 "*Minimum size of a buffer for demand-driven fontification. |
317 On-demand fontification occurs if the buffer size is greater than this value. | 340 On-demand fontification occurs if the buffer size is greater than this value. |
318 If nil, means demand-driven fontification is never performed. | 341 If nil, means demand-driven fontification is never performed. |
319 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), | 342 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), |
320 where MAJOR-MODE is a symbol or t (meaning the default). For example: | 343 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
321 ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) | 344 ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576)) |
322 means that the minimum size is 25K for buffers in C or C++ modes, one megabyte | 345 means that the minimum size is 25K for buffers in C or C++ modes, one megabyte |
323 for buffers in Rmail mode, and size is irrelevant otherwise. | 346 for buffers in Rmail mode, and size is irrelevant otherwise. |
324 | 347 |
325 The value of this variable is used when Lazy Lock mode is turned on.") | 348 The value of this variable is used when Lazy Lock mode is turned on." |
326 | 349 :type '(radio (const :tag "None" nil) |
327 (defvar lazy-lock-defer-on-the-fly t | 350 (integer :tag "Size") |
351 (repeat (cons (symbol :tag "Major Mode") | |
352 (integer :tag "Size")))) | |
353 :group 'lazy-lock) | |
354 | |
355 (defcustom lazy-lock-defer-on-the-fly t | |
328 "*If non-nil, means fontification after a change should be deferred. | 356 "*If non-nil, means fontification after a change should be deferred. |
329 If nil, means on-the-fly fontification is performed. This means when changes | 357 If nil, means on-the-fly fontification is performed. This means when changes |
330 occur in the buffer, those areas are immediately fontified. | 358 occur in the buffer, those areas are immediately fontified. |
331 If a list, it should be a list of `major-mode' symbol names for which deferred | 359 If a list, it should be a list of `major-mode' symbol names for which deferred |
332 fontification should occur. The sense of the list is negated if it begins with | 360 fontification should occur. The sense of the list is negated if it begins with |
333 `not'. For example: | 361 `not'. For example: |
334 (c-mode c++-mode) | 362 (c-mode c++-mode) |
335 means that on-the-fly fontification is deferred for buffers in C and C++ modes | 363 means that on-the-fly fontification is deferred for buffers in C and C++ modes |
336 only, and deferral does not occur otherwise. | 364 only, and deferral does not occur otherwise. |
337 | 365 |
338 The value of this variable is used when Lazy Lock mode is turned on.") | 366 The value of this variable is used when Lazy Lock mode is turned on." |
339 | 367 :type '(radio (const :tag "Never" nil) |
340 (defvar lazy-lock-defer-on-scrolling nil | 368 (const :tag "Always" t) |
369 (repeat (symbol :tag "Major Mode"))) | |
370 :group 'lazy-lock) | |
371 | |
372 (defcustom lazy-lock-defer-on-scrolling nil | |
341 "*If non-nil, means fontification after a scroll should be deferred. | 373 "*If non-nil, means fontification after a scroll should be deferred. |
342 If nil, means demand-driven fontification is performed. This means when | 374 If nil, means demand-driven fontification is performed. This means when |
343 scrolling into unfontified areas of the buffer, those areas are immediately | 375 scrolling into unfontified areas of the buffer, those areas are immediately |
344 fontified. Thus scrolling never presents unfontified areas. However, since | 376 fontified. Thus scrolling never presents unfontified areas. However, since |
345 fontification occurs during scrolling, scrolling may be slow. | 377 fontification occurs during scrolling, scrolling may be slow. |
354 insertions momentarily unfontified. However, since fontification does not | 386 insertions momentarily unfontified. However, since fontification does not |
355 occur during scrolling after the buffer is first fontified, scrolling will | 387 occur during scrolling after the buffer is first fontified, scrolling will |
356 become faster. (But, since contextual changes continually occur, such a value | 388 become faster. (But, since contextual changes continually occur, such a value |
357 makes little sense if `lazy-lock-defer-contextually' is non-nil.) | 389 makes little sense if `lazy-lock-defer-contextually' is non-nil.) |
358 | 390 |
359 The value of this variable is used when Lazy Lock mode is turned on.") | 391 The value of this variable is used when Lazy Lock mode is turned on." |
360 | 392 :type '(radio (const :tag "Never" nil) |
361 (defvar lazy-lock-defer-contextually 'syntax-driven | 393 (const :tag "Always" t) |
394 (const :tag "Eventually" eventually)) | |
395 :group 'lazy-lock) | |
396 | |
397 (defcustom lazy-lock-defer-contextually 'syntax-driven | |
362 "*If non-nil, means deferred fontification should be syntactically true. | 398 "*If non-nil, means deferred fontification should be syntactically true. |
363 If nil, means deferred fontification occurs only on those lines modified. This | 399 If nil, means deferred fontification occurs only on those lines modified. This |
364 means where modification on a line causes syntactic change on subsequent lines, | 400 means where modification on a line causes syntactic change on subsequent lines, |
365 those subsequent lines are not refontified to reflect their new context. | 401 those subsequent lines are not refontified to reflect their new context. |
366 If t, means deferred fontification occurs on those lines modified and all | 402 If t, means deferred fontification occurs on those lines modified and all |
368 their new syntactic context, either immediately or when scrolling into them. | 404 their new syntactic context, either immediately or when scrolling into them. |
369 If any other value, e.g., `syntax-driven', means deferred syntactically true | 405 If any other value, e.g., `syntax-driven', means deferred syntactically true |
370 fontification occurs only if syntactic fontification is performed using the | 406 fontification occurs only if syntactic fontification is performed using the |
371 buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil. | 407 buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil. |
372 | 408 |
373 The value of this variable is used when Lazy Lock mode is turned on.") | 409 The value of this variable is used when Lazy Lock mode is turned on." |
374 | 410 :type '(radio (const :tag "Never" nil) |
375 (defvar lazy-lock-defer-time | 411 (const :tag "Always" t) |
412 (const :tag "Syntax driven" syntax-driven)) | |
413 :group 'lazy-lock) | |
414 | |
415 (defcustom lazy-lock-defer-time | |
376 (if (featurep 'lisp-float-type) (/ (float 1) (float 3)) 1) | 416 (if (featurep 'lisp-float-type) (/ (float 1) (float 3)) 1) |
377 "*Time in seconds to delay before beginning deferred fontification. | 417 "*Time in seconds to delay before beginning deferred fontification. |
378 Deferred fontification occurs if there is no input within this time. | 418 Deferred fontification occurs if there is no input within this time. |
379 If nil, means fontification is never deferred, regardless of the values of the | 419 If nil, means fontification is never deferred, regardless of the values of the |
380 variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and | 420 variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and |
381 `lazy-lock-defer-contextually'. | 421 `lazy-lock-defer-contextually'. |
382 | 422 |
383 The value of this variable is used when Lazy Lock mode is turned on.") | 423 The value of this variable is used when Lazy Lock mode is turned on." |
384 | 424 :type '(radio (const :tag "Never" nil) |
385 (defvar lazy-lock-stealth-time 30 | 425 (number :tag "Seconds")) |
426 :group 'lazy-lock) | |
427 | |
428 (defcustom lazy-lock-stealth-time 30 | |
386 "*Time in seconds to delay before beginning stealth fontification. | 429 "*Time in seconds to delay before beginning stealth fontification. |
387 Stealth fontification occurs if there is no input within this time. | 430 Stealth fontification occurs if there is no input within this time. |
388 If nil, means stealth fontification is never performed. | 431 If nil, means stealth fontification is never performed. |
389 | 432 |
390 The value of this variable is used when Lazy Lock mode is turned on.") | 433 The value of this variable is used when Lazy Lock mode is turned on." |
391 | 434 :type '(radio (const :tag "Never" nil) |
392 (defvar lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250) | 435 (number :tag "Seconds")) |
436 :group 'lazy-lock) | |
437 | |
438 (defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250) | |
393 "*Maximum size of a chunk of stealth fontification. | 439 "*Maximum size of a chunk of stealth fontification. |
394 Each iteration of stealth fontification can fontify this number of lines. | 440 Each iteration of stealth fontification can fontify this number of lines. |
395 To speed up input response during stealth fontification, at the cost of stealth | 441 To speed up input response during stealth fontification, at the cost of stealth |
396 taking longer to fontify, you could reduce the value of this variable.") | 442 taking longer to fontify, you could reduce the value of this variable." |
397 | 443 :type '(integer :tag "Lines") |
398 (defvar lazy-lock-stealth-load | 444 :group 'lazy-lock) |
399 (when (condition-case nil (load-average) (error)) 200) | 445 |
446 (defcustom lazy-lock-stealth-load | |
447 (when (condition-case nil (load-average) (error)) | |
448 200) | |
400 "*Load in percentage above which stealth fontification is suspended. | 449 "*Load in percentage above which stealth fontification is suspended. |
401 Stealth fontification pauses when the system short-term load average (as | 450 Stealth fontification pauses when the system short-term load average (as |
402 returned by the function `load-average' if supported) goes above this level, | 451 returned by the function `load-average' if supported) goes above this level, |
403 thus reducing the demand that stealth fontification makes on the system. | 452 thus reducing the demand that stealth fontification makes on the system. |
404 If nil, means stealth fontification is never suspended. | 453 If nil, means stealth fontification is never suspended. |
405 To reduce machine load during stealth fontification, at the cost of stealth | 454 To reduce machine load during stealth fontification, at the cost of stealth |
406 taking longer to fontify, you could reduce the value of this variable. | 455 taking longer to fontify, you could reduce the value of this variable. |
407 See also `lazy-lock-stealth-nice'.") | 456 See also `lazy-lock-stealth-nice'." |
408 | 457 :type '(radio (const :tag "Never" nil) |
409 (defvar lazy-lock-stealth-nice | 458 (integer :tag "Load")) |
459 :group 'lazy-lock) | |
460 | |
461 (defcustom lazy-lock-stealth-nice | |
410 (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1) | 462 (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1) |
411 "*Time in seconds to pause between chunks of stealth fontification. | 463 "*Time in seconds to pause between chunks of stealth fontification. |
412 Each iteration of stealth fontification is separated by this amount of time, | 464 Each iteration of stealth fontification is separated by this amount of time, |
413 thus reducing the demand that stealth fontification makes on the system. | 465 thus reducing the demand that stealth fontification makes on the system. |
414 If nil, means stealth fontification is never paused. | 466 If nil, means stealth fontification is never paused. |
415 To reduce machine load during stealth fontification, at the cost of stealth | 467 To reduce machine load during stealth fontification, at the cost of stealth |
416 taking longer to fontify, you could increase the value of this variable. | 468 taking longer to fontify, you could increase the value of this variable. |
417 See also `lazy-lock-stealth-load'.") | 469 See also `lazy-lock-stealth-load'." |
418 | 470 :type '(radio (const :tag "Never" nil) |
419 (defvar lazy-lock-stealth-verbose | 471 (number :tag "Seconds")) |
472 :group 'lazy-lock) | |
473 | |
474 (defcustom lazy-lock-stealth-verbose | |
420 (when (featurep 'lisp-float-type) | 475 (when (featurep 'lisp-float-type) |
421 (and font-lock-verbose (not lazy-lock-defer-contextually))) | 476 (and font-lock-verbose (not lazy-lock-defer-contextually))) |
422 "*If non-nil, means stealth fontification should show status messages.") | 477 "*If non-nil, means stealth fontification should show status messages." |
478 :type 'boolean | |
479 :group 'lazy-lock) | |
423 | 480 |
424 ;; User Functions: | 481 ;; User Functions: |
425 | 482 |
426 ;;;###autoload | 483 ;;;###autoload |
427 (defun lazy-lock-mode (&optional arg) | 484 (defun lazy-lock-mode (&optional arg) |
902 ;; Where we cannot use `window-start' and `window-end' we do `window-height' | 959 ;; Where we cannot use `window-start' and `window-end' we do `window-height' |
903 ;; lines around point. That way we guarantee to have done enough. | 960 ;; lines around point. That way we guarantee to have done enough. |
904 (with-current-buffer (window-buffer window) | 961 (with-current-buffer (window-buffer window) |
905 (lazy-lock-fontify-region | 962 (lazy-lock-fontify-region |
906 (save-excursion | 963 (save-excursion |
964 (goto-char (window-point window)) | |
907 (vertical-motion (- (window-height window)) window) (point)) | 965 (vertical-motion (- (window-height window)) window) (point)) |
908 (save-excursion | 966 (save-excursion |
967 (goto-char (window-point window)) | |
909 (vertical-motion (window-height window) window) (point))))) | 968 (vertical-motion (window-height window) window) (point))))) |
910 | 969 |
911 (defun lazy-lock-unfontified-p () | 970 (defun lazy-lock-unfontified-p () |
912 ;; Return non-nil if there is anywhere still to be fontified. | 971 ;; Return non-nil if there is anywhere still to be fontified. |
913 (save-restriction | 972 (save-restriction |