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