comparison lisp/isearch.el @ 59340:eb4a4bdb4f0f

(lazy-highlight): Group renamed from isearch-lazy-... (lazy-highlight-cleanup, lazy-highlight-initial-delay) (lazy-highlight-interval, lazy-highlight-max-at-a-time) (lazy-highlight-face): Renamed from isearch-lazy-... Change all references to them.
author Richard M. Stallman <rms@gnu.org>
date Tue, 04 Jan 2005 02:21:55 +0000
parents 71d0bc7835fb
children b9bf38399e43
comparison
equal deleted inserted replaced
59339:174ad645cbbc 59340:eb4a4bdb4f0f
153 This allows you to resume earlier isearch sessions through the 153 This allows you to resume earlier isearch sessions through the
154 command history." 154 command history."
155 :type 'boolean 155 :type 'boolean
156 :group 'isearch) 156 :group 'isearch)
157 157
158 (defcustom isearch-lazy-highlight t
159 "*Controls the lazy-highlighting during incremental search.
160 When non-nil, all text in the buffer matching the current search
161 string is highlighted lazily (see `lazy-highlight-initial-delay'
162 and `lazy-highlight-interval')."
163 :type 'boolean
164 :group 'lazy-highlight
165 :group 'isearch)
166
158 (defvar isearch-mode-hook nil 167 (defvar isearch-mode-hook nil
159 "Function(s) to call after starting up an incremental search.") 168 "Function(s) to call after starting up an incremental search.")
160 169
161 (defvar isearch-mode-end-hook nil 170 (defvar isearch-mode-end-hook nil
162 "Function(s) to call after terminating an incremental search.") 171 "Function(s) to call after terminating an incremental search.")
197 "*Non-nil if advancing or retreating in the search ring should cause search. 206 "*Non-nil if advancing or retreating in the search ring should cause search.
198 Default value, nil, means edit the string instead." 207 Default value, nil, means edit the string instead."
199 :type 'boolean 208 :type 'boolean
200 :group 'isearch) 209 :group 'isearch)
201 210
211 ;;; Lazy highlight customization.
212 (defgroup lazy-highlight nil
213 "Lazy highlighting feature for matching strings."
214 :prefix "lazy-highlight-"
215 :version "21.1"
216 :group 'isearch
217 :group 'replace)
218
219 (defcustom lazy-highlight-cleanup t
220 "*Controls whether to remove extra highlighting after a search.
221 If this is nil, extra highlighting can be \"manually\" removed with
222 \\[isearch-lazy-highlight-cleanup]."
223 :type 'boolean
224 :group 'lazy-highlight)
225
226 (defcustom lazy-highlight-initial-delay 0.25
227 "*Seconds to wait before beginning to lazily highlight all matches."
228 :type 'number
229 :group 'lazy-highlight)
230
231 (defcustom lazy-highlight-interval 0 ; 0.0625
232 "*Seconds between lazily highlighting successive matches."
233 :type 'number
234 :group 'lazy-highlight)
235
236 (defcustom lazy-highlight-max-at-a-time 20
237 "*Maximum matches to highlight at a time (for `lazy-highlight').
238 Larger values may reduce isearch's responsiveness to user input;
239 smaller values make matches highlight slowly.
240 A value of nil means highlight all matches."
241 :type '(choice (const :tag "All" nil)
242 (integer :tag "Some"))
243 :group 'lazy-highlight)
244
245 (defface lazy-highlight-face
246 '((((class color) (min-colors 88) (background light))
247 (:background "paleturquoise"))
248 (((class color) (min-colors 88) (background dark))
249 (:background "paleturquoise4"))
250 (((class color) (min-colors 16))
251 (:background "turquoise3"))
252 (((class color) (min-colors 8))
253 (:background "turquoise3"))
254 (t (:underline t)))
255 "Face for lazy highlighting of matches other than the current one."
256 :group 'isearch-faces
257 :group 'lazy-highlight)
258
202 ;; Define isearch-mode keymap. 259 ;; Define isearch-mode keymap.
203 260
204 (defvar isearch-mode-map 261 (defvar isearch-mode-map
205 (let* ((i 0) 262 (let* ((i 0)
206 (map (make-keymap))) 263 (map (make-keymap)))
675 ;; If NOPUSH is non-nil, we don't push the string on the search ring. 732 ;; If NOPUSH is non-nil, we don't push the string on the search ring.
676 (setq overriding-terminal-local-map nil) 733 (setq overriding-terminal-local-map nil)
677 ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs 734 ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs
678 (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout) 735 (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
679 (isearch-dehighlight t) 736 (isearch-dehighlight t)
680 (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) 737 (isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
681 (let ((found-start (window-start (selected-window))) 738 (let ((found-start (window-start (selected-window)))
682 (found-point (point))) 739 (found-point (point)))
683 (if isearch-window-configuration 740 (if isearch-window-configuration
684 (set-window-configuration isearch-window-configuration)) 741 (set-window-configuration isearch-window-configuration))
685 742
2225 ;; - the direction of the current search is expected to be given by 2282 ;; - the direction of the current search is expected to be given by
2226 ;; `isearch-forward'; 2283 ;; `isearch-forward';
2227 ;; - the variable `isearch-invalid-regexp' is expected to be true 2284 ;; - the variable `isearch-invalid-regexp' is expected to be true
2228 ;; iff `isearch-string' is an invalid regexp. 2285 ;; iff `isearch-string' is an invalid regexp.
2229 2286
2230 (defgroup isearch-lazy-highlight nil
2231 "Lazy highlighting feature for incremental search."
2232 :prefix "isearch-lazy-highlight-"
2233 :version "21.1"
2234 :group 'isearch)
2235
2236 (defcustom isearch-lazy-highlight t
2237 "*Controls the lazy-highlighting during incremental searches.
2238 When non-nil, all text in the buffer matching the current search
2239 string is highlighted lazily (see `isearch-lazy-highlight-initial-delay'
2240 and `isearch-lazy-highlight-interval')."
2241 :type 'boolean
2242 :group 'isearch-lazy-highlight)
2243
2244 (defcustom isearch-lazy-highlight-cleanup t
2245 "*Controls whether to remove extra highlighting after a search.
2246 If this is nil, extra highlighting can be \"manually\" removed with
2247 \\[isearch-lazy-highlight-cleanup]."
2248 :type 'boolean
2249 :group 'isearch-lazy-highlight)
2250
2251 (defcustom isearch-lazy-highlight-initial-delay 0.25
2252 "*Seconds to wait before beginning to lazily highlight all matches."
2253 :type 'number
2254 :group 'isearch-lazy-highlight)
2255
2256 (defcustom isearch-lazy-highlight-interval 0 ; 0.0625
2257 "*Seconds between lazily highlighting successive matches."
2258 :type 'number
2259 :group 'isearch-lazy-highlight)
2260
2261 (defcustom isearch-lazy-highlight-max-at-a-time 20
2262 "*Maximum matches to highlight at a time (for `isearch-lazy-highlight').
2263 Larger values may reduce isearch's responsiveness to user input;
2264 smaller values make matches highlight slowly.
2265 A value of nil means highlight all matches."
2266 :type '(choice (const :tag "All" nil)
2267 (integer :tag "Some"))
2268 :group 'isearch-lazy-highlight)
2269
2270 (defgroup isearch-faces nil 2287 (defgroup isearch-faces nil
2271 "Lazy highlighting feature for incremental search." 2288 "Lazy highlighting feature for incremental search."
2272 :version "21.1" 2289 :version "21.1"
2273 :group 'isearch) 2290 :group 'isearch)
2274 2291
2286 (t (:inverse-video t))) 2303 (t (:inverse-video t)))
2287 "Face for highlighting Isearch matches." 2304 "Face for highlighting Isearch matches."
2288 :group 'isearch-faces) 2305 :group 'isearch-faces)
2289 (defvar isearch 'isearch) 2306 (defvar isearch 'isearch)
2290 2307
2291 (defface isearch-lazy-highlight-face 2308 (defvar isearch-lazy-highlight-face 'lazy-highlight-face)
2292 '((((class color) (min-colors 88) (background light))
2293 (:background "paleturquoise"))
2294 (((class color) (min-colors 88) (background dark))
2295 (:background "paleturquoise4"))
2296 (((class color) (min-colors 16))
2297 (:background "turquoise3"))
2298 (((class color) (min-colors 8))
2299 (:background "turquoise3"))
2300 (t (:underline t)))
2301 "Face for lazy highlighting of Isearch matches other than the current one."
2302 :group 'isearch-faces)
2303 (defvar isearch-lazy-highlight-face 'isearch-lazy-highlight-face)
2304 2309
2305 (defvar isearch-lazy-highlight-overlays nil) 2310 (defvar isearch-lazy-highlight-overlays nil)
2306 (defvar isearch-lazy-highlight-wrapped nil) 2311 (defvar isearch-lazy-highlight-wrapped nil)
2307 (defvar isearch-lazy-highlight-start nil) 2312 (defvar isearch-lazy-highlight-start nil)
2308 (defvar isearch-lazy-highlight-end nil) 2313 (defvar isearch-lazy-highlight-end nil)
2314 (defvar isearch-lazy-highlight-case-fold-search nil) 2319 (defvar isearch-lazy-highlight-case-fold-search nil)
2315 (defvar isearch-lazy-highlight-regexp nil) 2320 (defvar isearch-lazy-highlight-regexp nil)
2316 2321
2317 (defun isearch-lazy-highlight-cleanup (&optional force) 2322 (defun isearch-lazy-highlight-cleanup (&optional force)
2318 "Stop lazy highlighting and remove extra highlighting from current buffer. 2323 "Stop lazy highlighting and remove extra highlighting from current buffer.
2319 FORCE non-nil means do it whether or not `isearch-lazy-highlight-cleanup' 2324 FORCE non-nil means do it whether or not `lazy-highlight-cleanup'
2320 is nil. This function is called when exiting an incremental search if 2325 is nil. This function is called when exiting an incremental search if
2321 `isearch-lazy-highlight-cleanup' is non-nil." 2326 `lazy-highlight-cleanup' is non-nil."
2322 (interactive '(t)) 2327 (interactive '(t))
2323 (if (or force isearch-lazy-highlight-cleanup) 2328 (if (or force lazy-highlight-cleanup)
2324 (while isearch-lazy-highlight-overlays 2329 (while isearch-lazy-highlight-overlays
2325 (delete-overlay (car isearch-lazy-highlight-overlays)) 2330 (delete-overlay (car isearch-lazy-highlight-overlays))
2326 (setq isearch-lazy-highlight-overlays 2331 (setq isearch-lazy-highlight-overlays
2327 (cdr isearch-lazy-highlight-overlays)))) 2332 (cdr isearch-lazy-highlight-overlays))))
2328 (when isearch-lazy-highlight-timer 2333 (when isearch-lazy-highlight-timer
2329 (cancel-timer isearch-lazy-highlight-timer) 2334 (cancel-timer isearch-lazy-highlight-timer)
2330 (setq isearch-lazy-highlight-timer nil))) 2335 (setq isearch-lazy-highlight-timer nil)))
2331 2336
2332 (defun isearch-lazy-highlight-new-loop () 2337 (defun isearch-lazy-highlight-new-loop ()
2333 "Cleanup any previous `isearch-lazy-highlight' loop and begin a new one. 2338 "Cleanup any previous `lazy-highlight' loop and begin a new one.
2334 This happens when `isearch-update' is invoked (which can cause the 2339 This happens when `isearch-update' is invoked (which can cause the
2335 search string to change or the window to scroll)." 2340 search string to change or the window to scroll)."
2336 (when (and (null executing-kbd-macro) 2341 (when (and (null executing-kbd-macro)
2337 (sit-for 0) ;make sure (window-start) is credible 2342 (sit-for 0) ;make sure (window-start) is credible
2338 (or (not (equal isearch-string 2343 (or (not (equal isearch-string
2359 isearch-lazy-highlight-case-fold-search isearch-case-fold-search 2364 isearch-lazy-highlight-case-fold-search isearch-case-fold-search
2360 isearch-lazy-highlight-regexp isearch-regexp 2365 isearch-lazy-highlight-regexp isearch-regexp
2361 isearch-lazy-highlight-wrapped nil) 2366 isearch-lazy-highlight-wrapped nil)
2362 (unless (equal isearch-string "") 2367 (unless (equal isearch-string "")
2363 (setq isearch-lazy-highlight-timer 2368 (setq isearch-lazy-highlight-timer
2364 (run-with-idle-timer isearch-lazy-highlight-initial-delay nil 2369 (run-with-idle-timer lazy-highlight-initial-delay nil
2365 'isearch-lazy-highlight-update)))))) 2370 'isearch-lazy-highlight-update))))))
2366 2371
2367 (defun isearch-lazy-highlight-search () 2372 (defun isearch-lazy-highlight-search ()
2368 "Search ahead for the next or previous match, for lazy highlighting. 2373 "Search ahead for the next or previous match, for lazy highlighting.
2369 Attempt to do the search exactly the way the pending isearch would." 2374 Attempt to do the search exactly the way the pending isearch would."
2380 (window-start))) 2385 (window-start)))
2381 t))) 2386 t)))
2382 2387
2383 (defun isearch-lazy-highlight-update () 2388 (defun isearch-lazy-highlight-update ()
2384 "Update highlighting of other matches for current search." 2389 "Update highlighting of other matches for current search."
2385 (let ((max isearch-lazy-highlight-max-at-a-time) 2390 (let ((max lazy-highlight-max-at-a-time)
2386 (looping t) 2391 (looping t)
2387 nomore) 2392 nomore)
2388 (with-local-quit 2393 (with-local-quit
2389 (save-selected-window 2394 (save-selected-window
2390 (if (and (window-live-p isearch-lazy-highlight-window) 2395 (if (and (window-live-p isearch-lazy-highlight-window)