Mercurial > hg > xemacs-beta
comparison lisp/prim/isearch-mode.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | 0293115a14e9 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 ;; Incremental search minor mode. | |
2 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc. | |
3 | |
4 ;; LCD Archive Entry: | |
5 ;; isearch-mode|Daniel LaLiberte|liberte@cs.uiuc.edu | |
6 ;; |A minor mode replacement for isearch.el. | |
7 | |
8 ;; This file is part of XEmacs. | |
9 | |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | |
11 ;; under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; XEmacs is distributed in the hope that it will be useful, but | |
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 ;; General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Synched up with: Not synched with FSF. | |
25 | |
26 ;;;==================================================================== | |
27 ;; Instructions | |
28 | |
29 ;; Searching with isearch-mode.el should work just like isearch.el, | |
30 ;; except it is done in a temporary minor mode that terminates when | |
31 ;; you finish searching. | |
32 | |
33 ;; Semi-modal searching is supported, using a recursive edit. If | |
34 ;; isearching is started non-interactively by calling one of the | |
35 ;; isearch commands (e.g. (isearch-forward), but not like gnus does | |
36 ;; it: (call-interactively 'isearch-forward)), isearch-mode does not | |
37 ;; return until the search is completed. You should still be able | |
38 ;; switch buffers, so be careful not to get things confused. | |
39 | |
40 ;; The key bindings active within isearch-mode are defined below in | |
41 ;; `isearch-mode-map' which is given bindings close to the default | |
42 ;; characters of isearch.el for version 19. With `isearch-mode', | |
43 ;; however, you can bind multi-character keys and it should be easier | |
44 ;; to add new commands. One bug though: keys with meta-prefix cannot | |
45 ;; be longer than two chars. Also see minibuffer-local-isearch-map | |
46 ;; for bindings active during `isearch-edit-string'. | |
47 | |
48 ;; The search ring and completion commands automatically put you in | |
49 ;; the minibuffer to edit the string. This gives you a chance to | |
50 ;; modify the search string before executing the search. There are | |
51 ;; three commands to terminate the editing: C-s and C-r exit the | |
52 ;; minibuffer and search forward and reverse respectively, while C-m | |
53 ;; exits and does a nonincremental search. | |
54 | |
55 ;; Exiting immediately from isearch uses isearch-edit-string instead | |
56 ;; of nonincremental-search, if search-nonincremental-instead is non-nil. | |
57 ;; The name of this option should probably be changed if we decide to | |
58 ;; keep the behavior. One difference is that isearch-edit-string does | |
59 ;; not support word search yet; perhaps isearch-mode should support it | |
60 ;; even for incremental searches, but how? | |
61 | |
62 ;;;==================================================================== | |
63 ;;; Change History | |
64 | |
65 ;;; Header: /import/kaplan/kaplan/liberte/Isearch/RCS/isearch-mode.el,v 1.3 92/06/29 13:10:08 liberte Exp Locker: liberte | |
66 ;;; Log: isearch-mode.el,v | |
67 ;;; | |
68 ;;; 20-aug-92 Hacked by jwz for Lucid Emacs 19.3. | |
69 ;;; | |
70 ;;; Revision 1.3 92/06/29 13:10:08 liberte | |
71 ;;; Moved modal isearch-mode handling into isearch-mode. | |
72 ;;; Got rid of buffer-local isearch variables. | |
73 ;;; isearch-edit-string used by ring adjustments, completion, and | |
74 ;;; nonincremental searching. C-s and C-r are additional exit commands. | |
75 ;;; Renamed all regex to regexp. | |
76 ;;; Got rid of found-start and found-point globals. | |
77 ;;; Generalized handling of upper-case chars. | |
78 | |
79 ;;; Revision 1.2 92/05/27 11:33:57 liberte | |
80 ;;; Emacs version 19 has a search ring, which is supported here. | |
81 ;;; Other fixes found in the version 19 isearch are included here. | |
82 ;;; | |
83 ;;; Also see variables search-caps-disable-folding, | |
84 ;;; search-nonincremental-instead, search-whitespace-regexp, and | |
85 ;;; commands isearch-toggle-regexp, isearch-edit-string. | |
86 ;;; | |
87 ;;; semi-modal isearching is supported. | |
88 | |
89 ;;; Changes for 1.1 | |
90 ;;; 3/18/92 Fixed invalid-regexp. | |
91 ;;; 3/18/92 Fixed yanking in regexps. | |
92 | |
93 | |
94 (defun isearch-char-to-string (c) | |
95 (if (integerp c) | |
96 (make-string 1 c) | |
97 (make-string 1 (event-to-character c nil nil t)))) | |
98 | |
99 ;(defun isearch-text-char-description (c) | |
100 ; (isearch-char-to-string c)) | |
101 | |
102 (define-function 'isearch-text-char-description 'text-char-description) | |
103 | |
104 | |
105 ;;;========================================================================= | |
106 ;;; User-accessible variables | |
107 | |
108 (defvar search-last-string "" | |
109 "Last string search for by a search command. | |
110 This does not include direct calls to the primitive search functions, | |
111 and does not include searches that are aborted.") | |
112 | |
113 (defvar search-last-regexp "" | |
114 "Last string searched for by a regexp search command. | |
115 This does not include direct calls to the primitive search functions, | |
116 and does not include searches that are aborted.") | |
117 | |
118 (defconst search-exit-option t | |
119 "Non-nil means random control characters terminate incremental search.") | |
120 | |
121 (defvar search-slow-window-lines 1 | |
122 "*Number of lines in slow search display windows. | |
123 These are the short windows used during incremental search on slow terminals. | |
124 Negative means put the slow search window at the top (normally it's at bottom) | |
125 and the value is minus the number of lines.") | |
126 | |
127 (defconst search-slow-speed 1200 | |
128 "*Highest terminal speed at which to use \"slow\" style incremental search. | |
129 This is the style where a one-line window is created to show the line | |
130 that the search has reached.") | |
131 | |
132 (defvar search-caps-disable-folding t | |
133 "*If non-nil, upper case chars disable case fold searching. | |
134 This does not apply to \"yanked\" strings.") | |
135 | |
136 (defvar search-nonincremental-instead t | |
137 "*If non-nil, do a nonincremental search instead if exiting immediately.") | |
138 | |
139 (defconst search-whitespace-regexp "\\(\\s \\|[\n\r]\\)+" | |
140 "*If non-nil, regular expression to match a sequence of whitespace chars.") | |
141 | |
142 ;;;================================================================== | |
143 ;;; Search ring. | |
144 | |
145 (defvar search-ring nil | |
146 "List of search string sequences.") | |
147 (defvar regexp-search-ring nil | |
148 "List of regular expression search string sequences.") | |
149 | |
150 (defconst search-ring-max 16 | |
151 "*Maximum length of search ring before oldest elements are thrown away.") | |
152 (defconst regexp-search-ring-max 16 | |
153 "*Maximum length of regexp search ring before oldest elements are thrown away.") | |
154 | |
155 (defvar search-ring-yank-pointer nil | |
156 "The tail of the search ring whose car is the last thing searched for.") | |
157 (defvar regexp-search-ring-yank-pointer nil | |
158 "The tail of the regular expression search ring whose car is the last | |
159 thing searched for.") | |
160 | |
161 ;;;==================================================== | |
162 ;;; Define isearch-mode keymap. | |
163 | |
164 (defvar isearch-mode-map | |
165 (let ((map (make-keymap))) | |
166 (set-keymap-name map 'isearch-mode-map) | |
167 | |
168 ;; Bind all printing characters to `isearch-printing-char'. | |
169 ;; This isn't normally necessary, but if a printing character were | |
170 ;; bound to something other than self-insert-command in global-map, | |
171 ;; then it would terminate the search and be executed without this. | |
172 (let ((i 32) | |
173 (str (make-string 1 0))) | |
174 (while (< i 127) | |
175 (aset str 0 i) | |
176 (define-key map str 'isearch-printing-char) | |
177 (setq i (1+ i)))) | |
178 (define-key map "\t" 'isearch-printing-char) | |
179 | |
180 ;; Several non-printing chars change the searching behavior. | |
181 ;; | |
182 (define-key map "\C-s" 'isearch-repeat-forward) | |
183 (define-key map "\M-\C-s" 'isearch-repeat-forward) | |
184 (define-key map "\C-r" 'isearch-repeat-backward) | |
185 (define-key map "\177" 'isearch-delete-char) | |
186 (define-key map "\C-g" 'isearch-abort) | |
187 | |
188 (define-key map "\C-q" 'isearch-quote-char) | |
189 | |
190 (define-key map "\C-m" 'isearch-exit) | |
191 (define-key map "\C-j" 'isearch-printing-char) | |
192 (define-key map "\t" 'isearch-printing-char) | |
193 | |
194 (define-key map "\C-w" 'isearch-yank-word) | |
195 (define-key map "\C-y" 'isearch-yank-line) | |
196 | |
197 ;; Define keys for regexp chars * ? | | |
198 (define-key map "*" 'isearch-*-char) | |
199 (define-key map "?" 'isearch-*-char) | |
200 (define-key map "|" 'isearch-|-char) | |
201 | |
202 ;; Some bindings you may want to put in your isearch-mode-hook. | |
203 ;; Suggest some alternates... | |
204 ;; (define-key map "\C-t" 'isearch-toggle-regexp) | |
205 ;; (define-key map "\C-^" 'isearch-edit-string) | |
206 | |
207 ;; backspace deletes, but C-h is help. | |
208 (define-key map 'backspace 'isearch-delete-char) | |
209 (define-key map '(control h) 'isearch-mode-help) | |
210 | |
211 (define-key map "\M-n" 'isearch-ring-advance) | |
212 (define-key map "\M-p" 'isearch-ring-retreat) | |
213 (define-key map "\M- " 'isearch-whitespace-chars) | |
214 (define-key map "\M-\t" 'isearch-complete) | |
215 | |
216 (define-key map 'button2 'isearch-yank-x-selection) | |
217 | |
218 map) | |
219 "Keymap for isearch-mode.") | |
220 | |
221 (defvar minibuffer-local-isearch-map | |
222 (let ((map (make-sparse-keymap))) | |
223 ;; #### - this should also be minor-mode-ified | |
224 (set-keymap-parents map (list minibuffer-local-map)) | |
225 (set-keymap-name map 'minibuffer-local-isearch-map) | |
226 | |
227 ;;#### This should just arrange to use the usual Emacs minibuffer histories | |
228 (define-key map "\r" 'isearch-nonincremental-exit-minibuffer) | |
229 (define-key map "\M-n" 'isearch-ring-advance-edit) | |
230 (define-key map "\M-p" 'isearch-ring-retreat-edit) | |
231 (define-key map "\M-\t" 'isearch-complete-edit) | |
232 (define-key map "\C-s" 'isearch-forward-exit-minibuffer) | |
233 (define-key map "\C-r" 'isearch-reverse-exit-minibuffer) | |
234 map) | |
235 "Keymap for editing isearch strings in the minibuffer.") | |
236 | |
237 ;;;======================================================== | |
238 ;; Internal variables declared globally for byte-compiler. | |
239 ;; These are all bound locally while editing the search string. | |
240 | |
241 (defvar isearch-forward nil) ; Searching in the forward direction. | |
242 (defvar isearch-regexp nil) ; Searching for a regexp. | |
243 (defvar isearch-word nil) ; Searching for words. | |
244 | |
245 (defvar isearch-cmds nil) ; Stack of search status sets. | |
246 (defvar isearch-string "") ; The current search string. | |
247 (defvar isearch-message "") ; text-char-description version of isearch-string | |
248 | |
249 (defvar isearch-success t) ; Searching is currently successful. | |
250 (defvar isearch-invalid-regexp nil) ; Regexp not well formed. | |
251 (defvar isearch-other-end nil) ; Start (end) of match if forward (backward). | |
252 (defvar isearch-wrapped nil) ; Searching restarted from the top (bottom). | |
253 (defvar isearch-barrier 0) | |
254 (defvar isearch-buffer nil) ; the buffer we've frobbed the keymap of | |
255 | |
256 (defvar isearch-case-fold-search nil) | |
257 | |
258 (defvar isearch-adjusted nil) | |
259 (defvar isearch-slow-terminal-mode nil) | |
260 ;;; If t, using a small window. | |
261 (defvar isearch-small-window nil) | |
262 (defvar isearch-opoint 0) | |
263 ;;; The window configuration active at the beginning of the search. | |
264 (defvar isearch-window-configuration nil) | |
265 (defvar isearch-selected-frame nil) | |
266 | |
267 ;; Flag to indicate a yank occurred, so don't move the cursor. | |
268 (defvar isearch-yank-flag nil) | |
269 | |
270 ;;; A function to be called after each input character is processed. | |
271 ;;; (It is not called after characters that exit the search.) | |
272 ;;; It is only set from an optional argument to `isearch-mode'. | |
273 (defvar isearch-op-fun nil) | |
274 | |
275 ;;; Is isearch-mode in a recursive edit for modal searching. | |
276 (defvar isearch-recursive-edit nil) | |
277 | |
278 ;;; Should isearch be terminated after doing one search? | |
279 (defvar isearch-nonincremental nil) | |
280 | |
281 ;; New value of isearch-forward after isearch-edit-string. | |
282 (defvar isearch-new-forward nil) | |
283 | |
284 | |
285 (defvar isearch-mode-hook nil | |
286 "Function(s) to call after starting up an incremental search.") | |
287 | |
288 (defvar isearch-mode-end-hook nil | |
289 "Function(s) to call after terminating an incremental search.") | |
290 | |
291 ;;;============================================================== | |
292 ;; Minor-mode-alist changes - kind of redundant with the | |
293 ;; echo area, but if isearching in multiple windows, it can be useful. | |
294 | |
295 (add-minor-mode 'isearch-mode 'isearch-mode) | |
296 | |
297 (defvar isearch-mode nil) | |
298 (make-variable-buffer-local 'isearch-mode) | |
299 | |
300 ;;;=============================================================== | |
301 ;;; Entry points to isearch-mode. | |
302 ;;; These four functions should replace those in loaddefs.el | |
303 ;;; An alternative is to fset isearch-forward etc to isearch-mode, | |
304 ;;; and look at the last command to set the options accordingly. | |
305 | |
306 (defun isearch-forward (&optional regexp-p) | |
307 "Do incremental search forward. | |
308 With a prefix argument, do an incremental regular expression search instead. | |
309 \\<isearch-mode-map> | |
310 As you type characters, they add to the search string and are found. | |
311 The following non-printing keys are bound in `isearch-mode-map'. | |
312 | |
313 Type \\[isearch-delete-char] to cancel characters from end of search string. | |
314 Type \\[isearch-exit] to exit, leaving point at location found. | |
315 Type LFD (C-j) to match end of line. | |
316 Type \\[isearch-repeat-forward] to search again forward,\ | |
317 \\[isearch-repeat-backward] to search again backward. | |
318 Type \\[isearch-yank-word] to yank word from buffer onto end of search\ | |
319 string and search for it. | |
320 Type \\[isearch-yank-line] to yank rest of line onto end of search string\ | |
321 and search for it. | |
322 Type \\[isearch-quote-char] to quote control character to search for it. | |
323 Type \\[isearch-whitespace-chars] to match all whitespace chars in regexp. | |
324 \\[isearch-abort] while searching or when search has failed cancels input\ | |
325 back to what has | |
326 been found successfully. | |
327 \\[isearch-abort] when search is successful aborts and moves point to\ | |
328 starting point. | |
329 | |
330 Also supported is a search ring of the previous 16 search strings. | |
331 Type \\[isearch-ring-advance] to search for the next item in the search ring. | |
332 Type \\[isearch-ring-retreat] to search for the previous item in the search\ | |
333 ring. | |
334 Type \\[isearch-complete] to complete the search string using the search ring. | |
335 | |
336 The above keys are bound in the isearch-mode-map. To change the keys which | |
337 are special to isearch-mode, simply change the bindings in that map. | |
338 | |
339 Other control and meta characters terminate the search | |
340 and are then executed normally (depending on `search-exit-option'). | |
341 | |
342 If this function is called non-interactively, it does not return to | |
343 the calling function until the search is done. | |
344 | |
345 The bindings, more precisely: | |
346 \\{isearch-mode-map}" | |
347 | |
348 ;; Non-standard bindings | |
349 ;; Type \\[isearch-toggle-regexp] to toggle regular expression with normal searching. | |
350 ;; Type \\[isearch-edit-string] to edit the search string in the minibuffer. | |
351 ;; Terminate editing and return to incremental searching with CR. | |
352 | |
353 (interactive "P") | |
354 (isearch-mode t (not (null regexp-p)) nil (not (interactive-p)))) | |
355 | |
356 (defun isearch-forward-regexp () | |
357 "\ | |
358 Do incremental search forward for regular expression. | |
359 Like ordinary incremental search except that your input | |
360 is treated as a regexp. See \\[isearch-forward] for more info." | |
361 (interactive) | |
362 (isearch-mode t t nil (not (interactive-p)))) | |
363 | |
364 (defun isearch-backward (&optional regexp-p) | |
365 "\ | |
366 Do incremental search backward. | |
367 With a prefix argument, do an incremental regular expression search instead. | |
368 See \\[isearch-forward] for more information." | |
369 (interactive "P") | |
370 (isearch-mode nil (not (null regexp-p)) nil (not (interactive-p)))) | |
371 | |
372 (defun isearch-backward-regexp () | |
373 "\ | |
374 Do incremental search backward for regular expression. | |
375 Like ordinary incremental search except that your input | |
376 is treated as a regexp. See \\[isearch-forward] for more info." | |
377 (interactive) | |
378 (isearch-mode nil t nil (not (interactive-p)))) | |
379 | |
380 | |
381 (defun isearch-mode-help () | |
382 (interactive) | |
383 (describe-function 'isearch-forward) | |
384 (isearch-update)) | |
385 | |
386 | |
387 ;;;================================================================== | |
388 ;; isearch-mode only sets up incremental search for the minor mode. | |
389 ;; All the work is done by the isearch-mode commands. | |
390 | |
391 (defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p) | |
392 "Start isearch minor mode. Called by isearch-forward, etc." | |
393 | |
394 (if executing-kbd-macro (setq recursive-edit nil)) | |
395 | |
396 (let ((inhibit-quit t)) ; don't leave things in an inconsistent state... | |
397 | |
398 ;; Initialize global vars. | |
399 (setq isearch-buffer (current-buffer) | |
400 isearch-forward forward | |
401 isearch-regexp regexp | |
402 isearch-word word-p | |
403 isearch-op-fun op-fun | |
404 isearch-case-fold-search case-fold-search | |
405 isearch-string "" | |
406 isearch-message "" | |
407 isearch-cmds nil | |
408 isearch-success t | |
409 isearch-wrapped nil | |
410 isearch-barrier (point) | |
411 isearch-adjusted nil | |
412 isearch-yank-flag nil | |
413 isearch-invalid-regexp nil | |
414 isearch-slow-terminal-mode (and (<= (device-baud-rate) | |
415 search-slow-speed) | |
416 (> (window-height) | |
417 (* 4 search-slow-window-lines))) | |
418 isearch-other-end nil | |
419 isearch-small-window nil | |
420 | |
421 isearch-opoint (point) | |
422 isearch-window-configuration (current-window-configuration) | |
423 | |
424 ;; #### - don't do this statically: isearch-mode must be FIRST in | |
425 ;; the minor-mode-map-alist -- Stig | |
426 minor-mode-map-alist (cons (cons 'isearch-mode isearch-mode-map) | |
427 minor-mode-map-alist) | |
428 isearch-selected-frame (selected-frame) | |
429 | |
430 isearch-mode (gettext " Isearch") | |
431 ) | |
432 | |
433 ;; XEmacs change: without clearing the match data, sometimes old values | |
434 ;; of isearch-other-end get used. Don't ask me why... | |
435 (store-match-data nil) | |
436 | |
437 (add-hook 'pre-command-hook 'isearch-pre-command-hook) | |
438 (set-buffer-modified-p (buffer-modified-p)) ; update modeline | |
439 (isearch-push-state) | |
440 | |
441 ) ; inhibit-quit is t before here | |
442 | |
443 (isearch-update) | |
444 (run-hooks 'isearch-mode-hook) | |
445 | |
446 ;; isearch-mode can be made modal (in the sense of not returning to | |
447 ;; the calling function until searching is completed) by entering | |
448 ;; a recursive-edit and exiting it when done isearching. | |
449 (if recursive-edit | |
450 (let ((isearch-recursive-edit t)) | |
451 (recursive-edit))) | |
452 ) | |
453 | |
454 | |
455 ;;;==================================================== | |
456 ;; Some high level utilities. Others below. | |
457 | |
458 (defun isearch-update () | |
459 ;; Called after each command to update the display. | |
460 (if (null unread-command-event) | |
461 (progn | |
462 (if (not (input-pending-p)) | |
463 (isearch-message)) | |
464 (if (and isearch-slow-terminal-mode | |
465 (not (or isearch-small-window | |
466 (pos-visible-in-window-p)))) | |
467 (let ((found-point (point))) | |
468 (setq isearch-small-window t) | |
469 (move-to-window-line 0) | |
470 (let ((window-min-height 1)) | |
471 (split-window nil (if (< search-slow-window-lines 0) | |
472 (1+ (- search-slow-window-lines)) | |
473 (- (window-height) | |
474 (1+ search-slow-window-lines))))) | |
475 (if (< search-slow-window-lines 0) | |
476 (progn (vertical-motion (- 1 search-slow-window-lines)) | |
477 (set-window-start (next-window) (point)) | |
478 (set-window-hscroll (next-window) | |
479 (window-hscroll)) | |
480 (set-window-hscroll (selected-window) 0)) | |
481 (other-window 1)) | |
482 (goto-char found-point))) | |
483 (if isearch-other-end | |
484 (if (< isearch-other-end (point)) | |
485 (isearch-highlight isearch-other-end (point)) | |
486 (isearch-highlight (point) isearch-other-end)) | |
487 (if (extentp isearch-extent) | |
488 (isearch-dehighlight nil))) | |
489 )) | |
490 (setq ;; quit-flag nil not for isearch-mode | |
491 isearch-adjusted nil | |
492 isearch-yank-flag nil) | |
493 ) | |
494 | |
495 | |
496 (defun isearch-done () | |
497 ;; Called by all commands that terminate isearch-mode. | |
498 (let ((inhibit-quit t)) ; danger danger! | |
499 (if (and isearch-buffer (buffer-live-p isearch-buffer)) | |
500 (save-excursion | |
501 ;; Some loser process filter might have switched the | |
502 ;; window's buffer, so be sure to set these variables back | |
503 ;; in the buffer we frobbed them in. But only if the buffer | |
504 ;; is still alive. | |
505 (set-buffer isearch-buffer) | |
506 (setq minor-mode-map-alist (delq (assoc 'isearch-mode minor-mode-map-alist) | |
507 minor-mode-map-alist)) | |
508 ;; Use remove-hook instead of just setting it to our saved value | |
509 ;; in case some process filter has created a buffer and modified | |
510 ;; the pre-command-hook in that buffer... yeah, this is obscure, | |
511 ;; and yeah, I was getting screwed by it. -jwz | |
512 (remove-hook 'pre-command-hook 'isearch-pre-command-hook) | |
513 (set-keymap-parents isearch-mode-map nil) | |
514 (setq isearch-mode nil) | |
515 (set-buffer-modified-p (buffer-modified-p));; update modeline | |
516 (isearch-dehighlight t))) | |
517 | |
518 ;; it's not critical that this be inside inhibit-quit, but leaving | |
519 ;; things in small-window-mode would be bad. | |
520 (let ((found-start (window-start (selected-window))) | |
521 (found-point (point))) | |
522 (cond ((eq (selected-frame) isearch-selected-frame) | |
523 (set-window-configuration isearch-window-configuration) | |
524 | |
525 (if isearch-small-window | |
526 (goto-char found-point) | |
527 ;; Exiting the save-window-excursion clobbers | |
528 ;; window-start; restore it. | |
529 (set-window-start (selected-window) found-start t)))) | |
530 ;; If there was movement, mark the starting position. | |
531 ;; Maybe should test difference between and set mark iff > threshold. | |
532 (if (and (buffer-live-p isearch-buffer) | |
533 (/= (point isearch-buffer) isearch-opoint)) | |
534 (progn | |
535 (push-mark isearch-opoint t nil isearch-buffer) | |
536 (or executing-kbd-macro (> (minibuffer-depth) 0) | |
537 (message "Mark saved where search started")))) | |
538 ) | |
539 (setq isearch-buffer nil) | |
540 ) ; inhibit-quit is t before here | |
541 | |
542 (if (> (length isearch-string) 0) | |
543 ;; Update the ring data. | |
544 (if isearch-regexp | |
545 (if (not (setq regexp-search-ring-yank-pointer | |
546 (member isearch-string regexp-search-ring))) | |
547 (progn | |
548 (setq regexp-search-ring | |
549 (cons isearch-string regexp-search-ring) | |
550 regexp-search-ring-yank-pointer regexp-search-ring) | |
551 (if (> (length regexp-search-ring) regexp-search-ring-max) | |
552 (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) | |
553 nil)))) | |
554 (if (not (setq search-ring-yank-pointer | |
555 ;; really need equal test instead of eq. | |
556 (member isearch-string search-ring))) | |
557 (progn | |
558 (setq search-ring (cons isearch-string search-ring) | |
559 search-ring-yank-pointer search-ring) | |
560 (if (> (length search-ring) search-ring-max) | |
561 (setcdr (nthcdr (1- search-ring-max) search-ring) nil)))))) | |
562 | |
563 (run-hooks 'isearch-mode-end-hook) | |
564 (if isearch-recursive-edit (exit-recursive-edit))) | |
565 | |
566 | |
567 ;;;==================================================== | |
568 ;; Commands active while inside of the isearch minor mode. | |
569 | |
570 (defun isearch-exit () | |
571 "Exit search normally. | |
572 However, if this is the first command after starting incremental | |
573 search and `search-nonincremental-instead' is non-nil, do an | |
574 incremental search via `isearch-edit-string'." | |
575 (interactive) | |
576 (if (and search-nonincremental-instead | |
577 (= 0 (length isearch-string))) | |
578 (let ((isearch-nonincremental t)) | |
579 (isearch-edit-string)) | |
580 (isearch-done))) | |
581 | |
582 | |
583 (defun isearch-edit-string () | |
584 "Edit the search string in the minibuffer. | |
585 The following additional command keys are active while editing. | |
586 \\<minibuffer-local-isearch-map> | |
587 \\[exit-minibuffer] to exit editing and resume incremental searching. | |
588 \\[isearch-forward-exit-minibuffer] to resume isearching forward. | |
589 \\[isearch-backward-exit-minibuffer] to resume isearching backward. | |
590 \\[isearch-ring-advance-edit] to replace the search string with the next\ | |
591 item in the search ring. | |
592 \\[isearch-ring-retreat-edit] to replace the search string with the next\ | |
593 item in the search ring. | |
594 \\[isearch-complete-edit] to complete the search string from the search ring." | |
595 | |
596 ;; Editing doesnt back up the search point. Should it? | |
597 (interactive) | |
598 | |
599 (condition-case nil | |
600 (let ((minibuffer-local-map minibuffer-local-isearch-map) | |
601 isearch-nonincremental ; should search nonincrementally? | |
602 isearch-new-string | |
603 isearch-new-message | |
604 (isearch-new-forward isearch-forward) | |
605 | |
606 ;; Locally bind all isearch global variables to protect them | |
607 ;; from recursive isearching. | |
608 (isearch-string isearch-string) | |
609 (isearch-message isearch-message) | |
610 (isearch-forward isearch-forward) ; set by commands below. | |
611 | |
612 (isearch-forward isearch-forward) | |
613 (isearch-regexp isearch-regexp) | |
614 (isearch-word isearch-word) | |
615 (isearch-op-fun isearch-op-fun) | |
616 (isearch-cmds isearch-cmds) | |
617 (isearch-success isearch-success) | |
618 (isearch-wrapped isearch-wrapped) | |
619 (isearch-barrier isearch-barrier) | |
620 (isearch-adjusted isearch-adjusted) | |
621 (isearch-yank-flag isearch-yank-flag) | |
622 (isearch-invalid-regexp isearch-invalid-regexp) | |
623 (isearch-other-end isearch-other-end) | |
624 (isearch-opoint isearch-opoint) | |
625 (isearch-slow-terminal-mode isearch-slow-terminal-mode) | |
626 (isearch-small-window isearch-small-window) | |
627 (isearch-recursive-edit isearch-recursive-edit) | |
628 (isearch-window-configuration (current-window-configuration)) | |
629 (isearch-selected-frame (selected-frame)) | |
630 ) | |
631 ;; Actually terminate isearching until editing is done. | |
632 ;; This is so that the user can do anything without failure, | |
633 ;; like switch buffers and start another isearch, and return. | |
634 ;; (condition-case nil | |
635 (isearch-done) | |
636 ;;#### What does this mean? There is no such condition! | |
637 ;; (exit nil)) ; was recursive editing | |
638 | |
639 (unwind-protect | |
640 (let ((prompt (isearch-message-prefix nil t)) | |
641 event) | |
642 ;; If the first character the user types when we prompt them | |
643 ;; for a string is the yank-word character, then go into | |
644 ;; word-search mode. Otherwise unread that character and | |
645 ;; read a string the normal way. | |
646 (let ((cursor-in-echo-area t)) | |
647 (message "%s" prompt) | |
648 (setq event (next-command-event)) | |
649 (if (eq 'isearch-yank-word | |
650 (lookup-key isearch-mode-map (vector event))) | |
651 (setq isearch-word t) | |
652 (setq unread-command-event event))) | |
653 (setq isearch-new-string | |
654 ;; (if (fboundp 'gmhist-old-read-from-minibuffer) | |
655 ;; ;; Eschew gmhist crockery | |
656 ;; (gmhist-old-read-from-minibuffer prompt isearch-string) | |
657 (read-string | |
658 prompt isearch-string | |
659 't ;does its own history (but shouldn't) | |
660 ;; (if isearch-regexp | |
661 ;; ;; The search-rings aren't exactly minibuffer | |
662 ;; ;; histories, but they are close enough | |
663 ;; (cons 'regexp-search-ring | |
664 ;; (- (length regexp-search-ring-yank-pointer) | |
665 ;; (length regexp-search-ring))) | |
666 ;; (cons 'search-ring | |
667 ;; (- (length search-ring-yank-pointer) | |
668 ;; (length search-ring)))) | |
669 ) | |
670 ;; ) | |
671 isearch-new-message (mapconcat | |
672 'isearch-text-char-description | |
673 isearch-new-string "")) | |
674 ) | |
675 ;; Always resume isearching by restarting it. | |
676 (isearch-mode isearch-forward | |
677 isearch-regexp | |
678 isearch-op-fun | |
679 isearch-recursive-edit | |
680 isearch-word) | |
681 ) | |
682 | |
683 ;; Copy new values in outer locals to isearch globals | |
684 (setq isearch-string isearch-new-string | |
685 isearch-message isearch-new-message | |
686 isearch-forward isearch-new-forward) | |
687 | |
688 ;; Empty isearch-string means use default. | |
689 (if (= 0 (length isearch-string)) | |
690 (setq isearch-string (if isearch-regexp search-last-regexp | |
691 search-last-string)) | |
692 ;; Set last search string now so it is set even if we fail. | |
693 (if search-last-regexp | |
694 (setq search-last-regexp isearch-string) | |
695 (setq search-last-string isearch-string))) | |
696 | |
697 ;; Reinvoke the pending search. | |
698 (isearch-push-state) | |
699 (isearch-search) | |
700 (isearch-update) | |
701 (if isearch-nonincremental (isearch-done))) | |
702 | |
703 (quit ; handle abort-recursive-edit | |
704 (isearch-abort) ;; outside of let to restore outside global values | |
705 ))) | |
706 | |
707 (defun isearch-nonincremental-exit-minibuffer () | |
708 (interactive) | |
709 (setq isearch-nonincremental t) | |
710 (exit-minibuffer)) | |
711 | |
712 (defun isearch-forward-exit-minibuffer () | |
713 (interactive) | |
714 (setq isearch-new-forward t) | |
715 (exit-minibuffer)) | |
716 | |
717 (defun isearch-reverse-exit-minibuffer () | |
718 (interactive) | |
719 (setq isearch-new-forward nil) | |
720 (exit-minibuffer)) | |
721 | |
722 | |
723 (defun isearch-abort () | |
724 "Quit incremental search mode if searching is successful, signalling quit. | |
725 Otherwise, revert to previous successful search and continue searching. | |
726 Use `isearch-exit' to quit without signalling." | |
727 (interactive) | |
728 ;; (ding) signal instead below, if quiting | |
729 (discard-input) | |
730 (if isearch-success | |
731 ;; If search is successful, move back to starting point | |
732 ;; and really do quit. | |
733 (progn (goto-char isearch-opoint) | |
734 (isearch-done) ; exit isearch | |
735 (signal 'quit '(isearch))) ; and pass on quit signal | |
736 ;; If search is failing, rub out until it is once more successful. | |
737 (while (not isearch-success) (isearch-pop-state)) | |
738 (isearch-update))) | |
739 | |
740 | |
741 (defun isearch-repeat (direction) | |
742 ;; Utility for isearch-repeat-forward and -backward. | |
743 (if (eq isearch-forward (eq direction 'forward)) | |
744 ;; C-s in forward or C-r in reverse. | |
745 (if (equal isearch-string "") | |
746 ;; If search string is empty, use last one. | |
747 (setq isearch-string | |
748 (or (if isearch-regexp | |
749 (if regexp-search-ring-yank-pointer | |
750 (car regexp-search-ring-yank-pointer) | |
751 (car regexp-search-ring)) | |
752 (if search-ring-yank-pointer | |
753 (car search-ring-yank-pointer) | |
754 (car search-ring))) | |
755 "") | |
756 isearch-message | |
757 (mapconcat 'isearch-text-char-description | |
758 isearch-string "")) | |
759 ;; If already have what to search for, repeat it. | |
760 (or isearch-success | |
761 (progn | |
762 | |
763 (goto-char (if isearch-forward (point-min) (point-max))) | |
764 (setq isearch-wrapped t)))) | |
765 ;; C-s in reverse or C-r in forward, change direction. | |
766 (setq isearch-forward (not isearch-forward))) | |
767 | |
768 (setq isearch-barrier (point)) ; For subsequent \| if regexp. | |
769 (setq isearch-success t) | |
770 (or (equal isearch-string "") | |
771 ;; If repeating a search that found | |
772 ;; an empty string, ensure we advance. | |
773 (if (equal (match-end 0) (match-beginning 0)) | |
774 (if (if isearch-forward (eobp) (bobp)) | |
775 ;; nowhere to advance to, so fail (and wrap next time) | |
776 (progn | |
777 (setq isearch-success nil) | |
778 (and executing-kbd-macro | |
779 (not defining-kbd-macro) | |
780 (isearch-done)) | |
781 (ding nil 'isearch-failed)) | |
782 (forward-char (if isearch-forward 1 -1)) | |
783 (isearch-search)) | |
784 (isearch-search))) | |
785 (isearch-push-state) | |
786 (isearch-update)) | |
787 | |
788 (defun isearch-repeat-forward () | |
789 "Repeat incremental search forwards." | |
790 (interactive) | |
791 (isearch-repeat 'forward)) | |
792 | |
793 (defun isearch-repeat-backward () | |
794 "Repeat incremental search backwards." | |
795 (interactive) | |
796 (isearch-repeat 'backward)) | |
797 | |
798 (defun isearch-toggle-regexp () | |
799 "Toggle regexp searching on or off." | |
800 ;; The status stack is left unchanged. | |
801 (interactive) | |
802 (setq isearch-regexp (not isearch-regexp)) | |
803 (if isearch-regexp (setq isearch-word nil)) | |
804 (isearch-update)) | |
805 | |
806 (defun isearch-toggle-case-fold () | |
807 "Toggle case folding in searching on or off." | |
808 (interactive) | |
809 (setq isearch-case-fold-search | |
810 (if isearch-case-fold-search nil 'yes)) | |
811 (message "%s%s [case %ssensitive]" | |
812 (isearch-message-prefix) | |
813 isearch-message | |
814 (if isearch-case-fold-search "in" "")) | |
815 (setq isearch-adjusted t) | |
816 (sit-for 1) | |
817 (isearch-update)) | |
818 | |
819 (defun isearch-delete-char () | |
820 "Discard last input item and move point back. | |
821 If no previous match was done, just beep." | |
822 (interactive) | |
823 (if (null (cdr isearch-cmds)) | |
824 (ding nil 'isearch-quit) | |
825 (isearch-pop-state)) | |
826 (isearch-update)) | |
827 | |
828 | |
829 (defun isearch-yank (chunk) | |
830 ;; Helper for isearch-yank-word and isearch-yank-line | |
831 (let ((word (if (stringp chunk) | |
832 chunk | |
833 (save-excursion | |
834 (and (not isearch-forward) isearch-other-end | |
835 (goto-char isearch-other-end)) | |
836 (buffer-substring | |
837 (point) | |
838 (save-excursion | |
839 (funcall chunk) | |
840 (point))))))) | |
841 ;; if configured so that typing upper-case characters turns off case | |
842 ;; folding, then downcase the string so that yanking an upper-case | |
843 ;; word doesn't mess with case-foldedness. | |
844 (if (and search-caps-disable-folding isearch-case-fold-search) | |
845 (setq word (downcase word))) | |
846 (if isearch-regexp (setq word (regexp-quote word))) | |
847 (setq isearch-string (concat isearch-string word) | |
848 isearch-message | |
849 (concat isearch-message | |
850 (mapconcat 'isearch-text-char-description | |
851 word "")) | |
852 ;; Don't move cursor in reverse search. | |
853 isearch-yank-flag t)) | |
854 (isearch-search-and-update)) | |
855 | |
856 | |
857 (defun isearch-yank-word () | |
858 "Pull next word from buffer into search string." | |
859 (interactive) | |
860 (isearch-yank (function (lambda () (forward-word 1))))) | |
861 | |
862 (defun isearch-yank-line () | |
863 "Pull rest of line from buffer into search string." | |
864 (interactive) | |
865 (isearch-yank 'end-of-line)) | |
866 | |
867 (defun isearch-yank-sexp () | |
868 "Pull next expression from buffer into search string." | |
869 (interactive) | |
870 (isearch-yank 'forward-sexp)) | |
871 | |
872 (defun isearch-yank-x-selection () | |
873 "Pull the current X selection into the search string." | |
874 (interactive) | |
875 (isearch-yank (x-get-selection))) | |
876 | |
877 (defun isearch-yank-x-clipboard () | |
878 "Pull the current X clipboard selection into the search string." | |
879 (interactive) | |
880 (isearch-yank (x-get-clipboard))) | |
881 | |
882 (defun isearch-search-and-update () | |
883 ;; Do the search and update the display. | |
884 (if (and (not isearch-success) | |
885 ;; unsuccessful regexp search may become | |
886 ;; successful by addition of characters which | |
887 ;; make isearch-string valid | |
888 (not isearch-regexp)) | |
889 nil | |
890 ;; In reverse search, adding stuff at | |
891 ;; the end may cause zero or many more chars to be | |
892 ;; matched, in the string following point. | |
893 ;; Allow all those possibilities without moving point as | |
894 ;; long as the match does not extend past search origin. | |
895 (if (and (not isearch-forward) (not isearch-adjusted) | |
896 (condition-case () | |
897 (looking-at (if isearch-regexp isearch-string | |
898 (regexp-quote isearch-string))) | |
899 (error nil)) | |
900 (or isearch-yank-flag | |
901 (<= (match-end 0) | |
902 (min isearch-opoint isearch-barrier)))) | |
903 (setq isearch-success t | |
904 isearch-invalid-regexp nil | |
905 isearch-other-end (match-end 0)) | |
906 ;; Not regexp, not reverse, or no match at point. | |
907 (if (and isearch-other-end (not isearch-adjusted)) | |
908 (goto-char (if isearch-forward isearch-other-end | |
909 (min isearch-opoint | |
910 isearch-barrier | |
911 (1+ isearch-other-end))))) | |
912 (isearch-search) | |
913 )) | |
914 (isearch-push-state) | |
915 (if isearch-op-fun (funcall isearch-op-fun)) | |
916 (isearch-update)) | |
917 | |
918 | |
919 ;; *, ?, and | chars can make a regexp more liberal. | |
920 ;; They can make a regexp match sooner | |
921 ;; or make it succeed instead of failing. | |
922 ;; So go back to place last successful search started | |
923 ;; or to the last ^S/^R (barrier), whichever is nearer. | |
924 | |
925 (defun isearch-*-char () | |
926 "Handle * and ? specially in regexps." | |
927 (interactive) | |
928 (if isearch-regexp | |
929 | |
930 (progn | |
931 (setq isearch-adjusted t) | |
932 (let ((cs (nth (if isearch-forward | |
933 5 ; isearch-other-end | |
934 2) ; saved (point) | |
935 (car (cdr isearch-cmds))))) | |
936 ;; (car isearch-cmds) is after last search; | |
937 ;; (car (cdr isearch-cmds)) is from before it. | |
938 (setq cs (or cs isearch-barrier)) | |
939 (goto-char | |
940 (if isearch-forward | |
941 (max cs isearch-barrier) | |
942 (min cs isearch-barrier)))))) | |
943 (isearch-process-search-char last-command-event)) | |
944 | |
945 | |
946 | |
947 (defun isearch-|-char () | |
948 "If in regexp search, jump to the barrier." | |
949 (interactive) | |
950 (if isearch-regexp | |
951 (progn | |
952 (setq isearch-adjusted t) | |
953 (goto-char isearch-barrier))) | |
954 (isearch-process-search-char last-command-event)) | |
955 | |
956 (defun isearch-quote-char () | |
957 "Quote special characters for incremental search." | |
958 (interactive) | |
959 (isearch-process-search-char (read-quoted-char (isearch-message t)))) | |
960 | |
961 | |
962 (defun isearch-return-char () | |
963 "Convert return into newline for incremental search. | |
964 Obsolete." | |
965 (interactive) | |
966 (isearch-process-search-char ?\n)) | |
967 | |
968 | |
969 (defun isearch-printing-char () | |
970 "Any other printing character => add it to the search string and search." | |
971 (interactive) | |
972 (isearch-process-search-char last-command-event)) | |
973 | |
974 | |
975 (defun isearch-whitespace-chars () | |
976 "Match all whitespace chars, if in regexp mode." | |
977 (interactive) | |
978 (if (and isearch-regexp search-whitespace-regexp) | |
979 (isearch-process-search-string search-whitespace-regexp " ") | |
980 (beep) | |
981 (isearch-process-search-char ?\ ) | |
982 ; (if isearch-word | |
983 ; nil | |
984 ; (setq isearch-word t) | |
985 ; (goto-char isearch-other-end) | |
986 ; (isearch-process-search-char ?\ )) | |
987 )) | |
988 | |
989 (defun isearch-process-search-char (char) | |
990 ;; Append the char to the search string, update the message and re-search. | |
991 (isearch-process-search-string (isearch-char-to-string char) | |
992 (isearch-text-char-description char))) | |
993 | |
994 (defun isearch-process-search-string (string message) | |
995 (setq isearch-string (concat isearch-string string) | |
996 isearch-message (concat isearch-message message)) | |
997 (isearch-search-and-update)) | |
998 | |
999 | |
1000 ;;=========================================================== | |
1001 ;; Search Ring | |
1002 | |
1003 (defvar search-ring-update nil | |
1004 "*Non-nil if advancing or retreating in the search ring should cause search. | |
1005 Default nil means edit the string from the search ring first.") | |
1006 | |
1007 (defun isearch-ring-adjust1 (advance) | |
1008 ;; Helper for isearch-ring-adjust | |
1009 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) | |
1010 (length (length ring)) | |
1011 (yank-pointer-name (if isearch-regexp | |
1012 'regexp-search-ring-yank-pointer | |
1013 'search-ring-yank-pointer)) | |
1014 (yank-pointer (eval yank-pointer-name))) | |
1015 (if (zerop length) | |
1016 () | |
1017 (set yank-pointer-name | |
1018 (setq yank-pointer | |
1019 (nthcdr (% (+ (- length (length yank-pointer)) | |
1020 (if advance (1- length) 1)) | |
1021 length) ring))) | |
1022 (setq isearch-string (car yank-pointer) | |
1023 isearch-message (mapconcat 'isearch-text-char-description | |
1024 isearch-string ""))))) | |
1025 | |
1026 (defun isearch-ring-adjust (advance) | |
1027 ;; Helper for isearch-ring-advance and isearch-ring-retreat | |
1028 (if (cdr isearch-cmds) ;; is there more than one thing on stack? | |
1029 (isearch-pop-state)) | |
1030 (isearch-ring-adjust1 advance) | |
1031 (isearch-push-state) | |
1032 (if search-ring-update | |
1033 (progn | |
1034 (isearch-search) | |
1035 (isearch-update)) | |
1036 (isearch-edit-string) | |
1037 )) | |
1038 | |
1039 (defun isearch-ring-advance () | |
1040 "Advance to the next search string in the ring." | |
1041 ;; This could be more general to handle a prefix arg, but who would use it. | |
1042 (interactive) | |
1043 (isearch-ring-adjust 'advance)) | |
1044 | |
1045 (defun isearch-ring-retreat () | |
1046 "Retreat to the previous search string in the ring." | |
1047 (interactive) | |
1048 (isearch-ring-adjust nil)) | |
1049 | |
1050 (defun isearch-ring-adjust-edit (advance) | |
1051 "Use the next or previous search string in the ring while in minibuffer." | |
1052 (isearch-ring-adjust1 advance) | |
1053 (erase-buffer) | |
1054 (insert isearch-string)) | |
1055 | |
1056 (defun isearch-ring-advance-edit () | |
1057 (interactive) | |
1058 (isearch-ring-adjust-edit 'advance)) | |
1059 | |
1060 (defun isearch-ring-retreat-edit () | |
1061 "Retreat to the previous search string in the ring while in the minibuffer." | |
1062 (interactive) | |
1063 (isearch-ring-adjust-edit nil)) | |
1064 | |
1065 | |
1066 (defun isearch-complete1 () | |
1067 ;; Helper for isearch-complete and isearch-complete-edit | |
1068 ;; Return t if completion OK, | |
1069 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) | |
1070 (alist (mapcar (function (lambda (string) (list string))) ring)) | |
1071 (completion-ignore-case case-fold-search) | |
1072 (completion (try-completion isearch-string alist)) | |
1073 ) | |
1074 (cond | |
1075 ((eq completion t) | |
1076 ;; isearch-string stays the same | |
1077 t) | |
1078 ((or completion ; not nil, must be a string | |
1079 (= 0 (length isearch-string))) ; shouldnt have to say this | |
1080 (if (equal completion isearch-string) ;; no extension? | |
1081 (if completion-auto-help | |
1082 (with-output-to-temp-buffer "*Isearch completions*" | |
1083 (display-completion-list | |
1084 (all-completions isearch-string alist)))) | |
1085 (setq isearch-string completion)) | |
1086 t) | |
1087 (t | |
1088 (temp-minibuffer-message "No completion") | |
1089 nil)))) | |
1090 | |
1091 (defun isearch-complete () | |
1092 "Complete the search string from the strings on the search ring. | |
1093 The completed string is then editable in the minibuffer. | |
1094 If there is no completion possible, say so and continue searching." | |
1095 (interactive) | |
1096 (if (isearch-complete1) | |
1097 (isearch-edit-string) | |
1098 ;; else | |
1099 (sit-for 1) | |
1100 (isearch-update))) | |
1101 | |
1102 (defun isearch-complete-edit () | |
1103 "Same as `isearch-complete' except in the minibuffer." | |
1104 (interactive) | |
1105 (setq isearch-string (buffer-string)) | |
1106 (if (isearch-complete1) | |
1107 (progn | |
1108 (erase-buffer) | |
1109 (insert isearch-string)))) | |
1110 | |
1111 | |
1112 ;;;============================================================== | |
1113 ;; The search status stack (and isearch window-local variables, not used). | |
1114 | |
1115 (defun isearch-top-state () | |
1116 ;; (fetch-window-local-variables) | |
1117 (let ((cmd (car isearch-cmds))) | |
1118 (setq isearch-string (car cmd) | |
1119 isearch-message (car (cdr cmd)) | |
1120 isearch-success (nth 3 cmd) | |
1121 isearch-forward (nth 4 cmd) | |
1122 isearch-other-end (nth 5 cmd) | |
1123 isearch-invalid-regexp (nth 6 cmd) | |
1124 isearch-wrapped (nth 7 cmd) | |
1125 isearch-barrier (nth 8 cmd)) | |
1126 (goto-char (car (cdr (cdr cmd)))))) | |
1127 | |
1128 (defun isearch-pop-state () | |
1129 ;; (fetch-window-local-variables) | |
1130 (setq isearch-cmds (cdr isearch-cmds)) | |
1131 (isearch-top-state) | |
1132 ) | |
1133 | |
1134 (defun isearch-push-state () | |
1135 (setq isearch-cmds | |
1136 (cons (list isearch-string isearch-message (point) | |
1137 isearch-success isearch-forward isearch-other-end | |
1138 isearch-invalid-regexp isearch-wrapped isearch-barrier) | |
1139 isearch-cmds))) | |
1140 | |
1141 | |
1142 ;;;================================================================== | |
1143 ;; Message string | |
1144 | |
1145 (defun isearch-message (&optional c-q-hack ellipsis) | |
1146 ;; Generate and print the message string. | |
1147 (let ((cursor-in-echo-area ellipsis) | |
1148 (m (concat | |
1149 (isearch-message-prefix c-q-hack) | |
1150 isearch-message | |
1151 (isearch-message-suffix c-q-hack) | |
1152 ))) | |
1153 (if c-q-hack m (message "%s" m)))) | |
1154 | |
1155 (defun isearch-message-prefix (&optional c-q-hack nonincremental) | |
1156 ;; If about to search, and previous search regexp was invalid, | |
1157 ;; check that it still is. If it is valid now, | |
1158 ;; let the message we display while searching say that it is valid. | |
1159 (and isearch-invalid-regexp | |
1160 (condition-case () | |
1161 (progn (re-search-forward isearch-string (point) t) | |
1162 (setq isearch-invalid-regexp nil)) | |
1163 (error nil))) | |
1164 ;; #### - Yo! Emacs assembles strings all over the place, they can't all | |
1165 ;; be internationalized in the manner proposed below... Add an explicit | |
1166 ;; call to `gettext' and have the string snarfer pluck the english | |
1167 ;; strings out of the comment below. XEmacs is on a purespace diet! -Stig | |
1168 (let ((m (concat (if isearch-success nil "failing ") | |
1169 (if isearch-wrapped "wrapped ") | |
1170 (if isearch-word "word ") | |
1171 (if isearch-regexp "regexp ") | |
1172 (if nonincremental "search" "I-search") | |
1173 (if isearch-forward nil " backward") | |
1174 ": " | |
1175 ))) | |
1176 (aset m 0 (upcase (aref m 0))) | |
1177 (gettext m))) | |
1178 | |
1179 (defun isearch-message-suffix (&optional c-q-hack) | |
1180 (concat (if c-q-hack "^Q" "") | |
1181 (if isearch-invalid-regexp | |
1182 (concat " [" isearch-invalid-regexp "]") | |
1183 ""))) | |
1184 | |
1185 ;;;;; #### - yuck...this is soooo lame. Is this really worth 4k of purespace??? | |
1186 ;;; | |
1187 ;;;(let ((i (logior (if isearch-success 32 0) | |
1188 ;;; (if isearch-wrapped 16 0) | |
1189 ;;; (if isearch-word 8 0) | |
1190 ;;; (if isearch-regexp 4 0) | |
1191 ;;; (if nonincremental 2 0) | |
1192 ;;; (if isearch-forward 1 0)))) | |
1193 ;;; (cond | |
1194 ;;; ((= i 63) (gettext "Wrapped word regexp search: ")) ; 111111 | |
1195 ;;; ((= i 62) (gettext "Wrapped word regexp search backward: ")) ; 111110 | |
1196 ;;; ((= i 61) (gettext "Wrapped word regexp I-search: ")) ; 111101 | |
1197 ;;; ((= i 60) (gettext "Wrapped word regexp I-search backward: ")) ; 111100 | |
1198 ;;; ((= i 59) (gettext "Wrapped word search: ")) ; 111011 | |
1199 ;;; ((= i 58) (gettext "Wrapped word search backward: ")) ; 111010 | |
1200 ;;; ((= i 57) (gettext "Wrapped word I-search: ")) ; 111001 | |
1201 ;;; ((= i 56) (gettext "Wrapped word I-search backward: ")) ; 111000 | |
1202 ;;; ((= i 55) (gettext "Wrapped regexp search: ")) ; 110111 | |
1203 ;;; ((= i 54) (gettext "Wrapped regexp search backward: ")) ; 110110 | |
1204 ;;; ((= i 53) (gettext "Wrapped regexp I-search: ")) ; 110101 | |
1205 ;;; ((= i 52) (gettext "Wrapped regexp I-search backward: ")) ; 110100 | |
1206 ;;; ((= i 51) (gettext "Wrapped search: ")) ; 110011 | |
1207 ;;; ((= i 50) (gettext "Wrapped search backward: ")) ; 110010 | |
1208 ;;; ((= i 49) (gettext "Wrapped I-search: ")) ; 110001 | |
1209 ;;; ((= i 48) (gettext "Wrapped I-search backward: ")) ; 110000 | |
1210 ;;; ((= i 47) (gettext "Word regexp search: ")) ; 101111 | |
1211 ;;; ((= i 46) (gettext "Word regexp search backward: ")) ; 101110 | |
1212 ;;; ((= i 45) (gettext "Word regexp I-search: ")) ; 101101 | |
1213 ;;; ((= i 44) (gettext "Word regexp I-search backward: ")) ; 101100 | |
1214 ;;; ((= i 43) (gettext "Word search: ")) ; 101011 | |
1215 ;;; ((= i 42) (gettext "Word search backward: ")) ; 101010 | |
1216 ;;; ((= i 41) (gettext "Word I-search: ")) ; 101001 | |
1217 ;;; ((= i 40) (gettext "Word I-search backward: ")) ; 101000 | |
1218 ;;; ((= i 39) (gettext "Regexp search: ")) ; 100111 | |
1219 ;;; ((= i 38) (gettext "Regexp search backward: ")) ; 100110 | |
1220 ;;; ((= i 37) (gettext "Regexp I-search: ")) ; 100101 | |
1221 ;;; ((= i 36) (gettext "Regexp I-search backward: ")) ; 100100 | |
1222 ;;; ((= i 35) (gettext "Search: ")) ; 100011 | |
1223 ;;; ((= i 34) (gettext "Search backward: ")) ; 100010 | |
1224 ;;; ((= i 33) (gettext "I-search: ")) ; 100001 | |
1225 ;;; ((= i 32) (gettext "I-search backward: ")) ; 100000 | |
1226 ;;; ((= i 31) (gettext "Failing wrapped word regexp search: ")) ; 011111 | |
1227 ;;; ((= i 30) (gettext "Failing wrapped word regexp search backward: ")) ; 011110 | |
1228 ;;; ((= i 29) (gettext "Failing wrapped word regexp I-search: ")) ; 011101 | |
1229 ;;; ((= i 28) (gettext "Failing wrapped word regexp I-search backward: ")) ; 011100 | |
1230 ;;; ((= i 27) (gettext "Failing wrapped word search: ")) ; 011011 | |
1231 ;;; ((= i 26) (gettext "Failing wrapped word search backward: ")) ; 011010 | |
1232 ;;; ((= i 25) (gettext "Failing wrapped word I-search: ")) ; 011001 | |
1233 ;;; ((= i 24) (gettext "Failing wrapped word I-search backward: ")) ; 011000 | |
1234 ;;; ((= i 23) (gettext "Failing wrapped regexp search: ")) ; 010111 | |
1235 ;;; ((= i 22) (gettext "Failing wrapped regexp search backward: ")) ; 010110 | |
1236 ;;; ((= i 21) (gettext "Failing wrapped regexp I-search: ")) ; 010101 | |
1237 ;;; ((= i 20) (gettext "Failing wrapped regexp I-search backward: ")) ; 010100 | |
1238 ;;; ((= i 19) (gettext "Failing wrapped search: ")) ; 010011 | |
1239 ;;; ((= i 18) (gettext "Failing wrapped search backward: ")) ; 010010 | |
1240 ;;; ((= i 17) (gettext "Failing wrapped I-search: ")) ; 010001 | |
1241 ;;; ((= i 16) (gettext "Failing wrapped I-search backward: ")) ; 010000 | |
1242 ;;; ((= i 15) (gettext "Failing word regexp search: ")) ; 001111 | |
1243 ;;; ((= i 14) (gettext "Failing word regexp search backward: ")) ; 001110 | |
1244 ;;; ((= i 13) (gettext "Failing word regexp I-search: ")) ; 001101 | |
1245 ;;; ((= i 12) (gettext "Failing word regexp I-search backward: ")) ; 001100 | |
1246 ;;; ((= i 11) (gettext "Failing word search: ")) ; 001011 | |
1247 ;;; ((= i 10) (gettext "Failing word search backward: ")) ; 001010 | |
1248 ;;; ((= i 9) (gettext "Failing word I-search: ")) ; 001001 | |
1249 ;;; ((= i 8) (gettext "Failing word I-search backward: ")) ; 001000 | |
1250 ;;; ((= i 7) (gettext "Failing regexp search: ")) ; 000111 | |
1251 ;;; ((= i 6) (gettext "Failing regexp search backward: ")) ; 000110 | |
1252 ;;; ((= i 5) (gettext "Failing regexp I-search: ")) ; 000101 | |
1253 ;;; ((= i 4) (gettext "Failing regexp I-search backward: ")) ; 000100 | |
1254 ;;; ((= i 3) (gettext "Failing search: ")) ; 000011 | |
1255 ;;; ((= i 2) (gettext "Failing search backward: ")) ; 000010 | |
1256 ;;; ((= i 1) (gettext "Failing I-search: ")) ; 000001 | |
1257 ;;; ((= i 0) (gettext "Failing I-search backward: ")) ; 000000 | |
1258 ;;; (t (error "Something's rotten"))))) | |
1259 | |
1260 | |
1261 ;;;======================================================== | |
1262 ;;; Exiting | |
1263 | |
1264 (put 'isearch-printing-char 'isearch-command t) | |
1265 (put 'isearch-return-char 'isearch-command t) | |
1266 (put 'isearch-repeat-forward 'isearch-command t) | |
1267 (put 'isearch-repeat-backward 'isearch-command t) | |
1268 (put 'isearch-delete-char 'isearch-command t) | |
1269 (put 'isearch-abort 'isearch-command t) | |
1270 (put 'isearch-quote-char 'isearch-command t) | |
1271 (put 'isearch-exit 'isearch-command t) | |
1272 (put 'isearch-printing-char 'isearch-command t) | |
1273 (put 'isearch-printing-char 'isearch-command t) | |
1274 (put 'isearch-yank-word 'isearch-command t) | |
1275 (put 'isearch-yank-line 'isearch-command t) | |
1276 (put 'isearch-yank-sexp 'isearch-command t) | |
1277 (put 'isearch-*-char 'isearch-command t) | |
1278 (put 'isearch-*-char 'isearch-command t) | |
1279 (put 'isearch-|-char 'isearch-command t) | |
1280 (put 'isearch-toggle-regexp 'isearch-command t) | |
1281 (put 'isearch-toggle-case-fold 'isearch-command t) | |
1282 (put 'isearch-edit-string 'isearch-command t) | |
1283 (put 'isearch-mode-help 'isearch-command t) | |
1284 (put 'isearch-ring-advance 'isearch-command t) | |
1285 (put 'isearch-ring-retreat 'isearch-command t) | |
1286 (put 'isearch-ring-advance-edit 'isearch-command t) | |
1287 (put 'isearch-ring-retreat-edit 'isearch-command t) | |
1288 (put 'isearch-whitespace-chars 'isearch-command t) | |
1289 (put 'isearch-complete 'isearch-command t) | |
1290 (put 'isearch-complete-edit 'isearch-command t) | |
1291 (put 'isearch-edit-string 'isearch-command t) | |
1292 (put 'isearch-toggle-regexp 'isearch-command t) | |
1293 (put 'isearch-forward-exit-minibuffer 'isearch-command t) | |
1294 (put 'isearch-reverse-exit-minibuffer 'isearch-command t) | |
1295 (put 'isearch-nonincremental-exit-minibuffer 'isearch-command t) | |
1296 (put 'isearch-yank-x-selection 'isearch-command t) | |
1297 (put 'isearch-yank-x-clipboard 'isearch-command t) | |
1298 | |
1299 ;; scrolling the scrollbar should not terminate isearch. | |
1300 | |
1301 ;; vertical scrollbar: | |
1302 (put 'scrollbar-line-up 'isearch-command t) | |
1303 (put 'scrollbar-line-down 'isearch-command t) | |
1304 (put 'scrollbar-page-up 'isearch-command t) | |
1305 (put 'scrollbar-page-down 'isearch-command t) | |
1306 (put 'scrollbar-to-top 'isearch-command t) | |
1307 (put 'scrollbar-to-bottom 'isearch-command t) | |
1308 (put 'scrollbar-vertical-drag 'isearch-command t) | |
1309 | |
1310 ;; horizontal scrollbar: | |
1311 (put 'scrollbar-char-left 'isearch-command t) | |
1312 (put 'scrollbar-char-right 'isearch-command t) | |
1313 (put 'scrollbar-page-left 'isearch-command t) | |
1314 (put 'scrollbar-page-right 'isearch-command t) | |
1315 (put 'scrollbar-to-left 'isearch-command t) | |
1316 (put 'scrollbar-to-right 'isearch-command t) | |
1317 (put 'scrollbar-horizontal-drag 'isearch-command t) | |
1318 | |
1319 (defun isearch-pre-command-hook () | |
1320 ;; | |
1321 ;; For use as the value of `pre-command-hook' when isearch-mode is active. | |
1322 ;; If the command about to be executed is not one of the isearch commands, | |
1323 ;; then isearch-mode is turned off before that command is executed. | |
1324 ;; | |
1325 ;; If the command about to be executed is self-insert-command, or is a | |
1326 ;; keyboard macro of a single key sequence which is bound to self-insert- | |
1327 ;; command, then we add those chars to the search ring instead of inserting | |
1328 ;; them in the buffer. In this way, the set of self-searching characters | |
1329 ;; need not be exhaustively enumerated, but is derived from other maps. | |
1330 ;; | |
1331 (cond ((not (eq (current-buffer) isearch-buffer)) | |
1332 ;; If the buffer (likely meaning "frame") has changed, bail. | |
1333 ;; This can also happen if a proc filter has popped up another | |
1334 ;; buffer, which is arguably a bad thing for it to have done, | |
1335 ;; but the way in which isearch would have hosed you in that | |
1336 ;; case is unarguably even worse. -jwz | |
1337 (isearch-done)) | |
1338 (t | |
1339 (isearch-maybe-frob-keyboard-macros) | |
1340 (if (and this-command | |
1341 (symbolp this-command) | |
1342 (get this-command 'isearch-command)) | |
1343 nil ; then continue. | |
1344 (isearch-done))))) | |
1345 | |
1346 (defun isearch-maybe-frob-keyboard-macros () | |
1347 ;; | |
1348 ;; If the command about to be executed is `self-insert-command' then change | |
1349 ;; the command to `isearch-printing-char' instead, meaning add the last- | |
1350 ;; typed character to the search string. | |
1351 ;; | |
1352 ;; If `this-command' is a string or a vector (that is, a keyboard macro) | |
1353 ;; and it contains only one command, which is bound to self-insert-command, | |
1354 ;; then do the same thing as for self-inserting commands: arrange for that | |
1355 ;; character to be added to the search string. If we didn't do this, then | |
1356 ;; typing a compose sequence (a la x-compose.el) would terminate the search | |
1357 ;; and insert the character, instead of searching for that character. | |
1358 ;; | |
1359 ;; We should continue doing this, since it's pretty much the behavior one | |
1360 ;; would expect, but it will stop being so necessary once key-translation- | |
1361 ;; map exists and is used by x-compose.el and things like it, since the | |
1362 ;; translation will have been done before we see the keys. | |
1363 ;; | |
1364 (cond ((eq this-command 'self-insert-command) | |
1365 (setq this-command 'isearch-printing-char)) | |
1366 ((and (or (stringp this-command) (vectorp this-command)) | |
1367 (eq (key-binding this-command) 'self-insert-command)) | |
1368 (setq last-command-event (character-to-event (aref this-command 0)) | |
1369 last-command-char (and (stringp this-command) | |
1370 (aref this-command 0)) | |
1371 this-command 'isearch-printing-char)) | |
1372 )) | |
1373 | |
1374 | |
1375 ;;;======================================================== | |
1376 ;;; Highlighting | |
1377 | |
1378 (defvar isearch-highlight t | |
1379 "*Whether isearch and query-replace should highlight the text which | |
1380 currently matches the search-string.") | |
1381 | |
1382 (defvar isearch-extent nil) | |
1383 | |
1384 ;; this face is initialized by x-faces.el since isearch is preloaded. | |
1385 ;; this face is now created in initialize-faces | |
1386 ;;(make-face 'isearch) | |
1387 | |
1388 (defun isearch-make-extent (begin end) | |
1389 (let ((x (make-extent begin end (current-buffer)))) | |
1390 ;; make the isearch extent always take prescedence over any mouse- | |
1391 ;; highlighted extents we may be passing through, since isearch, being | |
1392 ;; modal, is more interesting (there's nothing they could do with a | |
1393 ;; mouse-highlighted extent while in the midst of a search anyway). | |
1394 (set-extent-priority x (1+ mouse-highlight-priority)) | |
1395 (set-extent-face x 'isearch) | |
1396 (setq isearch-extent x))) | |
1397 | |
1398 (defun isearch-highlight (begin end) | |
1399 (if (null isearch-highlight) | |
1400 nil | |
1401 ;; make sure isearch-extent is in the current buffer | |
1402 (cond ((not (extentp isearch-extent)) | |
1403 (isearch-make-extent begin end)) | |
1404 ((not (eq (extent-object isearch-extent) (current-buffer))) | |
1405 (delete-extent isearch-extent) | |
1406 (isearch-make-extent begin end))) | |
1407 (set-extent-endpoints isearch-extent begin end))) | |
1408 | |
1409 (defun isearch-dehighlight (totally) | |
1410 (if (and isearch-highlight isearch-extent) | |
1411 (if totally | |
1412 (let ((inhibit-quit t)) | |
1413 (if (extentp isearch-extent) | |
1414 (delete-extent isearch-extent)) | |
1415 (setq isearch-extent nil)) | |
1416 (if (extentp isearch-extent) | |
1417 (detach-extent isearch-extent) | |
1418 (setq isearch-extent nil))))) | |
1419 | |
1420 | |
1421 ;;;======================================================== | |
1422 ;;; Searching | |
1423 | |
1424 (defun isearch-search () | |
1425 ;; Do the search with the current search string. | |
1426 (isearch-message nil t) | |
1427 (if (and isearch-case-fold-search search-caps-disable-folding) | |
1428 (setq isearch-case-fold-search (isearch-no-upper-case-p isearch-string))) | |
1429 | |
1430 (setq isearch-mode (if case-fold-search | |
1431 (if isearch-case-fold-search | |
1432 " Isearch" ;As God Intended Mode | |
1433 " ISeARch") ;Warn about evil case via StuDLYcAps. | |
1434 "Isearch" | |
1435 ; (if isearch-case-fold-search | |
1436 ; " isearch" ;Presumably case-sensitive losers | |
1437 ; ;will notice this 1-char difference. | |
1438 ; " Isearch") ;Weenie mode. | |
1439 )) | |
1440 (condition-case lossage | |
1441 (let ((inhibit-quit nil) | |
1442 (case-fold-search isearch-case-fold-search)) | |
1443 (if isearch-regexp (setq isearch-invalid-regexp nil)) | |
1444 (setq isearch-success | |
1445 (funcall | |
1446 (cond (isearch-word | |
1447 (if isearch-forward | |
1448 'word-search-forward 'word-search-backward)) | |
1449 (isearch-regexp | |
1450 (if isearch-forward | |
1451 're-search-forward 're-search-backward)) | |
1452 (t | |
1453 (if isearch-forward 'search-forward 'search-backward))) | |
1454 isearch-string nil t)) | |
1455 (if isearch-success | |
1456 (setq isearch-other-end | |
1457 (if isearch-forward (match-beginning 0) (match-end 0))))) | |
1458 | |
1459 (quit (setq unread-command-event (character-to-event (quit-char))) | |
1460 (setq isearch-success nil)) | |
1461 | |
1462 (invalid-regexp | |
1463 (setq isearch-invalid-regexp (car (cdr lossage))) | |
1464 (if (string-match | |
1465 "\\`Premature \\|\\`Unmatched \\|\\`Invalid " | |
1466 isearch-invalid-regexp) | |
1467 (setq isearch-invalid-regexp (gettext "incomplete input"))))) | |
1468 | |
1469 (if isearch-success | |
1470 nil | |
1471 | |
1472 ;; If we're being run inside a keyboard macro, then the call to | |
1473 ;; ding will signal an error (to terminate the macro). We must | |
1474 ;; turn off isearch-mode first, so that we aren't still in isearch | |
1475 ;; mode after the macro exits. Note that isearch-recursive-edit | |
1476 ;; must not be true if a keyboard macro is executing. | |
1477 (if (and executing-kbd-macro (not defining-kbd-macro)) | |
1478 (progn | |
1479 (isearch-done) | |
1480 (ding nil 'isearch-failed))) | |
1481 | |
1482 ;; Ding if failed this time after succeeding last time. | |
1483 (and (nth 3 (car isearch-cmds)) | |
1484 (ding nil 'isearch-failed)) | |
1485 (goto-char (nth 2 (car isearch-cmds))))) | |
1486 | |
1487 ;;;================================================= | |
1488 ;; This is called from incremental-search | |
1489 ;; if the first input character is the exit character. | |
1490 | |
1491 ;; We store the search string in `isearch-string' | |
1492 ;; which has been bound already by `isearch-search' | |
1493 ;; so that, when we exit, it is copied into `search-last-string'. | |
1494 | |
1495 ;(defun nonincremental-search (forward regexp) | |
1496 ; ;; This may be broken. Anyway, it is replaced by the isearch-edit-string. | |
1497 ; ;; Missing features: word search option, command history. | |
1498 ; (setq isearch-forward forward | |
1499 ; isearch-regexp regexp) | |
1500 ; (let (char function | |
1501 ; inhibit-quit | |
1502 ; (cursor-in-echo-area t)) | |
1503 ; ;; Prompt assuming not word search, | |
1504 ; (setq isearch-message | |
1505 ; (if isearch-regexp | |
1506 ; (if isearch-forward "Regexp search: " | |
1507 ; "Regexp search backward: ") | |
1508 ; (if isearch-forward "Search: " "Search backward: "))) | |
1509 ; (message "%s" isearch-message) | |
1510 ; ;; Read 1 char and switch to word search if it is ^W. | |
1511 ; (setq char (read-char)) | |
1512 ; (if (eq char search-yank-word-char) | |
1513 ; (setq isearch-message (if isearch-forward "Word search: " | |
1514 ; "Word search backward: ")) | |
1515 ; ;; Otherwise let that 1 char be part of the search string. | |
1516 ; (setq unread-command-event (character-to-event char)) | |
1517 ; ) | |
1518 ; (setq function | |
1519 ; (if (eq char search-yank-word-char) | |
1520 ; (if isearch-forward 'word-search-forward 'word-search-backward) | |
1521 ; (if isearch-regexp | |
1522 ; (if isearch-forward 're-search-forward 're-search-backward) | |
1523 ; (if isearch-forward 'search-forward 'search-backward)))) | |
1524 ; ;; Read the search string with corrected prompt. | |
1525 ; (setq isearch-string (read-string isearch-message isearch-string)) | |
1526 ; ;; Empty means use default. | |
1527 ; (if (= 0 (length isearch-string)) | |
1528 ; (setq isearch-string search-last-string) | |
1529 ; ;; Set last search string now so it is set even if we fail. | |
1530 ; (setq search-last-string isearch-string)) | |
1531 ; ;; Since we used the minibuffer, we should be available for redo. | |
1532 ; (setq command-history | |
1533 ; (cons (list function isearch-string) command-history)) | |
1534 ; ;; Go ahead and search. | |
1535 ; (if search-caps-disable-folding | |
1536 ; (setq isearch-case-fold-search | |
1537 ; (isearch-no-upper-case-p isearch-string))) | |
1538 ; (let ((case-fold-search isearch-case-fold-search)) | |
1539 ; (funcall function isearch-string)))) | |
1540 | |
1541 | |
1542 (defun isearch-no-upper-case-p (string) | |
1543 "Return t if there are no upper case chars in string. | |
1544 But upper case chars preceeded by \\ do not count since they | |
1545 have special meaning in a regexp." | |
1546 ;; this incorrectly returns t for "\\\\A" | |
1547 (let ((case-fold-search nil)) | |
1548 (not (string-match "\\(^\\|[^\\]\\)[A-Z]" string)))) |