annotate lisp/packages/lazy-lock.el @ 28:1917ad0d78d7 r19-15b97

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