annotate lisp/packages/lazy-lock.el @ 193:f53b5ca2e663 r20-3b23

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