annotate lisp/packages/lazy-lock.el @ 12:bcdc7deadc19 r19-15b7

Import from CVS: tag r19-15b7
author cvs
date Mon, 13 Aug 2007 08:48:16 +0200
parents ac2d302a0011
children 4103f0995bd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; lazy-lock.el --- Lazy demand-driven fontification for fast Font Lock mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Simon Marshall <simon@gnu.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: faces files
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
7 ;; Version: 1.15
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; lazy-lock|Simon Marshall|simon@gnu.ai.mit.edu|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; Lazy Font Lock mode (with fast demand-driven fontification).|
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
12 ;; 13-Nov-95|1.15|~/modes/lazy-lock.el.Z|
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; The archive is archive.cis.ohio-state.edu in /pub/gnu/emacs/elisp-archive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Purpose:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; To make visiting buffers in `font-lock-mode' faster by making fontification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; be demand-driven and stealthy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Fontification only occurs when, and where, necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; See caveats and feedback below. See also the defer-lock and fast-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; packages. (But don't use lazy-lock.el and fast-lock.el at the same time!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Installation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; Put this file somewhere where Emacs can find it (i.e., in one of the paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; in your `load-path'), `byte-compile-file' it, and put in your ~/.emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; (autoload 'turn-on-lazy-lock "lazy-lock"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; "Unconditionally turn on Lazy Lock mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; (add-hook 'font-lock-mode-hook 'turn-on-lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; Start up a new Emacs and use font-lock as usual (except that you can use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; so-called "gaudier" fontification regexps on big files without frustration).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; In a buffer (which has `font-lock-mode' enabled) which is at least
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; `lazy-lock-minimum-size' characters long, only the visible portion of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; buffer will be fontified. Motion around the buffer will fontify those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; visible portions that were not previous fontified. If the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; `lazy-lock-hide-invisible' is non-nil, redisplay will be delayed until after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; fontification. Otherwise, text that has not yet been fontified is displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; in `lazy-lock-invisible-foreground'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; If stealth fontification is enabled, fontification will occur in invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; parts of the buffer after `lazy-lock-stealth-time' seconds of idle time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; Advanced Use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; You can also do fancy things with `advice'. For example, to fontify when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; dragging the scroll-bar in Emacs, you could put in your ~/.emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; (autoload 'lazy-lock-post-command-fontify-windows "lazy-lock")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; (defadvice scroll-bar-drag-1 (after fontify-window activate compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; (let ((lazy-lock-walk-windows nil) (lazy-lock-hide-invisible nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; (lazy-lock-post-command-fontify-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; Or to fontify when the Debugger pops up a source code window:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; (autoload 'lazy-lock-fontify-walk-windows "lazy-lock")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; (defadvice gud-display-line (after fontify-window activate compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; (let ((lazy-lock-walk-windows t) (lazy-lock-hide-invisible t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; (lazy-lock-fontify-walk-windows)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Scott Byer <byer@mv.us.adobe.com> suggested this to fontify the visible part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; of an insertion only:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; (defvar lazy-lock-insert-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; '(yank yank-pop clipboard-yank hilit-yank hilit-yank-pop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; mail-yank-original mouse-yank-at-click mouse-yank-secondary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; yank-rectangle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; "A list of insertion commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; (defadvice font-lock-after-change-function (around fontify-insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; activate compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; (if (or (not (memq this-command lazy-lock-insert-commands))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; (and (pos-visible-in-window-p beg) (pos-visible-in-window-p end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; ad-do-it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; (let ((this-command 'ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; (put-text-property beg end 'fontified nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; (lazy-lock-fontify-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; Let me know if you use any other `advice' and I'll put it here. Thanks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; These kinds of things with `advice' aren't done automatically because they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; cause large packages (advice.el plus bytecomp.el and friends) to be loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; Caveats:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; Lazy Lock mode does not work efficiently with Outline mode. This is because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; when in Outline mode, although text may be hidden (not visible in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; window), the text is visible to Emacs Lisp code (not surprisingly) and Lazy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; Lock fontifies it mercilessly. Hopefully this will be fixed one day.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Lazy Lock mode does not fontify windows as they appear:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; 1. With `query-replace' or `ispell-*', as Lazy Lock only knows about point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; motion after the command exits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; 2. When displayed by gud.el (the Grand Unified Debugger), as they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; displayed via a process sentinel. See `Advanced Use' above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; 3. In XEmacs 19.12, when the last command was invoked via a mouse event,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; because of a bug/feature in/of `sit-for'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; 4. In other random situations that I don't know about (yet).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; If you have `lazy-lock-hide-invisible' you may notice that redisplay occurs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; before fontification regardlessly. This is due to other packages sitting on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; `post-command-hook' and provoking redisplay. If you use these packages, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; can't use `lazy-lock-hide-invisible'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; If you have `lazy-lock-hide-invisible' and use scrollbar scrolling using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; Emacs 19, hidden text will not be fontified as it becomes visible. It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; expected that Emacs 19 will provide the necessary hooks in future, to solve
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; this problem and the problem above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; Unless otherwise stated, "Emacs 19.X" means versions up to and including X.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; In Emacs 19.25, one `window-start'/`window-end' bug means that if you open a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; file in another frame (such as via `find-tag-other-frame'), the whole buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; is fontified regardless. Upgrade!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; In Emacs 19.25, fontification by stealth is turned off because of a fatal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; bug in `previous-single-property-change'. Upgrade!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; In Emacs 19.28, if you see a message in the minibuffer of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; "Fontifying window... done. (Restarted in foo.c)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; it means the Garbage Collector has marked some (subsequently used) text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; properties. Lazy Lock attempts to recover the situation by restarting in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; that buffer. Unfortunately, that buffer will be left in a writable and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; modified state. Also, other windows may not be fontified when this happens.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; To reduce the frequency of this bug occuring, increase in your ~/.emacs the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; value of `gc-cons-threshold' to, say, 1Meg, e.g.:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; (setq gc-cons-threshold (* 1024 1024))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; The solution is to upgrade! (With thanks to Kevin Broadey for help here.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; For XEmacs 19.11 and Lucid Emacs 19.10 users, lazy-lock sort-of works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; There are bugs in text property and point/window primatives. Upgrade!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; Feedback:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Feedback is welcome.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; To submit a bug report (or make comments) please use the mechanism provided:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; M-x lazy-lock-submit-bug-report RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; History:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; 0.01--1.00:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; - Changed name from fore-lock to lazy-lock. Shame though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; - Dropped `advice'-wrapping completely. Ask me if you're interested in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; - Made `lazy-lock-mode' ignore `post-command-hook' and `buffer-file-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; - Made `lazy-lock-fontify-window' check `lazy-lock-mode' and `this-command'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; - Made `lazy-lock-fontify-window' redisplay via `sit-for'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; - Added `lazy-lock-minimum-size' to control `lazy-lock-mode'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; 1.00--1.01:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; - Added `lazy-lock-fontify-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; - Made `lazy-lock-fontify-window' ignore `lazy-lock-mode'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; - Made `lazy-lock-fontify-window' suspicious of `window-' favourites again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; - Added `lazy-lock-delay-commands' (idea from William G. Dubuque).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; - Added `lazy-lock-ignore-commands' for completeness.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; - Added `lazy-lock-continuity-time' for normal input delay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; 1.01--1.02:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; - Made `lazy-lock-fontify-window' cope with multiple unfontified regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; - Made `lazy-lock-mode' remove `fontified' properties if turned off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; - Made `lazy-lock-fontify-window' fontify by lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; - Added `lazy-lock-cache-position' buffer local to detect visibility change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; - Added `lazy-lock-post-command-hook' to do the waiting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; - Made `lazy-lock-fontify-window' just do the fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; - Made `lazy-lock-mode' append `lazy-lock-post-command-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; - Added `lazy-lock-walk-windows' to hack multi-window motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; - Made `lazy-lock-post-command-hook' `walk-windows' if variable is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; - Removed `lazy-lock-ignore-commands' since insertion may change window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; - Added `lazy-lock-fontify-stealthily' and `lazy-lock-stealth-time'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; - Made `lazy-lock-post-command-hook' use them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; 1.02--1.03:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; - Made `lazy-lock-fontify-stealthily' do `forward-line' not `previous-line'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; - Made `lazy-lock-fontify-stealthily' `move-to-window-line' first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; - Made `lazy-lock-fontify-stealthily' use `text-property-any' for region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; - Made `lazy-lock-post-command-hook' loop on `lazy-lock-fontify-stealthily'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; 1.03--1.04:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; - Made `lazy-lock-mode' reset `lazy-lock-cache-position'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; - Made `lazy-lock-post-command-hook' `widen' for `if' `text-property-any'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; - Made `lazy-lock-fontify-stealthily' return `text-property-any'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; - Added `lazy-lock-percent-fontified' for a/be-musement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; - Made `lazy-lock-post-command-hook' use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; - Made `lazy-lock-mode' use `make-local-hook' etc. if available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; - Made `lazy-lock-mode' use `before-revert-hook' and `after-revert-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; - Made `lazy-lock-post-command-hook' protect `deactivate-mark'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; - Adds `lazy-lock-post-command-hook' globally to `post-command-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; 1.04--1.05:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;; - Made `lazy-lock-mode' test `make-local-hook' not `emacs-minor-version'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; 1.05--1.06:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; - Added `lazy-lock-ignore-commands' for commands that leave no event but do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; - Made `lazy-lock-post-command-hook' check `lazy-lock-ignore-commands'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; 1.06--1.07:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; - Removed `before-revert-hook' and `after-revert-hook' use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; 1.07--1.08:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; - Added `lazy-lock-submit-bug-report'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; - Made `lazy-lock-post-command-hook' check `executing-macro'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; - Made it sort-of/almost work for XEmacs (help from Jonas Jarnestrom).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; - XEmacs: Fix `text-property-not-all' (fix based on fast-lock.el 3.05 fix).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; - XEmacs: Set `font-lock-no-comments' and alias `frame-parameters'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; - Made `byte-compile-warnings' omit `unresolved' on compilation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; - Made `lazy-lock-post-command-hook' protect `buffer-undo-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; - Moved `deactivate-mark' and `buffer-undo-list' protection to functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; - Added `lazy-lock-invisible-foreground' (idea from Boris Goldowsky).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; - XEmacs: Fix to use `text-property-not-all' t, not `text-property-any' nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; - Made `lazy-lock-percent-fontified' return `round' to an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; - XEmacs: Fix `text-property-any' (fix and work around for a bug elsewhere).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; - XEmacs: Fix `lazy-lock-submit-bug-report' for reporter.el & vm-window.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;; - XEmacs: Made `lazy-lock-fontify-window' loop `while' `<' not `/='.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; - Use `font-lock-after-change-function' to do the fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; 1.08--1.09:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; - Made `lazy-lock-post-command-hook' protect with `condition-case'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; - Made `lazy-lock-cache-start' to cache `window-start'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; - Made `lazy-lock-fontify-window' check and cache `lazy-lock-cache-start'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; - Renamed `lazy-lock-cache-position' to `lazy-lock-cache-end'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; - XEmacs: Fix for `font-lock-after-change-function'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; - Adds `lazy-lock-post-command-hook' globally to `window-setup-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; 1.09--1.10:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; - Made `buffer-file-name' be `let' to prevent supersession (Kevin Broadey).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; - Made `lazy-lock-submit-bug-report' `require' reporter (Ilya Zakharevich).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; - Made `lazy-lock-mode' and `turn-on-lazy-lock' succeed `autoload' cookies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; - Added `lazy-lock-fontify-walk-windows' for walking window fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; - Added `lazy-lock-fontify-walk-stealthily' for walking stealth.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; - Removed `move-to-window-line' from `lazy-lock-fontify-stealthily'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; - Made `lazy-lock-percent-fontified' use `truncate' rather than `round'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; - Added other `*-argument' to `lazy-lock-ignore-commands' (Kevin Broadey).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; - Made `lazy-lock-fontify-stealthily' not assume buffer is part `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; - Emacs: Fix for `font-lock-fontify-region'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; - Made `lazy-lock-post-command-hook' check for minibuffer (Kevin Broadey).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; - Added `lazy-lock-stealth-nice' for niceness during stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; - Added `lazy-lock-stealth-lines' for chunks of stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; 1.10--1.11: incorporated hack by Ben Wing from William Dubuque's fontifly.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; - Made `lazy-lock-fontify-stealthily' see a non `fontified' preceding line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; - XEmacs: Fix `text-property-any' and `text-property-not-all' (Ben Wing).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; - XEmacs: Fix `lazy-lock-continuity-time' (Ben Wing).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; - Added awful `lazy-lock-running-xemacs-p' (Ben Wing).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; - Made loading set `emacs-minor-version' if it's not bound.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; - Added `lazy-lock-hide-invisible' to control redisplay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; - Made `lazy-lock-post-command-hook' use it in `sit-for' (Ben Wing).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; - Made `lazy-lock-fontify-window' move relative to `end-of-line' if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; - Added `lazy-lock-fontify-region' so packages can ensure fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; - Made `lazy-lock-fontify-walk-stealthily' do stealth widening.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; - Made `lazy-lock-fontify-stealthily' always do adjacent preceding regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; - Added `lazy-lock-after-fontify-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; - XEmacs: Removed `font-lock-no-comments' incompatibility code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; - Removed `lazy-lock-delay-time' and `lazy-lock-delay-commands'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; - Removed `lazy-lock-post-command' and split the functionality.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; - Adds `lazy-lock-post-command-fontify-windows' on first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; - Adds `lazy-lock-post-command-fontify-stealthily' on last.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; - Made `lazy-lock-mode' ensure both first and last on `post-command-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; - Made `lazy-lock-mode' ensure `font-lock-mode' is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; - Wrap `lazy-lock-post-command-fontify-stealthily' for errors (David Karr).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; - Added `calcDigit-key' to `lazy-lock-ignore-commands' (Bob Glickstein).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; - Wrap `lazy-lock-running-xemacs-p' with `eval-and-compile' (Erik Naggum).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; - XEmacs: Fix use of `previous-single-property-change' (Jim Thompson).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; - XEmacs: Fix `next-single-property-change' fix for 19.11 (Jim Thompson).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; - Added `lazy-lock-post-resize-fontify-windows' to fontify on resizing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; - Adds globally to `window-size-change-functions'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; - Added `lazy-lock-post-setup-fontify-windows' to fontify after start up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; - Adds globally to `window-setup-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; - Made `lazy-lock-post-command-fontify-windows' check for `input-pending-p'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; - Made `save-selected-window' to restore the `selected-window'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; - Use `save-selected-window' rather than `save-window-excursion'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; 1.11--1.12:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; - Made `lazy-lock-post-command-fontify-windows' do `set-buffer' first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; - Made `lazy-lock-fontify-stealthily' respect narrowing before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; - Added `lazy-lock-post-setup-ediff-control-frame' for Ediff control frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; - Adds globally to `ediff-after-setup-control-frame-hooks'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; - Wrap `save-selected-window' with `save-excursion' for `current-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; 1.12--1.13:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; - XEmacs: Add `lazy-lock-after-fontify-buffer' to the Font Lock hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; - Made `buffer-file-truename' also wrapped for supersession (Rick Sladkey).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; - Made `font-lock-beginning-of-syntax-function' wrapped for fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; - Added `lazy-lock-stealth-verbose' (after harassment from Ben Wing).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; - XEmacs: Made `font-lock-verbose' wrapped for stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; 1.13--1.14:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; - Wrap `lazy-lock-colour-invisible' for `set-face-foreground' (Jari Aalto).
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
305 ;; 1.14--1.15:
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
306 ;; - Made `lazy-lock-post-command-setup'; may add to `post-command-idle-hook'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; Only `require' so `ediff-multiframe-setup-p' is expanded at compile time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (condition-case nil (require 'ediff) (file-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; Well, shouldn't Lazy Lock be as lazy as possible?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;(setq byte-compile-dynamic t byte-compile-dynamic-docstrings t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; Shut Emacs' byte-compiler up (cf. stop me getting mail from users).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setq byte-compile-warnings '(free-vars callargs redefine)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun lazy-lock-submit-bug-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "Submit via mail a bug report on lazy-lock.el."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((reporter-prompt-for-summary-p t))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
323 (reporter-submit-bug-report "simon@gnu.ai.mit.edu" "lazy-lock 1.15"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 '(lazy-lock-walk-windows lazy-lock-continuity-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 lazy-lock-stealth-time lazy-lock-stealth-nice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 lazy-lock-stealth-lines lazy-lock-stealth-verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 lazy-lock-hide-invisible lazy-lock-invisible-foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 lazy-lock-minimum-size lazy-lock-ignore-commands)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (concat "Hi Si.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 I want to report a bug. I've read the `Bugs' section of `Info' on Emacs, so I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 know how to make a clear and unambiguous report. To reproduce the bug:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 Start a fresh Emacs via `" invocation-name " -no-init-file -no-site-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 In the `*scratch*' buffer, evaluate:"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
338 ;; Let's define `emacs-minor-version' if no-one else has.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (if (not (boundp 'emacs-minor-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defconst emacs-minor-version
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
342 (save-match-data
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
343 (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
344 (string-to-int
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
345 (substring emacs-version (match-beginning 1) (match-end 1)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; Yuck, but we make so much use of this variable it's probably worth it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defconst lazy-lock-running-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (not (null (save-match-data (string-match "Lucid" emacs-version))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defvar lazy-lock-cache-start nil) ; for window fontifiction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defvar lazy-lock-cache-end nil) ; for window fontifiction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defvar lazy-lock-cache-continue nil) ; for stealth fontifiction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
356 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defvar lazy-lock-mode nil) ; for modeline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; User Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defvar lazy-lock-minimum-size (* 25 1024)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "*If non-nil, the minimum size for buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 Only buffers more than this can have demand-driven fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 If nil, means size is irrelevant.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defvar lazy-lock-walk-windows t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "*If non-nil, fontify windows other than the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 If `all-frames', fontify windows even on other frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 A non-nil value slows down redisplay.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; XEmacs 19.11 and below exercise a bug in the Xt event loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defvar lazy-lock-continuity-time
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
374 (if (or (not lazy-lock-running-xemacs-p) (> emacs-minor-version 11))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (featurep 'lisp-float-type) 0.001 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "*Time in seconds to delay before normal window fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 Window fontification occurs if there is no input within this time.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; `previous-single-property-change' at `point-min' up to Emacs 19.25 is fatal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; `text-property-any', `text-property-not-all' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; `next-single-property-change' up to XEmacs 19.11 are too broke.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defvar lazy-lock-stealth-time
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
384 (if (> emacs-minor-version (if lazy-lock-running-xemacs-p 11 25)) 30)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "*Time in seconds to delay before beginning stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Stealth fontification occurs if there is no input within this time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 If nil, means no fontification by stealth.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defvar lazy-lock-stealth-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (cond ((boundp 'font-lock-maximum-decoration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if font-lock-maximum-decoration 75 150))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ((boundp 'font-lock-use-maximal-decoration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if font-lock-use-maximal-decoration 50 100))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 50))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "*If non-nil, the maximum size of a chunk of stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 Each iteration of stealth fontification can fontify this number of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 To speed up input response during stealth fontification, at the cost of stealth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 taking longer to fontify, you could reduce the value of this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 If nil, means use `window-height' for the maximum chunk size.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defvar lazy-lock-stealth-nice (if (featurep 'lisp-float-type) 0.125 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "*Time in seconds to pause during chunks of stealth fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 To reduce machine load during stealth fontification, at the cost of stealth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 taking longer to fontify, you could increase the value of this variable.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (defvar lazy-lock-stealth-verbose font-lock-verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 "*If non-nil, means stealth fontification should show status messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defvar lazy-lock-ignore-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; Standard commands...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 '(universal-argument digit-argument negative-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 isearch-other-control-char isearch-other-meta-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; And some resulting from non-standard packages...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (if (fboundp 'calc) '(calcDigit-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "A list of commands after which fontification should not occur.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 To speed up typing response, at the cost of Lazy Lock not fontifying when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 insertion causes scrolling, you could add `self-insert-command' to this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (defvar lazy-lock-hide-invisible lazy-lock-running-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 "*If non-nil, hide invisible text while it is fontified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 If non-nil, redisplay is delayed until after fontification occurs. If nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 text is shown (in `lazy-lock-invisible-foreground') while it is fontified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 A non-nil value slows down redisplay and can slow down cursor motion.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defvar lazy-lock-invisible-foreground "gray50"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "The foreground colour to use to display invisible text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 If nil, the default foreground is used. If t, the default background is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 If a string, it should be a colour to use (either its name or its RGB value).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Invisible text is momentarily seen (if `lazy-lock-hide-invisible' is nil) when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 scrolling into unfontified regions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; User Functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (defun lazy-lock-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 "Toggle Lazy Lock mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 With arg, turn Lazy Lock mode on if and only if arg is positive and the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 is at least `lazy-lock-minimum-size' characters long.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 When Lazy Lock mode is enabled, fontification is demand-driven and stealthy:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 - Fontification occurs in visible parts of buffers when necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 Occurs if there is no input after pausing for `lazy-lock-continuity-time'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 - Fontification occurs in invisible parts when Emacs has been idle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Occurs if there is no input after pausing for `lazy-lock-stealth-time'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 If `lazy-lock-hide-invisible' is non-nil, text is not displayed until it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 fontified, otherwise it is displayed in `lazy-lock-invisible-foreground'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 See also variables `lazy-lock-walk-windows' and `lazy-lock-ignore-commands' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 window (scroll) fontification, and `lazy-lock-stealth-lines',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 `lazy-lock-stealth-nice' and `lazy-lock-stealth-verbose' for stealth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 fontification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 Use \\[lazy-lock-submit-bug-report] to send bug reports or feedback."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (set (make-local-variable 'lazy-lock-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (and (<= (or lazy-lock-minimum-size 0) (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if arg (> (prefix-numeric-value arg) 0) (not lazy-lock-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (if (and lazy-lock-mode (not font-lock-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; Turned on `lazy-lock-mode' rather than using `font-lock-mode-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (add-hook 'font-lock-mode-hook 'turn-on-lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (font-lock-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Let's get down to business.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
469 (lazy-lock-post-command-setup)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (not lazy-lock-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (let ((modified (buffer-modified-p)) (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 deactivate-mark buffer-file-name buffer-file-truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (remove-text-properties (point-min) (point-max) '(fontified nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (or modified (set-buffer-modified-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (if (and (not lazy-lock-hide-invisible) lazy-lock-invisible-foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (lazy-lock-colour-invisible))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (set (make-local-variable 'lazy-lock-cache-start) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set (make-local-variable 'lazy-lock-cache-end) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (set (make-local-variable 'font-lock-fontified) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (defun turn-on-lazy-lock ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 "Unconditionally turn on Lazy Lock mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (lazy-lock-mode 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
487 (if (< emacs-minor-version (if lazy-lock-running-xemacs-p 12 29))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; We don't need this in Emacs 19.29 or XEmacs 19.12.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun lazy-lock-fontify-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "Fontify the current buffer where necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (lazy-lock-fontify-region (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; API Functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun lazy-lock-fontify-region (start end &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 "Fontify between START and END in BUFFER where necessary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (let ((lazy-lock-stealth-lines (count-lines start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (while (text-property-not-all start end 'fontified t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (lazy-lock-fontify-stealthily))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (defun lazy-lock-after-fontify-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; Mark the buffer as `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (let ((modified (buffer-modified-p)) (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 deactivate-mark buffer-file-name buffer-file-truename)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
511 (put-text-property (point-min) (point-max) 'fontified t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (or modified (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; Just a cleaner-looking way of coping with Emacs' and XEmacs' `sit-for'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (defmacro lazy-lock-sit-for (seconds &optional nodisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (if lazy-lock-running-xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (` (sit-for (, seconds) (, nodisp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (` (sit-for (, seconds) 0 (, nodisp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;; Using `save-window-excursion' provokes `window-size-change-functions'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; I prefer `save-walking-excursion', of course, because I have a warped mind.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (if (fboundp 'save-selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defmacro save-selected-window (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "Execute the BODY forms, restoring the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 Does not restore the value of point in the selected window, or anything else."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (` (let ((original-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (progn (,@ body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (select-window original-window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (put 'save-selected-window 'lisp-indent-function 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ;; Functions for hooks:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
536 (defun lazy-lock-post-command-fontify-windows ()
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
537 ;; We might not be where we think we are, since `post-command-hook' is run
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
538 ;; before `command_loop_1' makes sure we have the correct buffer selected.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
539 (set-buffer (window-buffer))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
540 ;; Do groovy things if (a) not in a macro, (b) no input pending, (c) got a
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
541 ;; real command, (d) not in the minibuffer, and (e) no input after waiting
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
542 ;; for `lazy-lock-continuity-time'.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
543 (if (or executing-kbd-macro
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
544 (input-pending-p)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
545 (memq this-command lazy-lock-ignore-commands)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
546 (window-minibuffer-p (selected-window)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq lazy-lock-cache-continue nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq lazy-lock-cache-continue t)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
549 (if (lazy-lock-sit-for lazy-lock-continuity-time lazy-lock-hide-invisible)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
550 ;; Do the visible parts of the buffer(s), i.e., the window(s).
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
551 (if (or (not lazy-lock-walk-windows)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
552 (and (eq lazy-lock-walk-windows t) (one-window-p t)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
553 (if lazy-lock-mode (condition-case nil (lazy-lock-fontify-window)))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
554 (lazy-lock-fontify-walk-windows)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (defun lazy-lock-post-command-fontify-stealthily ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; Do groovy things if (a-d) above, (e) not moving the mouse, and (f) no
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
558 ;; input after after waiting for `lazy-lock-stealth-time'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (if (and lazy-lock-cache-continue lazy-lock-stealth-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (condition-case data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (lazy-lock-sit-for lazy-lock-stealth-time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; Do the invisible parts of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (lazy-lock-fontify-walk-stealthily))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (error (message "Fontifying stealthily... %s" data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun lazy-lock-post-resize-fontify-windows (frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; Fontify all windows in FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (let ((lazy-lock-walk-windows t) executing-kbd-macro this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-selected-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (select-frame frame)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
572 (lazy-lock-post-command-fontify-windows)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (defun lazy-lock-post-setup-emacs-fontify-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; Fontify all windows in all frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (let ((lazy-lock-walk-windows 'all-frames) executing-kbd-macro this-command)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
577 (lazy-lock-post-command-fontify-windows)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (defun lazy-lock-post-setup-ediff-control-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; Fontify all windows in all frames when using the Ediff control frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (make-local-variable 'lazy-lock-walk-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (setq lazy-lock-walk-windows (if (ediff-multiframe-setup-p) 'all-frames t))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
583 (lazy-lock-post-command-setup))
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
584
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
585 (defun lazy-lock-post-command-setup ()
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
586 ;; Make sure that we're in the correct positions to avoid hassle.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
587 (remove-hook 'post-command-hook 'lazy-lock-post-command-fontify-windows)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
588 (remove-hook 'post-command-hook 'lazy-lock-post-command-fontify-stealthily)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
589 (add-hook 'post-command-hook 'lazy-lock-post-command-fontify-windows)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
590 (add-hook (if (boundp 'post-command-idle-hook)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
591 'post-command-idle-hook
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
592 'post-command-hook)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
593 'lazy-lock-post-command-fontify-stealthily t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; Functions for fontification:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun lazy-lock-fontify-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; Fontify the visible part of the buffer where necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (let ((ws (if lazy-lock-hide-invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (end-of-line) (forward-line (- (window-height))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (min (max (window-start) (point-min)) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (we (if lazy-lock-hide-invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (end-of-line) (forward-line (window-height)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (min (max (1- (window-end)) (point-min)) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (if (or (/= ws lazy-lock-cache-start) (/= we lazy-lock-cache-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; Find where we haven't `fontified' before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (let* ((start (or (text-property-not-all ws we 'fontified t) ws))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (end (or (text-property-any start we 'fontified t) we))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (modified (buffer-modified-p)) (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; We do the following to prevent: undo list addition; region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; highlight disappearance; supersession/locking checks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 deactivate-mark buffer-file-name buffer-file-truename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; Ensure Emacs 19.30 syntactic fontification is always correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 font-lock-beginning-of-syntax-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; Prevent XEmacs 19.13 during fontification from messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 font-lock-verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (while (< start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; Fontify and flag the region as `fontified'.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
622 (font-lock-after-change-function start end 0)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
623 (put-text-property start end 'fontified t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; Find the next region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (setq start (or (text-property-not-all ws we 'fontified t) ws)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 end (or (text-property-any start we 'fontified t) we)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq lazy-lock-cache-start ws lazy-lock-cache-end we)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (or modified (set-buffer-modified-p nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (defun lazy-lock-fontify-walk-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; Fontify windows in all required by walking through them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (save-selected-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (function (lambda (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if lazy-lock-mode (lazy-lock-fontify-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 'no-minibuf (eq lazy-lock-walk-windows 'all-frames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (wrong-type-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; Looks like the Emacs 19.28 Garbage Collection bug has hit town.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;; Completely remove all text properties and restart.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (set-text-properties (point-min) (point-max) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (turn-on-lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (lazy-lock-fontify-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (message "Fontifying window... done. (Restarted in %s)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (buffer-name)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defun lazy-lock-fontify-stealthily ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; Fontify an invisible part of the buffer where necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Move to the end in case the character to the left is not `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; Find where the next and previous regions not `fontified' begin and end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (let ((next (text-property-not-all (point) (point-max) 'fontified t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (prev (let ((p (previous-single-property-change (point) 'fontified)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (and p (> p (point-min)) p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (modified (buffer-modified-p)) (inhibit-read-only t) start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;; We do the following to prevent: undo list addition; region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;; highlight disappearance; supersession/locking checks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 deactivate-mark buffer-file-name buffer-file-truename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ;; Ensure Emacs 19.30 syntactic fontification is always correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 font-lock-beginning-of-syntax-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;; Prevent XEmacs 19.13 during fontification from spewing messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 font-lock-verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (cond ((and (null next) (null prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; Nothing has been `fontified' yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (beginning-of-line 1) (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (forward-line (or lazy-lock-stealth-lines (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ((or (null prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (and next (> (- (point) prev) (- next (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; The next region is the nearest not `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (goto-char next) (beginning-of-line 1) (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (forward-line (or lazy-lock-stealth-lines (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; Maybe the region is already partially `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (setq end (or (text-property-any next (point) 'fontified t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;; The previous region is the nearest not `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (goto-char prev) (forward-line 1) (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (forward-line (- (or lazy-lock-stealth-lines (window-height))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; Maybe the region is already partially `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (setq start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (or (previous-single-property-change prev 'fontified nil (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; Fontify and flag the region as `fontified'.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
689 (font-lock-after-change-function start end 0)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
690 (put-text-property start end 'fontified t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (or modified (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (defun lazy-lock-fontify-walk-stealthily ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; Fontify regions in all required buffers while there is no input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (let ((buffers (buffer-list)) (continue t) fontified message-log-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (while (and buffers continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (set-buffer (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (if (and lazy-lock-mode (lazy-lock-unfontified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;; Fontify regions in this buffer while there is no input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (let ((bufname (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (if (and lazy-lock-stealth-verbose (not fontified))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (message "Fontifying stealthily..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 ;; We `save-restriction' and `widen' around everything as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;; `lazy-lock-fontify-stealthily' doesn't and we `sit-for'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (save-restriction (widen) (lazy-lock-fontify-stealthily))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (while (and (lazy-lock-unfontified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (setq continue (lazy-lock-sit-for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 lazy-lock-stealth-nice)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (if lazy-lock-stealth-verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (message "Fontifying stealthily... %2d%% of %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (lazy-lock-percent-fontified) bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (save-restriction (widen) (lazy-lock-fontify-stealthily)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ;; Note that fontification occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (setq fontified t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (setq buffers (cdr buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if (and lazy-lock-stealth-verbose fontified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (message "Fontifying stealthily... %s." (if continue "done" "quit")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (defun lazy-lock-unfontified-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; Return non-nil if there is anywhere still to be `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (text-property-not-all (point-min) (point-max) 'fontified t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (defun lazy-lock-percent-fontified ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;; Return the percentage (of characters) of the buffer that are `fontified'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (let ((size 0) (start (point-min)) (max (point-max)) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (while (setq start (text-property-any start max 'fontified t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (setq end (or (text-property-not-all start max 'fontified t) max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 size (+ size (- end start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; Saying "99% done" is probably better than "100% done" when it isn't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (truncate (/ (* size 100.0) (buffer-size))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (defun lazy-lock-colour-invisible ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;; Fontify the current buffer in `lazy-lock-invisible-face'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (let ((face 'lazy-lock-invisible-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (fore (if (stringp lazy-lock-invisible-foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 lazy-lock-invisible-foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (cdr (assq 'background-color (frame-parameters)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (modified (buffer-modified-p)) (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 deactivate-mark buffer-file-name buffer-file-truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (make-face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (if (not (equal (face-foreground face) fore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (set-face-foreground face fore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (error (message "Unable to use foreground \"%s\"" fore))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
754 (put-text-property (point-min) (point-max) 'face face)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
755 (put-text-property (point-min) (point-max) 'fontified nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (or modified (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; Functions for Emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; This fix is for a number of bugs in the function in Emacs 19.28.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
761 (if (and (not lazy-lock-running-xemacs-p) (< emacs-minor-version 29))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (defun font-lock-fontify-region (start end &optional loudly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 "Put proper face on each string and comment between START and END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (let ((inhibit-read-only t) (buffer-undo-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 buffer-file-name buffer-file-truename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (modified (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (old-syntax (syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (synstart (if comment-start-skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (concat "\\s\"\\|" comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 "\\s\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (comstart (if comment-start-skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (concat "\\s<\\|" comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 "\\s<"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (startline (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 state prev prevstate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if font-lock-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (set-syntax-table font-lock-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ;; Find the state at the line-beginning before START.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if (eq startline font-lock-cache-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (setq state font-lock-cache-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ;; Find outermost containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; Find the state at STARTLINE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (while (< (point) startline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (setq state (parse-partial-sexp (point) startline 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (setq font-lock-cache-state state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 font-lock-cache-position (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; Now find the state precisely at START.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (setq state (parse-partial-sexp (point) start nil nil state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;; If the region starts inside a string, show the extent of it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (if (nth 3 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (while (and (re-search-forward "\\s\"" end 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (nth 3 (parse-partial-sexp beg (point) nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 state))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
804 (put-text-property beg (point) 'face font-lock-string-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (setq state (parse-partial-sexp beg (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 nil nil state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; Likewise for a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (if (or (nth 4 state) (nth 7 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (narrow-to-region (point-min) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (re-search-backward comstart (point-min) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (forward-comment 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; forward-comment skips all whitespace,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; so go back to the real end of the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (error (goto-char end))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
820 (put-text-property beg (point) 'face
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
821 font-lock-comment-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (setq state (parse-partial-sexp beg (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 nil nil state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; Find each interesting place between here and END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (while (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq prev (point) prevstate state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (re-search-forward synstart end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Clear out the fonts of what we skip over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (remove-text-properties prev (point) '(face nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; Verify the state at that place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; so we don't get fooled by \" or \;.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (setq state (parse-partial-sexp prev (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 nil nil state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (if (or (nth 4 state) (nth 7 state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; We found a real comment start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (let ((beg (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (narrow-to-region (point-min) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (forward-comment 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;; forward-comment skips all whitespace,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; so go back to the real end of the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (error (goto-char end))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
849 (put-text-property beg (point) 'face
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
850 font-lock-comment-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (setq state (parse-partial-sexp here (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 nil nil state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (if (nth 3 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (let ((beg (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (while (and (re-search-forward "\\s\"" end 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (nth 3 (parse-partial-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 here (point) nil nil state))))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
858 (put-text-property beg (point) 'face
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
859 font-lock-string-face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (setq state (parse-partial-sexp here (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 nil nil state))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; Make sure PREV is non-nil after the loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; only if it was set on the very last iteration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (setq prev nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (set-syntax-table old-syntax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (and prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (remove-text-properties prev end '(face nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (not modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (set-buffer-modified-p nil))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; Functions for XEmacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; These fix bugs in `text-property-any' and `text-property-not-all'. They may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;; not work perfectly in 19.11 and below because `next-single-property-change'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ;; is also broke and not easily fixable in Lisp.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
877 (if (and lazy-lock-running-xemacs-p (< emacs-minor-version 12))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; Loop through property changes until found. This fix includes a work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; around which prevents a bug in `window-start' causing a barf here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (defun text-property-any (start end prop value &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "Check text from START to END to see if PROP is ever `eq' to VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 If so, return the position of the first character whose PROP is `eq'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 to VALUE. Otherwise return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (let ((start (min start end)) (end (max start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (while (and start (not (eq (get-text-property start prop buffer) value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (setq start (next-single-property-change start prop buffer end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; No need to loop here; if it's not at START it's at the next change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; However, `next-single-property-change' sometimes returns LIMIT, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; `point-max', if no change is found and sometimes returns nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (defun text-property-not-all (start end prop value &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 "Check text from START to END to see if PROP is ever not `eq' to VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 If so, return the position of the first character whose PROP is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 `eq' to VALUE. Otherwise, return nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (if (not (eq value (get-text-property start prop buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (let ((next (next-single-property-change start prop buffer end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (end (or end (save-excursion (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (and next (< next end) next))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; XEmacs 19.11 function `font-lock-any-extents-p' looks for `text-prop' rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ;; than `face'. Since `font-lock-unfontify-region' only removes `face', and we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ;; have non-font-lock properties hanging about, `text-prop' never gets removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ;; Unfortunately `font-lock-any-extents-p' is inlined so we can't redefine it.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
907 (if (and lazy-lock-running-xemacs-p (< emacs-minor-version 12))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (add-hook 'font-lock-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (remove-hook 'after-change-functions 'font-lock-after-change-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (add-hook 'after-change-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (function (lambda (beg end old-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (let ((a-c-beg beg) (a-c-end end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; First set `text-prop' to nil for `font-lock-any-extents-p'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (goto-char end) (forward-line 1) (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (goto-char beg) (beginning-of-line) (setq beg (point))
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
918 (put-text-property beg end 'text-prop nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ;; Then do the real `font-lock-after-change-function'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (font-lock-after-change-function a-c-beg a-c-end old-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; Now set `fontified' to t to stop `lazy-lock-fontify-window'.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
922 (put-text-property beg end 'fontified t))))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
924 (if (and lazy-lock-running-xemacs-p (>= emacs-minor-version 12))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; XEmacs 19.12 font-lock.el's `font-lock-fontify-buffer' runs a hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (add-hook 'font-lock-after-fontify-buffer-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 'lazy-lock-after-fontify-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; Cope with the differences between Emacs and [LX]Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (or (fboundp 'frame-parameters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (defalias 'frame-parameters 'screen-parameters))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; Install ourselves:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; We don't install ourselves on `font-lock-mode-hook' as other packages can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;; used with font-lock.el, and lazy-lock.el should be dumpable without forcing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;; people to get lazy or making it difficult for people to use alternatives.
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
938
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
939 ;; After a command is run.
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
940 (lazy-lock-post-command-setup)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
941
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
942 ;; After some relevant event.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (add-hook 'window-setup-hook 'lazy-lock-post-setup-emacs-fontify-windows)
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 2
diff changeset
944 ;Not needed in XEmacs 19.15:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;(add-hook 'window-size-change-functions 'lazy-lock-post-resize-fontify-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; Package-specific.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (add-hook 'ediff-after-setup-control-frame-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 'lazy-lock-post-setup-ediff-control-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;; Might as well uninstall too. Package-local symbols would be nice...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (and (fboundp 'unintern) (unintern 'lazy-lock-running-xemacs-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (and (fboundp 'unintern) (unintern 'lazy-lock-sit-for))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; Maybe save on the modeline?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;;(setcdr (assq 'font-lock-mode minor-mode-alist) '(" Lazy"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;(or (assq 'lazy-lock-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ; (setq minor-mode-alist (cons '(lazy-lock-mode " Lazy") minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;; XEmacs change: do it the right way. This works with modeline mousing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (add-minor-mode 'lazy-lock-mode " Lazy")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; Provide ourselves:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (provide 'lazy-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;;; lazy-lock.el ends here