aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2005-01-11 23:03:01 +0000
committerJuri Linkov2005-01-11 23:03:01 +0000
commitbca92193e42e31279529e2601a23bc7ad5523485 (patch)
tree7ffc480a174dd3c9fbd2b7e13cca304222e701d1
parent6daf3e15717468c2a8e9147869dbb58a2b30af8f (diff)
downloademacs-bca92193e42e31279529e2601a23bc7ad5523485.tar.gz
emacs-bca92193e42e31279529e2601a23bc7ad5523485.zip
(search-highlight, isearch, isearch-lazy-highlight):
Bring together isearch highlight related options. (lazy-highlight): Replace group `replace' by `matching'. (lazy-highlight-cleanup, lazy-highlight-initial-delay) (lazy-highlight-interval, lazy-highlight-max-at-a-time) (lazy-highlight): Add aliases to old names isearch-lazy-highlight-... and declare them obsolete. (lazy-highlight-face): Rename from isearch-lazy-highlight-face. (isearch-faces): Remove defgroup. (isearch-overlay, isearch-highlight, isearch-dehighlight): Move isearch highlighting code closer to lazy highlighting code.
-rw-r--r--lisp/isearch.el129
1 files changed, 67 insertions, 62 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 3867a6d42d1..6aae4b32533 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -120,11 +120,6 @@ a tab, a carriage return (control-M), a newline, and `]+'."
120 :type 'regexp 120 :type 'regexp
121 :group 'isearch) 121 :group 'isearch)
122 122
123(defcustom search-highlight t
124 "*Non-nil means incremental search highlights the current match."
125 :type 'boolean
126 :group 'isearch)
127
128(defcustom search-invisible 'open 123(defcustom search-invisible 'open
129 "If t incremental search can match hidden text. 124 "If t incremental search can match hidden text.
130nil means don't match invisible text. 125nil means don't match invisible text.
@@ -155,15 +150,6 @@ command history."
155 :type 'boolean 150 :type 'boolean
156 :group 'isearch) 151 :group 'isearch)
157 152
158(defcustom isearch-lazy-highlight t
159 "*Controls the lazy-highlighting during incremental search.
160When non-nil, all text in the buffer matching the current search
161string is highlighted lazily (see `lazy-highlight-initial-delay'
162and `lazy-highlight-interval')."
163 :type 'boolean
164 :group 'lazy-highlight
165 :group 'isearch)
166
167(defvar isearch-mode-hook nil 153(defvar isearch-mode-hook nil
168 "Function(s) to call after starting up an incremental search.") 154 "Function(s) to call after starting up an incremental search.")
169 155
@@ -208,13 +194,46 @@ Default value, nil, means edit the string instead."
208 :type 'boolean 194 :type 'boolean
209 :group 'isearch) 195 :group 'isearch)
210 196
197;;; isearch highlight customization.
198
199(defcustom search-highlight t
200 "*Non-nil means incremental search highlights the current match."
201 :type 'boolean
202 :group 'isearch)
203
204(defface isearch
205 '((((class color) (min-colors 88) (background light))
206 ;; The background must not be too dark, for that means
207 ;; the character is hard to see when the cursor is there.
208 (:background "magenta2" :foreground "lightskyblue1"))
209 (((class color) (min-colors 88) (background dark))
210 (:background "palevioletred2" :foreground "brown4"))
211 (((class color) (min-colors 16))
212 (:background "magenta4" :foreground "cyan1"))
213 (((class color) (min-colors 8))
214 (:background "magenta4" :foreground "cyan1"))
215 (t (:inverse-video t)))
216 "Face for highlighting Isearch matches."
217 :group 'isearch)
218(defvar isearch 'isearch)
219
220(defcustom isearch-lazy-highlight t
221 "*Controls the lazy-highlighting during incremental search.
222When non-nil, all text in the buffer matching the current search
223string is highlighted lazily (see `lazy-highlight-initial-delay'
224and `lazy-highlight-interval')."
225 :type 'boolean
226 :group 'lazy-highlight
227 :group 'isearch)
228
211;;; Lazy highlight customization. 229;;; Lazy highlight customization.
230
212(defgroup lazy-highlight nil 231(defgroup lazy-highlight nil
213 "Lazy highlighting feature for matching strings." 232 "Lazy highlighting feature for matching strings."
214 :prefix "lazy-highlight-" 233 :prefix "lazy-highlight-"
215 :version "21.1" 234 :version "21.1"
216 :group 'isearch 235 :group 'isearch
217 :group 'replace) 236 :group 'matching)
218 237
219(defcustom lazy-highlight-cleanup t 238(defcustom lazy-highlight-cleanup t
220 "*Controls whether to remove extra highlighting after a search. 239 "*Controls whether to remove extra highlighting after a search.
@@ -222,16 +241,22 @@ If this is nil, extra highlighting can be \"manually\" removed with
222\\[isearch-lazy-highlight-cleanup]." 241\\[isearch-lazy-highlight-cleanup]."
223 :type 'boolean 242 :type 'boolean
224 :group 'lazy-highlight) 243 :group 'lazy-highlight)
244(defvaralias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
245(make-obsolete-variable 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
225 246
226(defcustom lazy-highlight-initial-delay 0.25 247(defcustom lazy-highlight-initial-delay 0.25
227 "*Seconds to wait before beginning to lazily highlight all matches." 248 "*Seconds to wait before beginning to lazily highlight all matches."
228 :type 'number 249 :type 'number
229 :group 'lazy-highlight) 250 :group 'lazy-highlight)
251(defvaralias 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
252(make-obsolete-variable 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
230 253
231(defcustom lazy-highlight-interval 0 ; 0.0625 254(defcustom lazy-highlight-interval 0 ; 0.0625
232 "*Seconds between lazily highlighting successive matches." 255 "*Seconds between lazily highlighting successive matches."
233 :type 'number 256 :type 'number
234 :group 'lazy-highlight) 257 :group 'lazy-highlight)
258(defvaralias 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
259(make-obsolete-variable 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
235 260
236(defcustom lazy-highlight-max-at-a-time 20 261(defcustom lazy-highlight-max-at-a-time 20
237 "*Maximum matches to highlight at a time (for `lazy-highlight'). 262 "*Maximum matches to highlight at a time (for `lazy-highlight').
@@ -241,6 +266,8 @@ A value of nil means highlight all matches."
241 :type '(choice (const :tag "All" nil) 266 :type '(choice (const :tag "All" nil)
242 (integer :tag "Some")) 267 (integer :tag "Some"))
243 :group 'lazy-highlight) 268 :group 'lazy-highlight)
269(defvaralias 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
270(make-obsolete-variable 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
244 271
245(defface lazy-highlight 272(defface lazy-highlight
246 '((((class color) (min-colors 88) (background light)) 273 '((((class color) (min-colors 88) (background light))
@@ -253,8 +280,11 @@ A value of nil means highlight all matches."
253 (:background "turquoise3")) 280 (:background "turquoise3"))
254 (t (:underline t))) 281 (t (:underline t)))
255 "Face for lazy highlighting of matches other than the current one." 282 "Face for lazy highlighting of matches other than the current one."
256 :group 'isearch-faces
257 :group 'lazy-highlight) 283 :group 'lazy-highlight)
284(put 'isearch-lazy-highlight-face 'face-alias 'lazy-highlight)
285(defvar lazy-highlight-face 'lazy-highlight)
286(defvaralias 'isearch-lazy-highlight-face 'lazy-highlight-face)
287(make-obsolete-variable 'isearch-lazy-highlight-face 'lazy-highlight-face)
258 288
259;; Define isearch-mode keymap. 289;; Define isearch-mode keymap.
260 290
@@ -2203,31 +2233,8 @@ Can be changed via `isearch-search-fun-function' for special needs."
2203 (setq isearch-hidden t))))))) 2233 (setq isearch-hidden t)))))))
2204 2234
2205 2235
2206;; Highlighting
2207
2208(defvar isearch-overlay nil)
2209
2210(defun isearch-highlight (beg end)
2211 (unless (null search-highlight)
2212 (cond (isearch-overlay
2213 ;; Overlay already exists, just move it.
2214 (move-overlay isearch-overlay beg end (current-buffer)))
2215
2216 (t
2217 ;; Overlay doesn't exist, create it.
2218 (setq isearch-overlay (make-overlay beg end))
2219 (overlay-put isearch-overlay 'face isearch)
2220 (overlay-put isearch-overlay 'priority 1) ;higher than lazy overlays
2221 ))))
2222
2223(defun isearch-dehighlight ()
2224 (when isearch-overlay
2225 (delete-overlay isearch-overlay)))
2226
2227
2228;; General utilities 2236;; General utilities
2229 2237
2230
2231(defun isearch-no-upper-case-p (string regexp-flag) 2238(defun isearch-no-upper-case-p (string regexp-flag)
2232 "Return t if there are no upper case chars in STRING. 2239 "Return t if there are no upper case chars in STRING.
2233If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\') 2240If REGEXP-FLAG is non-nil, disregard letters preceded by `\\' (but not `\\\\')
@@ -2259,6 +2266,27 @@ since they have special meaning in a regexp."
2259 (append char-or-events unread-command-events))) 2266 (append char-or-events unread-command-events)))
2260 2267
2261 2268
2269;; Highlighting
2270
2271(defvar isearch-overlay nil)
2272
2273(defun isearch-highlight (beg end)
2274 (unless (null search-highlight)
2275 (cond (isearch-overlay
2276 ;; Overlay already exists, just move it.
2277 (move-overlay isearch-overlay beg end (current-buffer)))
2278
2279 (t
2280 ;; Overlay doesn't exist, create it.
2281 (setq isearch-overlay (make-overlay beg end))
2282 (overlay-put isearch-overlay 'face isearch)
2283 (overlay-put isearch-overlay 'priority 1) ;higher than lazy overlays
2284 ))))
2285
2286(defun isearch-dehighlight ()
2287 (when isearch-overlay
2288 (delete-overlay isearch-overlay)))
2289
2262;; isearch-lazy-highlight feature 2290;; isearch-lazy-highlight feature
2263;; by Bob Glickstein <http://www.zanshin.com/~bobg/> 2291;; by Bob Glickstein <http://www.zanshin.com/~bobg/>
2264 2292
@@ -2284,29 +2312,6 @@ since they have special meaning in a regexp."
2284;; - the variable `isearch-invalid-regexp' is expected to be true 2312;; - the variable `isearch-invalid-regexp' is expected to be true
2285;; iff `isearch-string' is an invalid regexp. 2313;; iff `isearch-string' is an invalid regexp.
2286 2314
2287(defgroup isearch-faces nil
2288 "Lazy highlighting feature for incremental search."
2289 :version "21.1"
2290 :group 'isearch)
2291
2292(defface isearch
2293 '((((class color) (min-colors 88) (background light))
2294 ;; The background must not be too dark, for that means
2295 ;; the character is hard to see when the cursor is there.
2296 (:background "magenta2" :foreground "lightskyblue1"))
2297 (((class color) (min-colors 88) (background dark))
2298 (:background "palevioletred2" :foreground "brown4"))
2299 (((class color) (min-colors 16))
2300 (:background "magenta4" :foreground "cyan1"))
2301 (((class color) (min-colors 8))
2302 (:background "magenta4" :foreground "cyan1"))
2303 (t (:inverse-video t)))
2304 "Face for highlighting Isearch matches."
2305 :group 'isearch-faces)
2306(defvar isearch 'isearch)
2307
2308(defvar isearch-lazy-highlight-face 'lazy-highlight)
2309
2310(defvar isearch-lazy-highlight-overlays nil) 2315(defvar isearch-lazy-highlight-overlays nil)
2311(defvar isearch-lazy-highlight-wrapped nil) 2316(defvar isearch-lazy-highlight-wrapped nil)
2312(defvar isearch-lazy-highlight-start nil) 2317(defvar isearch-lazy-highlight-start nil)