annotate lisp/lazy-lock.el @ 17562:512c5e112d10

Delete setting of byte-compile-dynamic, byte-compile-dynamic-docstrings and byte-optimize. (with-current-buffer): Duplicate definition deleted. (save-buffer-state, do-while): Move defmacros to top level.
author Richard M. Stallman <rms@gnu.org>
date Fri, 25 Apr 1997 18:14:10 +0000
parents 1c2392208ad9
children fd8de684f5c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; lazy-lock.el --- Lazy demand-driven fontification for fast Font Lock mode.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Simon Marshall <simon@gnu.ai.mit.edu>
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: faces files
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
7 ;; Version: 2.08
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;;; This file is part of GNU Emacs.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
28 ;; Purpose:
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
29 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
30 ;; Lazy Lock mode is a Font Lock support mode.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
31 ;; It makes visiting buffers in Font Lock mode faster by making fontification
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
32 ;; be demand-driven, deferred and stealthy, so that fontification only occurs
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
33 ;; when, and where, necessary.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; See caveats and feedback below.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; See also the fast-lock package. (But don't use them at the same time!)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Installation:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; Put in your ~/.emacs:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
42 ;; (setq font-lock-support-mode 'lazy-lock-mode)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; Start up a new Emacs and use font-lock as usual (except that you can use the
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; so-called "gaudier" fontification regexps on big files without frustration).
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; In a buffer (which has `font-lock-mode' enabled) which is at least
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; `lazy-lock-minimum-size' characters long, buffer fontification will not
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; occur and only the visible portion of the buffer will be fontified. Motion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; around the buffer will fontify those visible portions not previously
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; fontified. If stealth fontification is enabled, buffer fontification will
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; occur in invisible parts of the buffer after `lazy-lock-stealth-time'
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; seconds of idle time. If on-the-fly fontification is deferred, on-the-fly
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; fontification will occur after `lazy-lock-defer-time' seconds of idle time.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; User-visible differences with version 1:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; - Version 2 can defer on-the-fly fontification. Therefore you need not, and
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; should not, use defer-lock.el with this version of lazy-lock.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; A number of variables have changed meaning:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; - A value of nil for the variable `lazy-lock-minimum-size' means never turn
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; on demand-driven fontification. In version 1 this meant always turn on
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; demand-driven fontification. If you really want demand-driven fontification
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; regardless of buffer size, set this variable to 0.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; - The variable `lazy-lock-stealth-lines' cannot have a nil value. In
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; version 1 this meant use `window-height' as the maximum number of lines to
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; fontify as a stealth chunk. This makes no sense; stealth fontification is
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; of a buffer, not a window.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; Implementation differences with version 1:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; - Version 1 of lazy-lock.el is a bit of a hack. Version 1 demand-driven
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; fontification, the core feature of lazy-lock.el, is implemented by placing a
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; function on `post-command-hook'. This function fontifies where necessary,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; i.e., where a window scroll has occurred. However, there are a number of
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; problems with using `post-command-hook':
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; (a) As the name suggests, `post-command-hook' is run after every command,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; i.e., frequently and regardless of whether scrolling has occurred.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; (b) Scrolling can occur during a command, when `post-command-hook' is not
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; run, i.e., it is not necessarily run after scrolling has occurred.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; (c) When `post-command-hook' is run, there is nothing to suggest where
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; scrolling might have occurred, i.e., which windows have scrolled.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; Thus lazy-lock.el's function is called almost as often as possible, usually
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; when it need not be called, yet it is not always called when it is needed.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; Also, lazy-lock.el's function must check each window to see if a scroll has
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; occurred there. Worse still, lazy-lock.el's function must fontify a region
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; twice as large as necessary to make sure the window is completely fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; Basically, `post-command-hook' is completely inappropriate for lazy-lock.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; Ideally, we want to attach lazy-lock.el's function to a hook that is run
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; only when scrolling occurs, e.g., `window-start' has changed, and tells us
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; as much information as we need, i.e., the window and its new buffer region.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; Richard Stallman implemented a `window-scroll-functions' for Emacs 19.30.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; Functions on it are run when `window-start' has changed, and are supplied
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; with the window and the window's new `window-start' position. (It would be
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; better if it also supplied the window's new `window-end' position, but that
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; is calculated as part of the redisplay process, and the functions on
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; `window-scroll-functions' are run before redisplay has finished.) Thus, the
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; hook deals with the above problems (a), (b) and (c).
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; If only life was that easy. Version 2 demand-driven fontification is mostly
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; implemented by placing a function on `window-scroll-functions'. However,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; not all scrolling occurs when `window-start' has changed. A change in
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; window size, e.g., via C-x 1, or a significant deletion, e.g., of a number
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
110 ;; of lines, causes text previously invisible (i.e., after `window-end') to
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
111 ;; become visible without changing `window-start'. Arguably, these events are
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
112 ;; not scrolling events, but fontification must occur for lazy-lock.el to work.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
113 ;; Hooks `window-size-change-functions' and `redisplay-end-trigger-functions'
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
114 ;; were added for these circumstances.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;;
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
116 ;; (Ben Wing thinks these hooks are "horribly horribly kludgy", and implemented
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; a `pre-idle-hook', a `mother-of-all-post-command-hooks', for XEmacs 19.14.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; He then hacked up a version 1 lazy-lock.el to use `pre-idle-hook' rather
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; than `post-command-hook'. Whereas functions on `post-command-hook' are
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; called almost as often as possible, functions on `pre-idle-hook' really are
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; called as often as possible, even when the mouse moves and, on some systems,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; while XEmacs is idle. Thus, the hook deals with the above problem (b), but
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; unfortunately it makes (a) worse and does not address (c) at all.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; I freely admit that `redisplay-end-trigger-functions' and, to a much lesser
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; extent, `window-size-change-functions' are not pretty. However, I feel that
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; a `window-scroll-functions' feature is cleaner than a `pre-idle-hook', and
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; the result is faster and smaller, less intrusive and more targeted, code.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; Since `pre-idle-hook' is pretty much like `post-command-hook', there is no
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; point in making this version of lazy-lock.el work with it. Anyway, that's
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; Lit 30 of my humble opinion.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
133 ;; Steve Baur reverted to a non-hacked version 1 lazy-lock.el for XEmacs 19.15
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
134 ;; and 20.0. Obviously, the above `post-command-hook' problems still apply.)
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
135 ;;
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; - Version 1 stealth fontification is also implemented by placing a function
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; on `post-command-hook'. This function waits for a given amount of time,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; and, if Emacs remains idle, fontifies where necessary. Again, there are a
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; number of problems with using `post-command-hook':
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; (a) Functions on `post-command-hook' are run sequentially, so this function
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; can interfere with other functions on the hook, and vice versa.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; (b) This function waits for a given amount of time, so it can interfere with
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;; various features that are dealt with by Emacs after a command, e.g.,
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; region highlighting, asynchronous updating and keystroke echoing.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; (c) Fontification may be required during a command, when `post-command-hook'
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; is not run. (Version 2 deferred fontification only.)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; Again, `post-command-hook' is completely inappropriate for lazy-lock.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; Richard Stallman and Morten Welinder implemented internal Timers and Idle
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; Timers for Emacs 19.31. Functions can be run independently at given times
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; or after given amounts of idle time. Thus, the feature deals with the above
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; problems (a), (b) and (c). Version 2 deferral and stealth are implemented
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; by functions on Idle Timers. (A function on XEmacs' `pre-idle-hook' is
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
155 ;; similar to an Emacs Idle Timer function with a fixed zero second timeout.)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
157 ;; - Version 1 has the following problems (relative to version 2):
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
158 ;;
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
159 ;; (a) It is slow when it does its job.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
160 ;; (b) It does not always do its job when it should.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
161 ;; (c) It slows all interaction (when it doesn't need to do its job).
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
162 ;; (d) It interferes with other package functions on `post-command-hook'.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
163 ;; (e) It interferes with Emacs things within the read-eval loop.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
164 ;;
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
165 ;; Ben's hacked-up lazy-lock.el 1.14 almost solved (b) but made (c) worse.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
166 ;;
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
167 ;; - Version 2 has the following additional features (relative to version 1):
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
168 ;;
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
169 ;; (a) It can defer fontification (both on-the-fly and on-scrolling).
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
170 ;; (b) It can fontify contextually (syntactically true on-the-fly).
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
171
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; Caveats:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
174 ;; Lazy Lock mode does not work efficiently with Outline mode.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
175 ;; This is because when in Outline mode, although text may be not visible to
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
176 ;; you in the window, the text is visible to Emacs Lisp code (not surprisingly)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
177 ;; and Lazy Lock fontifies it mercilessly. Maybe it will be fixed one day.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ;; Because buffer text is not necessarily fontified, other packages that expect
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; buffer text to be fontified in Font Lock mode either might not work as
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; expected, or might not display buffer text as expected. An example of the
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; latter is `occur', which copies lines of buffer text into another buffer.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; In Emacs 19.30, Lazy Lock mode does not ensure that an existing buffer is
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; fontified if it is made visible via a minibuffer-less command that replaces
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; an existing window's buffer (e.g., via the Buffers menu). Upgrade!
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; In Emacs 19.30, Lazy Lock mode does not work well with Transient Mark mode
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;; or modes based on Comint mode (e.g., Shell mode), and also interferes with
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; the echoing of keystrokes in the minibuffer. This is because of the way
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ;; deferral and stealth have to be implemented for Emacs 19.30. Upgrade!
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;;
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
193 ;; Currently XEmacs does not have the features to support this version of
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
194 ;; lazy-lock.el. Maybe it will one day.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
196 ;;; Code:
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
197
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (require 'font-lock)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; Make sure lazy-lock.el is supported.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (if (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 t
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (and (= emacs-major-version 19) (< emacs-minor-version 30)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (error "`lazy-lock' was written for Emacs 19.30 or later"))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (eval-when-compile
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;; We don't do this at the top-level as idle timers are not necessarily used.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (require 'timer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;; We don't do this at the top-level as we only use non-autoloaded macros.
17562
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
211 (require 'cl))
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
212
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
213 ;; We use this to preserve or protect things when modifying text properties.
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
214 (defmacro save-buffer-state (varlist &rest body)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
215 "Bind variables according to VARLIST and eval BODY restoring buffer state."
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
216 (` (let* ((,@ (append varlist
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
217 '((modified (buffer-modified-p)) (buffer-undo-list t)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
218 (inhibit-read-only t) (inhibit-point-motion-hooks t)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
219 before-change-functions after-change-functions
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
220 deactivate-mark buffer-file-name buffer-file-truename))))
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
221 (,@ body)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
222 (when (and (not modified) (buffer-modified-p))
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
223 (set-buffer-modified-p nil)))))
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
224 (put 'save-buffer-state 'lisp-indent-function 1)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
225
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
226 ;; We use this for clarity and speed. Naughty but nice.
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
227 (defmacro do-while (test &rest body)
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
228 "(do-while TEST BODY...): eval BODY... and repeat if TEST yields non-nil.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 The order of execution is thus BODY, TEST, BODY, TEST and so on
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 until TEST returns nil."
17562
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
231 (` (while (progn (,@ body) (, test)))))
512c5e112d10 Delete setting of byte-compile-dynamic,
Richard M. Stallman <rms@gnu.org>
parents: 17508
diff changeset
232 (put 'do-while 'lisp-indent-function (get 'while 'lisp-indent-function))
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
233
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
234 ;(defun lazy-lock-submit-bug-report ()
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
235 ; "Submit via mail a bug report on lazy-lock.el."
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
236 ; (interactive)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
237 ; (let ((reporter-prompt-for-summary-p t))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
238 ; (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 2.08"
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
239 ; '(lazy-lock-minimum-size lazy-lock-defer-on-the-fly
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
240 ; lazy-lock-defer-on-scrolling lazy-lock-defer-contextually
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
241 ; lazy-lock-defer-time lazy-lock-stealth-time
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
242 ; lazy-lock-stealth-load lazy-lock-stealth-nice lazy-lock-stealth-lines
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
243 ; lazy-lock-stealth-verbose)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
244 ; nil nil
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
245 ; (concat "Hi Si.,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
246 ;
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
247 ;I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
248 ;know how to make a clear and unambiguous report. To reproduce the bug:
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
249 ;
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
250 ;Start a fresh editor via `" invocation-name " -no-init-file -no-site-file'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
251 ;In the `*scratch*' buffer, evaluate:"))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
252
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
253 (defvar lazy-lock-mode nil) ; Whether we are turned on.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
254 (defvar lazy-lock-buffers nil) ; For deferral.
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
255 (defvar lazy-lock-timers (cons nil nil)) ; For deferral and stealth.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ;; User Variables:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
259 (defgroup lazy-lock nil
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
260 "Font Lock support mode to fontify lazily."
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
261 :link '(custom-manual "(emacs)Support Modes")
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
262 :group 'font-lock)
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
263
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
264 (defcustom lazy-lock-minimum-size (* 25 1024)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 "*Minimum size of a buffer for demand-driven fontification.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 On-demand fontification occurs if the buffer size is greater than this value.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 If nil, means demand-driven fontification is never performed.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 where MAJOR-MODE is a symbol or t (meaning the default). For example:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ((c-mode . 25600) (c++-mode . 25600) (rmail-mode . 1048576))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 means that the minimum size is 25K for buffers in C or C++ modes, one megabyte
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 for buffers in Rmail mode, and size is irrelevant otherwise.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
274 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
275 :type '(choice (const :tag "none" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
276 (integer :tag "size")
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
277 (repeat :menu-tag "mode specific" :tag "mode specific"
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
278 :value ((t . nil))
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
279 (cons :tag "Instance"
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
280 (radio :tag "Mode"
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
281 (const :tag "all" t)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
282 (symbol :tag "name"))
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
283 (radio :tag "Size"
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
284 (const :tag "none" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
285 (integer :tag "size")))))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
286 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
288 (defcustom lazy-lock-defer-on-the-fly t
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
289 "*If non-nil, means fontification after a change should be deferred.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
290 If nil, means on-the-fly fontification is performed. This means when changes
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
291 occur in the buffer, those areas are immediately fontified.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
292 If a list, it should be a list of `major-mode' symbol names for which deferred
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
293 fontification should occur. The sense of the list is negated if it begins with
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
294 `not'. For example:
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
295 (c-mode c++-mode)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
296 means that on-the-fly fontification is deferred for buffers in C and C++ modes
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
297 only, and deferral does not occur otherwise.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
298
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
299 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
300 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
301 (const :tag "always" t)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
302 (set :menu-tag "mode specific" :tag "modes"
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
303 :value (not)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
304 (const :tag "Except" not)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
305 (repeat :inline t (symbol :tag "mode"))))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
306 :group 'lazy-lock)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
307
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
308 (defcustom lazy-lock-defer-on-scrolling nil
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
309 "*If non-nil, means fontification after a scroll should be deferred.
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
310 If nil, means demand-driven fontification is performed. This means when
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
311 scrolling into unfontified areas of the buffer, those areas are immediately
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
312 fontified. Thus scrolling never presents unfontified areas. However, since
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
313 fontification occurs during scrolling, scrolling may be slow.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 If t, means defer-driven fontification is performed. This means fontification
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 of those areas is deferred. Thus scrolling may present momentarily unfontified
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 areas. However, since fontification does not occur during scrolling, scrolling
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 will be faster than demand-driven fontification.
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
318 If any other value, e.g., `eventually', means demand-driven fontification is
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
319 performed until the buffer is fontified, then buffer fontification becomes
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
320 defer-driven. Thus scrolling never presents unfontified areas until the buffer
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
321 is first fontified, after which subsequent scrolling may present future buffer
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
322 insertions momentarily unfontified. However, since fontification does not
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
323 occur during scrolling after the buffer is first fontified, scrolling will
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
324 become faster. (But, since contextual changes continually occur, such a value
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
325 makes little sense if `lazy-lock-defer-contextually' is non-nil.)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
326
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
327 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
328 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
329 (const :tag "always" t)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
330 (const eventually))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
331 :group 'lazy-lock)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
332
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
333 (defcustom lazy-lock-defer-contextually 'syntax-driven
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
334 "*If non-nil, means deferred fontification should be syntactically true.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
335 If nil, means deferred fontification occurs only on those lines modified. This
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
336 means where modification on a line causes syntactic change on subsequent lines,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
337 those subsequent lines are not refontified to reflect their new context.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
338 If t, means deferred fontification occurs on those lines modified and all
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
339 subsequent lines. This means those subsequent lines are refontified to reflect
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
340 their new syntactic context, either immediately or when scrolling into them.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
341 If any other value, e.g., `syntax-driven', means deferred syntactically true
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
342 fontification occurs only if syntactic fontification is performed using the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
343 buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
345 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
346 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
347 (const :tag "always" t)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
348 (const syntax-driven))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
349 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
351 (defcustom lazy-lock-defer-time
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
352 (if (featurep 'lisp-float-type) (/ (float 1) (float 3)) 1)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 "*Time in seconds to delay before beginning deferred fontification.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 Deferred fontification occurs if there is no input within this time.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
355 If nil, means fontification is never deferred, regardless of the values of the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
356 variables `lazy-lock-defer-on-the-fly', `lazy-lock-defer-on-scrolling' and
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
357 `lazy-lock-defer-contextually'.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
359 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
360 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
361 (number :tag "seconds"))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
362 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
364 (defcustom lazy-lock-stealth-time 30
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 "*Time in seconds to delay before beginning stealth fontification.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 Stealth fontification occurs if there is no input within this time.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 If nil, means stealth fontification is never performed.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
369 The value of this variable is used when Lazy Lock mode is turned on."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
370 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
371 (number :tag "seconds"))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
372 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
374 (defcustom lazy-lock-stealth-lines (if font-lock-maximum-decoration 100 250)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 "*Maximum size of a chunk of stealth fontification.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 Each iteration of stealth fontification can fontify this number of lines.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 To speed up input response during stealth fontification, at the cost of stealth
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
378 taking longer to fontify, you could reduce the value of this variable."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
379 :type '(integer :tag "lines")
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
380 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
382 (defcustom lazy-lock-stealth-load
17508
1c2392208ad9 Don't use cl forms in defcustom declarations.
Simon Marshall <simon@gnu.org>
parents: 17507
diff changeset
383 (if (condition-case nil (load-average) (error)) 200)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
384 "*Load in percentage above which stealth fontification is suspended.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
385 Stealth fontification pauses when the system short-term load average (as
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
386 returned by the function `load-average' if supported) goes above this level,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
387 thus reducing the demand that stealth fontification makes on the system.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
388 If nil, means stealth fontification is never suspended.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
389 To reduce machine load during stealth fontification, at the cost of stealth
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
390 taking longer to fontify, you could reduce the value of this variable.
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
391 See also `lazy-lock-stealth-nice'."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
392 :type (if (condition-case nil (load-average) (error))
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
393 '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
394 (integer :tag "load"))
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
395 '(const :tag "never" nil))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
396 :group 'lazy-lock)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
397
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
398 (defcustom lazy-lock-stealth-nice
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (if (featurep 'lisp-float-type) (/ (float 1) (float 8)) 1)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 "*Time in seconds to pause between chunks of stealth fontification.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
401 Each iteration of stealth fontification is separated by this amount of time,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
402 thus reducing the demand that stealth fontification makes on the system.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
403 If nil, means stealth fontification is never paused.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 To reduce machine load during stealth fontification, at the cost of stealth
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
405 taking longer to fontify, you could increase the value of this variable.
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
406 See also `lazy-lock-stealth-load'."
17507
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
407 :type '(choice (const :tag "never" nil)
fd87760f20cd Cleaned up custom support.
Simon Marshall <simon@gnu.org>
parents: 17498
diff changeset
408 (number :tag "seconds"))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
409 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
411 (defcustom lazy-lock-stealth-verbose
17508
1c2392208ad9 Don't use cl forms in defcustom declarations.
Simon Marshall <simon@gnu.org>
parents: 17507
diff changeset
412 (if (featurep 'lisp-float-type)
1c2392208ad9 Don't use cl forms in defcustom declarations.
Simon Marshall <simon@gnu.org>
parents: 17507
diff changeset
413 (and (not lazy-lock-defer-contextually) (not (null font-lock-verbose))))
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
414 "*If non-nil, means stealth fontification should show status messages."
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
415 :type 'boolean
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
416 :group 'lazy-lock)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;; User Functions:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 ;;;###autoload
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (defun lazy-lock-mode (&optional arg)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 "Toggle Lazy Lock mode.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 With arg, turn Lazy Lock mode on if and only if arg is positive. Enable it
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 automatically in your `~/.emacs' by:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (setq font-lock-support-mode 'lazy-lock-mode)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 When Lazy Lock mode is enabled, fontification can be lazy in a number of ways:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
430 - Demand-driven buffer fontification if `lazy-lock-minimum-size' is non-nil.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
431 This means initial fontification does not occur if the buffer is greater than
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
432 `lazy-lock-minimum-size' characters in length. Instead, fontification occurs
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
433 when necessary, such as when scrolling through the buffer would otherwise
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
434 reveal unfontified areas. This is useful if buffer fontification is too slow
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
435 for large buffers.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
437 - Deferred scroll fontification if `lazy-lock-defer-on-scrolling' is non-nil.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
438 This means demand-driven fontification does not occur as you scroll.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
439 Instead, fontification is deferred until after `lazy-lock-defer-time' seconds
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
440 of Emacs idle time, while Emacs remains idle. This is useful if
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
441 fontification is too slow to keep up with scrolling.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
442
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
443 - Deferred on-the-fly fontification if `lazy-lock-defer-on-the-fly' is non-nil.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
444 This means on-the-fly fontification does not occur as you type. Instead,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
445 fontification is deferred until after `lazy-lock-defer-time' seconds of Emacs
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
446 idle time, while Emacs remains idle. This is useful if fontification is too
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
447 slow to keep up with your typing.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
449 - Deferred context fontification if `lazy-lock-defer-contextually' is non-nil.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
450 This means fontification updates the buffer corresponding to true syntactic
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
451 context, after `lazy-lock-defer-time' seconds of Emacs idle time, while Emacs
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
452 remains idle. Otherwise, fontification occurs on modified lines only, and
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
453 subsequent lines can remain fontified corresponding to previous syntactic
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
454 contexts. This is useful where strings or comments span lines.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
456 - Stealthy buffer fontification if `lazy-lock-stealth-time' is non-nil.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
457 This means remaining unfontified areas of buffers are fontified if Emacs has
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
458 been idle for `lazy-lock-stealth-time' seconds, while Emacs remains idle.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
459 This is useful if any buffer has any deferred fontification.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
461 Basic Font Lock mode on-the-fly fontification behaviour fontifies modified
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
462 lines only. Thus, if `lazy-lock-defer-contextually' is non-nil, Lazy Lock mode
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
463 on-the-fly fontification may fontify differently, albeit correctly. In any
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
464 event, to refontify some lines you can use \\[font-lock-fontify-block].
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
466 Stealth fontification only occurs while the system remains unloaded.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
467 If the system load rises above `lazy-lock-stealth-load' percent, stealth
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
468 fontification is suspended. Stealth fontification intensity is controlled via
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
469 the variable `lazy-lock-stealth-nice' and `lazy-lock-stealth-lines', and
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
470 verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (interactive "P")
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
472 (let* ((was-on lazy-lock-mode)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
473 (now-on (unless (memq 'lazy-lock-mode font-lock-inhibit-thing-lock)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
474 (if arg (> (prefix-numeric-value arg) 0) (not was-on)))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
475 (cond ((and now-on (not font-lock-mode))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
476 ;; Turned on `lazy-lock-mode' rather than `font-lock-mode'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
477 (let ((font-lock-support-mode 'lazy-lock-mode))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
478 (font-lock-mode t)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
479 (now-on
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
480 ;; Turn ourselves on.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
481 (set (make-local-variable 'lazy-lock-mode) t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
482 (lazy-lock-install))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
483 (was-on
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
484 ;; Turn ourselves off.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
485 (set (make-local-variable 'lazy-lock-mode) nil)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
486 (lazy-lock-unstall)))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 ;;;###autoload
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (defun turn-on-lazy-lock ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 "Unconditionally turn on Lazy Lock mode."
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (lazy-lock-mode t))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (defun lazy-lock-install ()
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
494 (let ((min-size (font-lock-value-in-major-mode lazy-lock-minimum-size))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
495 (defer-change (and lazy-lock-defer-time lazy-lock-defer-on-the-fly))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
496 (defer-scroll (and lazy-lock-defer-time lazy-lock-defer-on-scrolling))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
497 (defer-context (and lazy-lock-defer-time lazy-lock-defer-contextually
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
498 (or (eq lazy-lock-defer-contextually t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
499 (null font-lock-keywords-only)))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 ;; Tell Font Lock whether Lazy Lock will do fontification.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (make-local-variable 'font-lock-fontified)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (setq font-lock-fontified (and min-size (>= (buffer-size) min-size)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 ;; Add the text properties and fontify.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (if (not font-lock-fontified)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (lazy-lock-after-fontify-buffer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 ;; Make sure we fontify in any existing windows showing the buffer.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (let ((windows (get-buffer-window-list (current-buffer) 'nomini t)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (lazy-lock-after-unfontify-buffer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (while windows
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (lazy-lock-fontify-conservatively (car windows))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (setq windows (cdr windows)))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 ;; Add the fontification hooks.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (lazy-lock-install-hooks
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 font-lock-fontified
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
518 (cond ((eq (car-safe defer-change) 'not)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
519 (not (memq major-mode (cdr defer-change))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
520 ((listp defer-change)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
521 (memq major-mode defer-change))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
522 (t
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
523 defer-change))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
524 (eq defer-scroll t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
525 defer-context)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 ;; Add the fontification timers.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (lazy-lock-install-timers
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
529 (if (or defer-change defer-scroll defer-context) lazy-lock-defer-time)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 lazy-lock-stealth-time)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
532 (defun lazy-lock-install-hooks (fontifying
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
533 defer-change defer-scroll defer-context)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
535 ;; Add hook if lazy-lock.el is fontifying on scrolling or is deferring.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
536 (when (or fontifying defer-change defer-scroll defer-context)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (make-local-hook 'window-scroll-functions)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
538 (add-hook 'window-scroll-functions (if defer-scroll
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 'lazy-lock-defer-after-scroll
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 'lazy-lock-fontify-after-scroll)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 nil t))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
543 ;; Add hook if lazy-lock.el is fontifying and is not deferring changes.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
544 (when (and fontifying (not defer-change) (not defer-context))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (make-local-hook 'before-change-functions)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (add-hook 'before-change-functions 'lazy-lock-arrange-before-change nil t))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
548 ;; Replace Font Lock mode hook.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
549 (remove-hook 'after-change-functions 'font-lock-after-change-function t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
550 (add-hook 'after-change-functions
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
551 (cond ((and defer-change defer-context)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
552 'lazy-lock-defer-rest-after-change)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
553 (defer-change
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
554 'lazy-lock-defer-line-after-change)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
555 (defer-context
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
556 'lazy-lock-fontify-rest-after-change)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
557 (t
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
558 'lazy-lock-fontify-line-after-change))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
559 nil t)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
561 ;; Add package-specific hook.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 (make-local-hook 'outline-view-change-hook)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (add-hook 'outline-view-change-hook 'lazy-lock-fontify-after-outline nil t))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (defun lazy-lock-install-timers (dtime stime)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 ;; Schedule or re-schedule the deferral and stealth timers.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 ;; The layout of `lazy-lock-timers' is:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 ;; ((DEFER-TIME . DEFER-TIMER) (STEALTH-TIME . STEALTH-TIMER)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;; If an idle timeout has changed, cancel the existing idle timer (if there
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 ;; is one) and schedule a new one (if the new idle timeout is non-nil).
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 (unless (eq dtime (car (car lazy-lock-timers)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (let ((defer (car lazy-lock-timers)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (when (cdr defer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 (cancel-timer (cdr defer)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (setcar lazy-lock-timers (cons dtime (and dtime
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 (run-with-idle-timer dtime t 'lazy-lock-fontify-after-defer))))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (unless (eq stime (car (cdr lazy-lock-timers)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (let ((stealth (cdr lazy-lock-timers)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (when (cdr stealth)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (cancel-timer (cdr stealth)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (setcdr lazy-lock-timers (cons stime (and stime
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (run-with-idle-timer stime t 'lazy-lock-fontify-after-idle)))))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 (defun lazy-lock-unstall ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 ;;
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
586 ;; If Font Lock mode is still enabled, make sure that the buffer is
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
587 ;; fontified, and reinstall its hook. We must do this first.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
588 (when font-lock-mode
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
589 (when (lazy-lock-unfontified-p)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
590 (let ((verbose (if (numberp font-lock-verbose)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
591 (> (buffer-size) font-lock-verbose)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
592 font-lock-verbose)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
593 (if verbose (message "Fontifying %s..." (buffer-name)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
594 ;; Make sure we fontify etc. in the whole buffer.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
595 (save-restriction
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
596 (widen)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
597 (lazy-lock-fontify-region (point-min) (point-max)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
598 (if verbose (message "Fontifying %s...%s" (buffer-name)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
599 (if (lazy-lock-unfontified-p) "quit" "done")))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
600 (add-hook 'after-change-functions 'font-lock-after-change-function nil t))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
601 ;;
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 ;; Remove the text properties.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (lazy-lock-after-unfontify-buffer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 ;; Remove the fontification hooks.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 (remove-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll t)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (remove-hook 'before-change-functions 'lazy-lock-arrange-before-change t)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
609 (remove-hook 'after-change-functions 'lazy-lock-fontify-line-after-change t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
610 (remove-hook 'after-change-functions 'lazy-lock-fontify-rest-after-change t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
611 (remove-hook 'after-change-functions 'lazy-lock-defer-line-after-change t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
612 (remove-hook 'after-change-functions 'lazy-lock-defer-rest-after-change t)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
613 (remove-hook 'outline-view-change-hook 'lazy-lock-fontify-after-outline t))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 ;; Hook functions.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
617 ;; Lazy Lock mode intervenes when (1) a previously invisible buffer region
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
618 ;; becomes visible, i.e., for demand- or defer-driven on-the-scroll
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
619 ;; fontification, (2) a buffer modification occurs, i.e., for defer-driven
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
620 ;; on-the-fly fontification, (3) Emacs becomes idle, i.e., for fontification of
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
621 ;; deferred fontification and stealth fontification, and (4) other special
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
622 ;; occasions.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
623
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
624 ;; 1. There are three ways whereby this can happen.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
625 ;;
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
626 ;; (a) Scrolling the window, either explicitly (e.g., `scroll-up') or
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
627 ;; implicitly (e.g., `search-forward'). Here, `window-start' changes.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
628 ;; Fontification occurs by adding `lazy-lock-fontify-after-scroll' (for
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
629 ;; demand-driven fontification) or `lazy-lock-defer-after-scroll' (for
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
630 ;; defer-driven fontification) to the hook `window-scroll-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
631
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (defun lazy-lock-fontify-after-scroll (window window-start)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 ;; Called from `window-scroll-functions'.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
634 ;; Fontify WINDOW from WINDOW-START following the scroll. We cannot use
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
635 ;; `window-end' so we work out what it would be via `vertical-motion'.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (save-excursion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (goto-char window-start)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 (vertical-motion (window-height window) window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (lazy-lock-fontify-region window-start (point)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 ;; A prior deletion that did not cause scrolling, followed by a scroll, would
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 ;; result in an unnecessary trigger after this if we did not cancel it now.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (set-window-redisplay-end-trigger window nil))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
644 (defun lazy-lock-defer-after-scroll (window window-start)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
645 ;; Called from `window-scroll-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
646 ;; Defer fontification following the scroll. Save the current buffer so that
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
647 ;; we subsequently fontify in all windows showing the buffer.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
648 (unless (memq (current-buffer) lazy-lock-buffers)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
649 (push (current-buffer) lazy-lock-buffers))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
650 ;; A prior deletion that did not cause scrolling, followed by a scroll, would
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
651 ;; result in an unnecessary trigger after this if we did not cancel it now.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
652 (set-window-redisplay-end-trigger window nil))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
653
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
654 ;; (b) Resizing the window, either explicitly (e.g., `enlarge-window') or
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
655 ;; implicitly (e.g., `delete-other-windows'). Here, `window-end' changes.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
656 ;; Fontification occurs by adding `lazy-lock-fontify-after-resize' to the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
657 ;; hook `window-size-change-functions'.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (defun lazy-lock-fontify-after-resize (frame)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 ;; Called from `window-size-change-functions'.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
661 ;; Fontify windows in FRAME following the resize. We cannot use
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
662 ;; `window-start' or `window-end' so we fontify conservatively.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (save-excursion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (save-selected-window
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (select-frame frame)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (walk-windows (function (lambda (window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (set-buffer (window-buffer window))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (when lazy-lock-mode
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (lazy-lock-fontify-conservatively window))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (set-window-redisplay-end-trigger window nil)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 'nomini frame))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
673 ;; (c) Deletion in the buffer. Here, a `window-end' marker can become visible.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
674 ;; Fontification occurs by adding `lazy-lock-arrange-before-change' to
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
675 ;; `before-change-functions' and `lazy-lock-fontify-after-trigger' to the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
676 ;; hook `redisplay-end-trigger-functions'. Before every deletion, the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
677 ;; marker `window-redisplay-end-trigger' position is set to the soon-to-be
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
678 ;; changed `window-end' position. If the marker becomes visible,
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
679 ;; `lazy-lock-fontify-after-trigger' gets called. Ouch. Note that we only
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
680 ;; have to deal with this eventuality if there is no on-the-fly deferral.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
681
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (defun lazy-lock-arrange-before-change (beg end)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 ;; Called from `before-change-functions'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ;; Arrange that if text becomes visible it will be fontified (if a deletion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 ;; is pending, text might become visible at the bottom).
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (unless (eq beg end)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (let ((windows (get-buffer-window-list (current-buffer) 'nomini t)) window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (while windows
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (setq window (car windows))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (unless (markerp (window-redisplay-end-trigger window))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (set-window-redisplay-end-trigger window (make-marker)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (set-marker (window-redisplay-end-trigger window) (window-end window))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 (setq windows (cdr windows))))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
695 (defun lazy-lock-fontify-after-trigger (window trigger-point)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
696 ;; Called from `redisplay-end-trigger-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
697 ;; Fontify WINDOW from TRIGGER-POINT. We cannot use `window-end' so we work
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
698 ;; out what it would be via `vertical-motion'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
699 ;; We could probably just use `lazy-lock-fontify-after-scroll' without loss:
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
700 ;; (lazy-lock-fontify-after-scroll window (window-start window))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
701 (save-excursion
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
702 (goto-char (window-start window))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
703 (vertical-motion (window-height window) window)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
704 (lazy-lock-fontify-region trigger-point (point))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
706 ;; 2. Modified text must be marked as unfontified so it can be identified and
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
707 ;; fontified later when Emacs is idle. Deferral occurs by adding one of
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
708 ;; `lazy-lock-fontify-*-after-change' (for on-the-fly fontification) or
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
709 ;; `lazy-lock-defer-*-after-change' (for deferred fontification) to the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
710 ;; hook `after-change-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
711
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
712 (defalias 'lazy-lock-fontify-line-after-change
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 ;; Called from `after-change-functions'.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
714 ;; Fontify the current change.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
715 'font-lock-after-change-function)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
716
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
717 (defun lazy-lock-fontify-rest-after-change (beg end old-len)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
718 ;; Called from `after-change-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
719 ;; Fontify the current change and defer fontification of the rest of the
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
720 ;; buffer. Save the current buffer so that we subsequently fontify in all
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
721 ;; windows showing the buffer.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
722 (lazy-lock-fontify-line-after-change beg end old-len)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 (save-buffer-state nil
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (unless (memq (current-buffer) lazy-lock-buffers)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (push (current-buffer) lazy-lock-buffers))
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
726 (remove-text-properties end (point-max) '(lazy-lock nil))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
727
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
728 (defun lazy-lock-defer-line-after-change (beg end old-len)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
729 ;; Called from `after-change-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
730 ;; Defer fontification of the current change. Save the current buffer so
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
731 ;; that we subsequently fontify in all windows showing the buffer.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
732 (save-buffer-state nil
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
733 (unless (memq (current-buffer) lazy-lock-buffers)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
734 (push (current-buffer) lazy-lock-buffers))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
735 (remove-text-properties (max (1- beg) (point-min))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
736 (min (1+ end) (point-max))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
737 '(lazy-lock nil))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
738
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
739 (defun lazy-lock-defer-rest-after-change (beg end old-len)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
740 ;; Called from `after-change-functions'.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
741 ;; Defer fontification of the rest of the buffer. Save the current buffer so
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
742 ;; that we subsequently fontify in all windows showing the buffer.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
743 (save-buffer-state nil
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
744 (unless (memq (current-buffer) lazy-lock-buffers)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
745 (push (current-buffer) lazy-lock-buffers))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
746 (remove-text-properties (max (1- beg) (point-min))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
747 (point-max)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
748 '(lazy-lock nil))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
749
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
750 ;; 3. Deferred fontification and stealth fontification are done from these two
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
751 ;; functions. They are set up as Idle Timers.
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 (defun lazy-lock-fontify-after-defer ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 ;; Called from `timer-idle-list'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 ;; Fontify all windows where deferral has occurred for its buffer.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (while (and lazy-lock-buffers (not (input-pending-p)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (let ((windows (get-buffer-window-list (car lazy-lock-buffers) 'nomini t)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (while windows
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 (lazy-lock-fontify-window (car windows))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 (setq windows (cdr windows)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (setq lazy-lock-buffers (cdr lazy-lock-buffers))))
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
762 ;; Add hook if fontification should now be defer-driven in this buffer.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
763 (when (and lazy-lock-mode lazy-lock-defer-on-scrolling
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
764 (memq 'lazy-lock-fontify-after-scroll window-scroll-functions)
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
765 (not (or (input-pending-p) (lazy-lock-unfontified-p))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (remove-hook 'window-scroll-functions 'lazy-lock-fontify-after-scroll t)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (add-hook 'window-scroll-functions 'lazy-lock-defer-after-scroll nil t)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (defun lazy-lock-fontify-after-idle ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 ;; Called from `timer-idle-list'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 ;; Fontify all buffers that need it, stealthily while idle.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (unless (or executing-kbd-macro (window-minibuffer-p (selected-window)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 ;; Loop over all buffers, fontify stealthily for each if necessary.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (let ((buffers (buffer-list)) (continue t) message message-log-max)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 (save-excursion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 (do-while (and buffers continue)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (set-buffer (car buffers))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 (if (not (and lazy-lock-mode (lazy-lock-unfontified-p)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 (setq continue (not (input-pending-p)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 ;; Fontify regions in this buffer while there is no input.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
781 (do-while (and (lazy-lock-unfontified-p) continue)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
782 (if (and lazy-lock-stealth-load
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
783 (> (car (load-average)) lazy-lock-stealth-load))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
784 ;; Wait a while before continuing with the loop.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
785 (progn
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
786 (when message
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
787 (message "Fontifying stealthily...suspended")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
788 (setq message nil))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
789 (setq continue (sit-for (or lazy-lock-stealth-time 30))))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
790 ;; Fontify a chunk.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
791 (when lazy-lock-stealth-verbose
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
792 (if message
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
793 (message "Fontifying stealthily... %2d%% of %s"
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
794 (lazy-lock-percent-fontified) (buffer-name))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
795 (message "Fontifying stealthily...")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
796 (setq message t)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
797 (lazy-lock-fontify-chunk)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
798 (setq continue (sit-for (or lazy-lock-stealth-nice 0))))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (setq buffers (cdr buffers))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (when message
15499
aa9675ed8ed4 Test for lazy-lock-mode before swapping hooks.
Simon Marshall <simon@gnu.org>
parents: 15461
diff changeset
801 (message "Fontifying stealthily...%s" (if continue "done" "quit"))))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
803 ;; 4. Special circumstances.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
804
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (defun lazy-lock-fontify-after-outline ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 ;; Called from `outline-view-change-hook'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 ;; Fontify windows showing the current buffer, as its visibility has changed.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 ;; This is a conspiracy hack between lazy-lock.el and noutline.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 (let ((windows (get-buffer-window-list (current-buffer) 'nomini t)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 (while windows
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (lazy-lock-fontify-conservatively (car windows))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 (setq windows (cdr windows)))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (defun lazy-lock-after-fontify-buffer ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 ;; Called from `font-lock-after-fontify-buffer'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ;; Mark the current buffer as fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 ;; This is a conspiracy hack between lazy-lock.el and font-lock.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (save-buffer-state nil
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (add-text-properties (point-min) (point-max) '(lazy-lock t))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (defun lazy-lock-after-unfontify-buffer ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 ;; Called from `font-lock-after-unfontify-buffer'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 ;; Mark the current buffer as unfontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 ;; This is a conspiracy hack between lazy-lock.el and font-lock.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (save-buffer-state nil
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (remove-text-properties (point-min) (point-max) '(lazy-lock nil))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 ;; Fontification functions.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 ;; If packages want to ensure that some region of the buffer is fontified, they
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 ;; should use this function. For an example, see ps-print.el.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (defun lazy-lock-fontify-region (beg end)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 ;; Fontify between BEG and END, where necessary, in the current buffer.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (when (setq beg (text-property-any beg end 'lazy-lock nil))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (save-excursion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (save-match-data
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 (save-buffer-state
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 ;; Ensure syntactic fontification is always correct.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 (font-lock-beginning-of-syntax-function next)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;; Find successive unfontified regions between BEG and END.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 (condition-case data
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 (do-while beg
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (setq next (or (text-property-any beg end 'lazy-lock t) end))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 ;; Make sure the region end points are at beginning of line.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (goto-char beg)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (unless (bolp)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (beginning-of-line)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (setq beg (point)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (goto-char next)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (unless (bolp)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (forward-line)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (setq next (point)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 ;; Fontify the region, then flag it as fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 (font-lock-fontify-region beg next)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (add-text-properties beg next '(lazy-lock t))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 (setq beg (text-property-any next end 'lazy-lock nil)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 ((error quit) (message "Fontifying region...%s" data))))))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (defun lazy-lock-fontify-chunk ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 ;; Fontify the nearest chunk, for stealth, in the current buffer.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (save-excursion
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (save-restriction
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (widen)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 ;; Move to end of line in case the character at point is not fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 (end-of-line)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 ;; Find where the previous, and next, unfontified regions end, and begin.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (let ((prev (previous-single-property-change (point) 'lazy-lock))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (next (text-property-any (point) (point-max) 'lazy-lock nil)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 ;; Fontify from the nearest unfontified position.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (if (or (null prev) (and next (< (- next (point)) (- (point) prev))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 ;; The next, or neither, region is the nearest not fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (lazy-lock-fontify-region
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 (progn (goto-char (or next (point-min)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (beginning-of-line)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (point))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (progn (goto-char (or next (point-min)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (forward-line lazy-lock-stealth-lines)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (point)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 ;; The previous region is the nearest not fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (lazy-lock-fontify-region
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (progn (goto-char prev)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (forward-line (- lazy-lock-stealth-lines))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (point))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (progn (goto-char prev)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 (forward-line)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (point))))))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (defun lazy-lock-fontify-window (window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 ;; Fontify in WINDOW between `window-start' and `window-end'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 ;; We can only do this when we can use `window-start' and `window-end'.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
891 (with-current-buffer (window-buffer window)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (lazy-lock-fontify-region (window-start window) (window-end window))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (defun lazy-lock-fontify-conservatively (window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 ;; Fontify in WINDOW conservatively around point.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 ;; Where we cannot use `window-start' and `window-end' we do `window-height'
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 ;; lines around point. That way we guarantee to have done enough.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
898 (with-current-buffer (window-buffer window)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (lazy-lock-fontify-region
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (save-excursion
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
901 (goto-char (window-point window))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 (vertical-motion (- (window-height window)) window) (point))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (save-excursion
17498
5ea11c278a57 Customise.
Simon Marshall <simon@gnu.org>
parents: 16580
diff changeset
904 (goto-char (window-point window))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (vertical-motion (window-height window) window) (point)))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (defun lazy-lock-unfontified-p ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 ;; Return non-nil if there is anywhere still to be fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (save-restriction
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (widen)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (text-property-any (point-min) (point-max) 'lazy-lock nil)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (defun lazy-lock-percent-fontified ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 ;; Return the percentage (of characters) of the buffer that are fontified.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (save-restriction
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (widen)
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
917 (let ((beg (point-min)) (size 0) next)
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 ;; Find where the next fontified region begins.
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
919 (while (setq beg (text-property-any beg (point-max) 'lazy-lock t))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
920 (setq next (or (text-property-any beg (point-max) 'lazy-lock nil)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
921 (point-max)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
922 (incf size (- next beg))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
923 (setq beg next))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
924 ;; Float because using integer multiplication will frequently overflow.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
925 (truncate (* (/ (float size) (point-max)) 100)))))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 ;; Version dependent workarounds and fixes.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (when (if (save-match-data (string-match "Lucid\\|XEmacs" (emacs-version)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 nil
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (and (= emacs-major-version 19) (= emacs-minor-version 30)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 ;; We use `post-command-idle-hook' for deferral and stealth. Oh Lordy.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (defun lazy-lock-install-timers (foo bar)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (add-hook 'post-command-idle-hook 'lazy-lock-fontify-post-command t)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (add-hook 'post-command-idle-hook 'lazy-lock-fontify-post-idle t)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (add-to-list 'lazy-lock-install (current-buffer))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (add-hook 'post-command-hook 'lazy-lock-fontify-after-install))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (defun lazy-lock-fontify-post-command ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (and lazy-lock-buffers (not executing-kbd-macro)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (progn
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (and deactivate-mark (deactivate-mark))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (sit-for
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (or (cdr-safe lazy-lock-defer-time) lazy-lock-defer-time 0)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 (lazy-lock-fontify-after-defer)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (defun lazy-lock-fontify-post-idle ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 (and lazy-lock-stealth-time (not executing-kbd-macro)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (not (window-minibuffer-p (selected-window)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (progn
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (and deactivate-mark (deactivate-mark))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (sit-for lazy-lock-stealth-time))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (lazy-lock-fontify-after-idle)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 ;;
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 ;; Simulate running of `window-scroll-functions' in `set-window-buffer'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (defvar lazy-lock-install nil)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (defun lazy-lock-fontify-after-install ()
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 (remove-hook 'post-command-hook 'lazy-lock-fontify-after-install)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (while lazy-lock-install
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 (mapcar 'lazy-lock-fontify-conservatively
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 (get-buffer-window-list (pop lazy-lock-install) 'nomini t)))))
16580
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
961
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
962 (when (consp lazy-lock-defer-time)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
963 ;;
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
964 ;; In 2.06.04 and below, `lazy-lock-defer-time' could specify modes and time.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
965 (with-output-to-temp-buffer "*Help*"
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
966 (princ "The value of the variable `lazy-lock-defer-time' was\n ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
967 (princ lazy-lock-defer-time)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
968 (princ "\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
969 (princ "This variable cannot now be a list of modes and time, ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
970 (princ "so instead use the forms:\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
971 (princ " (setq lazy-lock-defer-time ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
972 (princ (cdr lazy-lock-defer-time))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
973 (princ ")\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
974 (princ " (setq lazy-lock-defer-on-the-fly '")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
975 (princ (car lazy-lock-defer-time))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
976 (princ ")\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
977 (princ "in your ~/.emacs. ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
978 (princ "The above forms have been evaluated for this editor session,\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
979 (princ "but you should change your ~/.emacs now."))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
980 (setq lazy-lock-defer-on-the-fly (car lazy-lock-defer-time)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
981 lazy-lock-defer-time (cdr lazy-lock-defer-time)))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
982
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
983 (when (boundp 'lazy-lock-defer-driven)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
984 ;;
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
985 ;; In 2.06.04 and below, `lazy-lock-defer-driven' was the variable name.
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
986 (with-output-to-temp-buffer "*Help*"
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
987 (princ "The value of the variable `lazy-lock-defer-driven' is set to ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
988 (if (memq lazy-lock-defer-driven '(nil t))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
989 (princ lazy-lock-defer-driven)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
990 (princ "`")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
991 (princ lazy-lock-defer-driven)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
992 (princ "'"))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
993 (princ ".\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
994 (princ "This variable is now called `lazy-lock-defer-on-scrolling',\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
995 (princ "so instead use the form:\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
996 (princ " (setq lazy-lock-defer-on-scrolling ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
997 (unless (memq lazy-lock-defer-driven '(nil t))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
998 (princ "'"))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
999 (princ lazy-lock-defer-driven)
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
1000 (princ ")\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
1001 (princ "in your ~/.emacs. ")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
1002 (princ "The above form has been evaluated for this editor session,\n")
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
1003 (princ "but you should change your ~/.emacs now."))
f4429e6fe33c (a) split lazy-lock-defer-time into lazy-lock-defer-time and lazy-lock-defer-on-the-fly, (b) add lazy-lock-defer-on-scrolling, (c) use these to choose one of lazy-lock-defer-line-after-change, lazy-lock-defer-rest-after-change, lazy-lock-fontify-line-after-change, lazy-lock-fontify-rest-after-change to add to after-change-functions, (d) use with-current-buffer rather than save-excursion, (e) avoid integer overflow in lazy-lock-percent-fontified.
Simon Marshall <simon@gnu.org>
parents: 15499
diff changeset
1004 (setq lazy-lock-defer-on-scrolling lazy-lock-defer-driven))
15461
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 ;; Possibly absent.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (unless (boundp 'font-lock-inhibit-thing-lock)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 ;; Font Lock mode uses this to direct Lazy and Fast Lock modes to stay off.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 (defvar font-lock-inhibit-thing-lock nil
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 "List of Font Lock mode related modes that should not be turned on."))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 (unless (fboundp 'font-lock-value-in-major-mode)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 (defun font-lock-value-in-major-mode (alist)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 ;; Return value in ALIST for `major-mode'.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 (if (consp alist)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (cdr (or (assq major-mode alist) (assq t alist)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 alist)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 (unless (fboundp 'get-buffer-window-list)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 ;; We use this to get all windows showing a buffer we have to fontify.
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (defun get-buffer-window-list (buffer &optional minibuf frame)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 "Return windows currently displaying BUFFER, or nil if none."
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (let ((buffer (if (bufferp buffer) buffer (get-buffer buffer))) windows)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 (walk-windows (function (lambda (window)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (when (eq (window-buffer window) buffer)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 (push window windows))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 minibuf frame)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 windows)))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 ;; Install ourselves:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 (add-hook 'window-size-change-functions 'lazy-lock-fontify-after-resize)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (add-hook 'redisplay-end-trigger-functions 'lazy-lock-fontify-after-trigger)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 (unless (assq 'lazy-lock-mode minor-mode-alist)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (setq minor-mode-alist (append minor-mode-alist '((lazy-lock-mode nil)))))
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 ;; Provide ourselves:
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 (provide 'lazy-lock)
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042
a0dc879461b8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 ;;; lazy-lock.el ends here