Mercurial > emacs
annotate lisp/isearch.el @ 1272:bfd04f61eb16
Mods to Ferase_text_properties
author | Joseph Arceneaux <jla@gnu.org> |
---|---|
date | Wed, 30 Sep 1992 01:11:20 +0000 |
parents | 5f4300ccc93f |
children | a7003e65eb66 |
rev | line source |
---|---|
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1 ;; Incremental search minor mode. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
792
diff
changeset
|
2 ;; Copyright (C) 1992 Free Software Foundation, Inc. |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
792
diff
changeset
|
3 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
4 ;; LCD Archive Entry: |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
5 ;; isearch-mode|Daniel LaLiberte|liberte@cs.uiuc.edu |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
6 ;; |A minor mode replacement for isearch.el. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
7 ;; |$Date: 92/09/14 16:26:02 $|$Revision: 1.4 $|~/modes/isearch-mode.el |
725 | 8 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
9 ;; This file is not yet part of GNU Emacs, but it is based almost |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
10 ;; entirely on isearch.el which is part of GNU Emacs. |
725 | 11 |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
14 ;; accepts responsibility to anyone for the consequences of using it | |
15 ;; or for whether it serves any particular purpose or works at all, | |
16 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
17 ;; License for full details. | |
18 | |
19 ;; Everyone is granted permission to copy, modify and redistribute | |
20 ;; GNU Emacs, but only under the conditions described in the | |
21 ;; GNU Emacs General Public License. A copy of this license is | |
22 ;; supposed to have been given to you along with GNU Emacs so you | |
23 ;; can know your rights and responsibilities. It should be in a | |
24 ;; file named COPYING. Among other things, the copyright notice | |
25 ;; and this notice must be preserved on all copies. | |
26 | |
27 ;;;==================================================================== | |
28 ;; Instructions | |
29 | |
30 ;; Searching with isearch-mode.el should work just like isearch.el, | |
31 ;; except it is done in a temporary minor mode that terminates when | |
32 ;; you finish searching. | |
33 | |
34 ;; To use isearch-mode instead of the standard isearch.el, add the | |
35 ;; following to your .emacs file. The standard key bindings to | |
36 ;; isearch-forward, etc, will then use isearch-mode instead of | |
37 ;; isearch. | |
38 | |
39 ;; (fset 'isearch 'isearch-mode) | |
40 ;; (autoload 'isearch-mode "isearch-mode") | |
41 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
42 ;; For programmed use of isearch-mode, e.g. calling (isearch-forward), |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
43 ;; isearch-mode behaves modally and does not return until the search |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
44 ;; is completed. It uses a recursive-edit to behave this way. Note: |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
45 ;; gnus does it wrong: (call-interactively 'isearch-forward). |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
46 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
47 ;; If any package you use invokes isearching non-interactively to get |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
48 ;; the modal behavior described above, you must use the redefinitions |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
49 ;; of isearch-forward, etc. found in this file instead of those in |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
50 ;; loaddefs.el. The simplest way to ensure this is to just load |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
51 ;; isearch-mode explicitly in your .emacs instead of using the above |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
52 ;; fset and autoload. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
53 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
54 ;; (load "isearch-mode") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
55 |
725 | 56 ;; The key bindings active within isearch-mode are defined below in |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
57 ;; `isearch-mode-map' which is given bindings close to the default |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
58 ;; characters of the original isearch.el. With `isearch-mode', |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
59 ;; however, you can bind multi-character keys and it should be easier |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
60 ;; to add new commands. One bug though: keys with meta-prefix cannot |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
61 ;; be longer than two chars. Also see minibuffer-local-isearch-map |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
62 ;; for bindings active during `isearch-edit-string'. |
725 | 63 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
64 ;; Note to emacs version 19 users: isearch-mode should work even if |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
65 ;; you switch windows with the mouse, in which case isearch-mode is |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
66 ;; terminated automatically before the switch. This is true of lemacs |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
67 ;; too, with a few more cleanups I've neglected in this release. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
68 ;; No one has supplied patches for epoch yet. |
725 | 69 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
70 ;; The search ring and completion commands automatically put you in |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
71 ;; the minibuffer to edit the string. This gives you a chance to |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
72 ;; modify the search string before executing the search. There are |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
73 ;; three commands to terminate the editing: C-s and C-r exit the |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
74 ;; minibuffer and search forward and reverse respectively, while C-m |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
75 ;; exits and does a nonincremental search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
76 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
77 ;; Exiting immediately from isearch uses isearch-edit-string instead |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
78 ;; of nonincremental-search, if search-nonincremental-instead is non-nil. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
79 ;; The name of this option should probably be changed if we decide to |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
80 ;; keep the behavior. No point in forcing nonincremental search until |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
81 ;; the last possible moment. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
82 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
83 ;; TODO |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
84 ;; - Integrate the emacs 19 generalized commmand history. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
85 ;; - Think about incorporating query-replace. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
86 ;; - Hooks and options for failed search. |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
87 |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
88 ;;;==================================================================== |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
89 ;;; Change History |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
90 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
91 ;;; $Header: /import/kaplan/kaplan/liberte/Isearch/RCS/isearch-mode.el,v 1.4 92/09/14 16:26:02 liberte Exp Locker: liberte $ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
92 ;;; $Log: isearch-mode.el,v $ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
93 ;;; Revision 1.4 92/09/14 16:26:02 liberte |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
94 ;;; Added prefix args to isearch-forward, etc. to switch between |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
95 ;;; string and regular expression searching. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
96 ;;; Added some support for lemacs. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
97 ;;; Added general isearch-highlight option - but only for lemacs so far. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
98 ;;; Added support for frame switching in emacs 19. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
99 ;;; Added word search option to isearch-edit-string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
100 ;;; Renamed isearch-quit to isearch-abort. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
101 ;;; Numerous changes to comments and doc strings. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
102 ;;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
103 ;;; Revision 1.3 92/06/29 13:10:08 liberte |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
104 ;;; Moved modal isearch-mode handling into isearch-mode. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
105 ;;; Got rid of buffer-local isearch variables. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
106 ;;; isearch-edit-string used by ring adjustments, completion, and |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
107 ;;; nonincremental searching. C-s and C-r are additional exit commands. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
108 ;;; Renamed all regex to regexp. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
109 ;;; Got rid of found-start and found-point globals. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
110 ;;; Generalized handling of upper-case chars. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
111 |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
112 ;;; Revision 1.2 92/05/27 11:33:57 liberte |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
113 ;;; Emacs version 19 has a search ring, which is supported here. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
114 ;;; Other fixes found in the version 19 isearch are included here. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
115 ;;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
116 ;;; Also see variables search-caps-disable-folding, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
117 ;;; search-nonincremental-instead, search-whitespace-regexp, and |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
118 ;;; commands isearch-toggle-regexp, isearch-edit-string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
119 ;;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
120 ;;; semi-modal isearching is supported. |
792
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
121 |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
122 ;;; Changes for 1.1 |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
123 ;;; 3/18/92 Fixed invalid-regexp. |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
124 ;;; 3/18/92 Fixed yanking in regexps. |
45d748a65f24
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
725
diff
changeset
|
125 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
126 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
127 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
128 ;;;========================================================================= |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
129 ;;; Emacs features |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
130 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
131 ;; isearch-mode takes advantage of the features provided by several |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
132 ;; different versions of emacs. Rather than testing the version of |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
133 ;; emacs, several constants are defined, one for each of the features. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
134 ;; Each of the tests below must work on any version of emacs. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
135 ;; (Perhaps provide and featurep could be used for this purpose.) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
136 |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
137 (defconst isearch-frames-exist (fboundp 'select-frame)) ;; emacs 19 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
138 (defconst isearch-pre-command-hook-exists (boundp 'pre-command-hook)) ;; lemacs |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
139 (defconst isearch-event-data-type nil) ;; lemacs |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
140 |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
141 (defconst search-exit-option t |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
142 "*Non-nil means random control characters terminate incremental search.") |
725 | 143 |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
144 (defvar search-slow-window-lines 1 |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
145 "*Number of lines in slow search display windows. |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
146 These are the short windows used during incremental search on slow terminals. |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
147 Negative means put the slow search window at the top (normally it's at bottom) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
148 and the value is minus the number of lines.") |
725 | 149 |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
150 (defvar search-slow-speed 1200 |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
151 "*Highest terminal speed at which to use \"slow\" style incremental search. |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
152 This is the style where a one-line window is created to show the line |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
153 that the search has reached.") |
725 | 154 |
155 ;;;======================================================================== | |
156 ;;; Some additional options and constants. | |
157 | |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
158 (defvar search-upper-case t |
725 | 159 "*If non-nil, upper case chars disable case fold searching. |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
160 That is, upper and lower case chars must match exactly. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
161 This applies no matter where the chars come from, but does not |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
162 apply to chars in regexps that are prefixed with `\\'. |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
163 If this value is `not-yanks', yanked text is always downcased.") |
725 | 164 |
165 (defvar search-nonincremental-instead t | |
166 "*If non-nil, do a nonincremental search instead if exiting immediately. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
167 Actually, `isearch-edit-string' is called to let you enter the search |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
168 string, and RET terminates editing and does a nonincremental search.") |
725 | 169 |
170 (defconst search-whitespace-regexp "\\s-+" | |
171 "*If non-nil, regular expression to match a sequence of whitespace chars. | |
172 You might want to use something like \"[ \\t\\r\\n]+\" instead.") | |
173 | |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
174 ;; I removed the * from the doc string because highlighting is not |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
175 ;; currently a clean thing to do. Once highlighting is made clean, |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
176 ;; this feature can be re-enabled and advertised. |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
177 (defvar search-highlight nil |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
178 "Whether isearch and query-replace should highlight the text which |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
179 currently matches the search-string.") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
180 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
181 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
182 (defvar isearch-mode-hook nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
183 "Function(s) to call after starting up an incremental search.") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
184 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
185 (defvar isearch-mode-end-hook nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
186 "Function(s) to call after terminating an incremental search.") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
187 |
725 | 188 ;;;================================================================== |
189 ;;; Search ring. | |
190 | |
191 (defvar search-ring nil | |
192 "List of search string sequences.") | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
193 (defvar regexp-search-ring nil |
725 | 194 "List of regular expression search string sequences.") |
195 | |
196 (defconst search-ring-max 16 | |
197 "*Maximum length of search ring before oldest elements are thrown away.") | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
198 (defconst regexp-search-ring-max 16 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
199 "*Maximum length of regexp search ring before oldest elements are thrown away.") |
725 | 200 |
201 (defvar search-ring-yank-pointer nil | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
202 "Index in `search-ring' of last string reused. |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
203 nil if none yet.") |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
204 (defvar regexp-search-ring-yank-pointer nil |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
205 "Index in `regexp-search-ring' of last string reused. |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
206 nil if none yet.") |
725 | 207 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
208 (defvar search-ring-update nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
209 "*Non-nil if advancing or retreating in the search ring should cause search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
210 Default value, nil, means edit the string instead.") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
211 |
725 | 212 ;;;==================================================== |
213 ;;; Define isearch-mode keymap. | |
214 | |
215 (defvar isearch-mode-map nil | |
216 "Keymap for isearch-mode.") | |
217 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
218 (or isearch-mode-map |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
219 (let* ((i 0) |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
220 (map (make-keymap))) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
221 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
222 ;; Control chars, by default, end isearch mode transparently. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
223 (while (< i ?\ ) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
224 (define-key map (make-string 1 i) 'isearch-other-control-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
225 (setq i (1+ i))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
226 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
227 ;; Printing chars extend the selection by default. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
228 ;; This assumes that all remaining chars are printable. |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
229 (while (< i 128) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
230 (define-key map (make-string 1 i) 'isearch-printing-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
231 (setq i (1+ i))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
232 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
233 ;; Several non-printing chars change the searching behavior. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
234 (define-key map "\C-s" 'isearch-repeat-forward) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
235 (define-key map "\C-r" 'isearch-repeat-backward) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
236 (define-key map "\177" 'isearch-delete-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
237 (define-key map "\C-g" 'isearch-abort) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
238 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
239 (define-key map "\C-q" 'isearch-quote-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
240 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
241 ;; (define-key map "\r" 'isearch-return-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
242 ;; For version 19, RET (C-m) terminates search and LFD (C-j) matches eol. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
243 ;; We could make this conditional. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
244 (define-key map "\r" 'isearch-exit) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
245 (define-key map "\C-j" 'isearch-printing-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
246 (define-key map "\t" 'isearch-printing-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
247 (define-key map " " 'isearch-whitespace-chars) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
248 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
249 (define-key map "\C-w" 'isearch-yank-word) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
250 (define-key map "\C-y" 'isearch-yank-line) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
251 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
252 ;; Define keys for regexp chars * ? |. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
253 ;; Nothing special for + because it matches at least once. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
254 (define-key map "*" 'isearch-*-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
255 (define-key map "?" 'isearch-*-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
256 (define-key map "|" 'isearch-|-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
257 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
258 ;; You can reenable global keys by binding them locally to nil. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
259 ;; For the help char this doesnt work quite as expected because |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
260 ;; isearch-mode is not a major mode. Also the echo area is not |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
261 ;; restored after the help command while isearch-mode is |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
262 ;; still active. Furthermore, we should not assume that the |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
263 ;; help-command is on C-h. But here is how it would be done: |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
264 ;; (define-key map "\C-h" nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
265 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
266 ;; Instead bind C-h to special help command for isearch-mode. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
267 (define-key map "\C-h" 'isearch-mode-help) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
268 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
269 ;; To handle local bindings with meta char prefix keys, define |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
270 ;; another full keymap. This must be done for any other prefix |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
271 ;; keys as well, one full keymap per char of the prefix key. It |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
272 ;; would be simpler to disable the global keymap, and/or have a |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
273 ;; default local key binding for any key not otherwise bound. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
274 (define-key map (char-to-string meta-prefix-char) (make-keymap)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
275 (setq i 0) |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
276 (while (< i 128) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
277 (define-key map (char-to-string (+ 128 i));; Needs to be generalized. |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
278 'isearch-other-meta-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
279 (setq i (1+ i))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
280 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
281 (define-key map "\M-n" 'isearch-ring-advance) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
282 (define-key map "\M-p" 'isearch-ring-retreat) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
283 (define-key map "\M-\t" 'isearch-complete) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
284 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
285 ;; For emacs 19, switching frames should terminate isearch-mode |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
286 (if isearch-frames-exist |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
287 (define-key map [switch-frame] 'isearch-switch-frame-handler)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
288 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
289 (setq isearch-mode-map map) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
290 )) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
291 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
292 ;; Some bindings you may want to put in your isearch-mode-hook. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
293 ;; Suggest some alternates... |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
294 ;; (define-key isearch-mode-map "\C-t" 'isearch-toggle-regexp) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
295 ;; (define-key isearch-mode-map "\C-^" 'isearch-edit-string) |
725 | 296 |
297 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
298 (defvar minibuffer-local-isearch-map nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
299 "Keymap for editing isearch strings in the minibuffer.") |
725 | 300 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
301 (or minibuffer-local-isearch-map |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
302 (let ((map (copy-keymap minibuffer-local-map))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
303 (define-key map "\r" 'isearch-nonincremental-exit-minibuffer) |
1184 | 304 (define-key map "\M-n" 'isearch-ring-advance-edit) |
305 (define-key map "\M-p" 'isearch-ring-retreat-edit) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
306 (define-key map "\M-\t" 'isearch-complete-edit) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
307 (define-key map "\C-s" 'isearch-forward-exit-minibuffer) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
308 (define-key map "\C-r" 'isearch-reverse-exit-minibuffer) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
309 (setq minibuffer-local-isearch-map map) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
310 )) |
725 | 311 |
312 ;;;======================================================== | |
313 ;; Internal variables declared globally for byte-compiler. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
314 ;; These are all set with setq while isearching |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
315 ;; and bound locally while editing the search string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
316 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
317 (defvar isearch-forward nil) ; Searching in the forward direction. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
318 (defvar isearch-regexp nil) ; Searching for a regexp. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
319 (defvar isearch-word nil) ; Searching for words. |
725 | 320 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
321 (defvar isearch-cmds nil) ; Stack of search status sets. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
322 (defvar isearch-string "") ; The current search string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
323 (defvar isearch-message "") ; text-char-description version of isearch-string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
324 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
325 (defvar isearch-success t) ; Searching is currently successful. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
326 (defvar isearch-invalid-regexp nil) ; Regexp not well formed. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
327 (defvar isearch-other-end nil) ; Start (end) of match if forward (backward). |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
328 (defvar isearch-wrapped nil) ; Searching restarted from the top (bottom). |
725 | 329 (defvar isearch-barrier 0) |
330 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
331 (defvar isearch-case-fold-search nil) ; case-fold-search while searching. |
725 | 332 |
333 (defvar isearch-adjusted nil) | |
334 (defvar isearch-slow-terminal-mode nil) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
335 ;;; If t, using a small window. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
336 (defvar isearch-small-window nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
337 (defvar isearch-opoint 0) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
338 ;;; The window configuration active at the beginning of the search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
339 (defvar isearch-window-configuration nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
340 (defvar isearch-old-local-map nil) |
725 | 341 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
342 ;; Flag to indicate a yank occurred, so don't move the cursor. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
343 (defvar isearch-yank-flag nil) |
725 | 344 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
345 ;;; A function to be called after each input character is processed. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
346 ;;; (It is not called after characters that exit the search.) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
347 ;;; It is only set from an optional argument to `isearch-mode'. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
348 (defvar isearch-op-fun nil) |
725 | 349 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
350 ;;; Is isearch-mode in a recursive edit for modal searching. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
351 (defvar isearch-recursive-edit nil) |
725 | 352 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
353 ;;; Should isearch be terminated after doing one search? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
354 (defvar isearch-nonincremental nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
355 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
356 ;; New value of isearch-forward after isearch-edit-string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
357 (defvar isearch-new-forward nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
358 |
725 | 359 |
360 ;;;============================================================== | |
361 ;; Minor-mode-alist changes - kind of redundant with the | |
362 ;; echo area, but if isearching in multiple windows, it can be useful. | |
363 | |
364 (or (assq 'isearch-mode minor-mode-alist) | |
365 (nconc minor-mode-alist | |
366 (list '(isearch-mode isearch-mode)))) | |
367 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
368 (defvar isearch-mode nil) ;; Name of the minor mode, if non-nil. |
725 | 369 (make-variable-buffer-local 'isearch-mode) |
370 | |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
371 (define-key global-map "\C-s" 'isearch-forward) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
372 (define-key esc-map "\C-s" 'isearch-forward-regexp) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
373 (define-key global-map "\C-r" 'isearch-backward) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
374 (define-key esc-map "\C-r" 'isearch-backward-regexp) |
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
375 |
725 | 376 ;;;=============================================================== |
377 ;;; Entry points to isearch-mode. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
378 ;;; These four functions should replace those in loaddefs.el |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
379 ;;; An alternative is to fset isearch-forward etc to isearch-mode, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
380 ;;; and look at this-command to set the options accordingly. |
725 | 381 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
382 (defun isearch-forward (&optional regexp-p) |
725 | 383 "\ |
384 Do incremental search forward. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
385 With a prefix argument, do an incremental regular expression search instead. |
725 | 386 \\<isearch-mode-map> |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
387 As you type characters, they add to the search string and are found. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
388 The following non-printing keys are bound in `isearch-mode-map'. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
389 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
390 Type \\[isearch-delete-char] to cancel characters from end of search string. |
725 | 391 Type \\[isearch-exit] to exit, leaving point at location found. |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
392 Type LFD (C-j) to match end of line. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
393 Type \\[isearch-repeat-forward] to search again forward,\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
394 \\[isearch-repeat-backward] to search again backward. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
395 Type \\[isearch-yank-word] to yank word from buffer onto end of search\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
396 string and search for it. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
397 Type \\[isearch-yank-line] to yank rest of line onto end of search string\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
398 and search for it. |
725 | 399 Type \\[isearch-quote-char] to quote control character to search for it. |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
400 Type \\[isearch-whitespace-chars] to match all whitespace chars in regexp. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
401 \\[isearch-abort] while searching or when search has failed cancels input\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
402 back to what has |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
403 been found successfully. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
404 \\[isearch-abort] when search is successful aborts and moves point to\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
405 starting point. |
725 | 406 |
407 Also supported is a search ring of the previous 16 search strings. | |
408 Type \\[isearch-ring-advance] to search for the next item in the search ring. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
409 Type \\[isearch-ring-retreat] to search for the previous item in the search\ |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
410 ring. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
411 Type \\[isearch-complete] to complete the search string using the search ring. |
725 | 412 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
413 The above keys, bound in `isearch-mode-map', are often controlled by |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
414 options; do M-x apropos on search-.* to find them. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
415 Other control and meta characters terminate the search |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
416 and are then executed normally (depending on `search-exit-option'). |
725 | 417 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
418 If this function is called non-interactively, it does not return to |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
419 the calling function until the search is done." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
420 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
421 (interactive "P") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
422 (isearch-mode t (not (null regexp-p)) nil (not (interactive-p)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
423 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
424 (defun isearch-forward-regexp (&optional regexp-p) |
725 | 425 "\ |
426 Do incremental search forward for regular expression. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
427 With a prefix argument, do a regular string search instead. |
725 | 428 Like ordinary incremental search except that your input |
429 is treated as a regexp. See \\[isearch-forward] for more info." | |
430 (interactive) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
431 (isearch-mode t (null regexp-p) nil (not (interactive-p)))) |
725 | 432 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
433 (defun isearch-backward (&optional regexp-p) |
725 | 434 "\ |
435 Do incremental search backward. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
436 With a prefix argument, do a regular expression search instead. |
725 | 437 See \\[isearch-forward] for more information." |
438 (interactive) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
439 (isearch-mode nil (not (null regexp-p)) nil (not (interactive-p)))) |
725 | 440 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
441 (defun isearch-backward-regexp (&optional regexp-p) |
725 | 442 "\ |
443 Do incremental search backward for regular expression. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
444 With a prefix argument, do a regular string search instead. |
725 | 445 Like ordinary incremental search except that your input |
446 is treated as a regexp. See \\[isearch-forward] for more info." | |
447 (interactive) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
448 (isearch-mode nil (null regexp-p) nil (not (interactive-p)))) |
725 | 449 |
450 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
451 (defun isearch-mode-help () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
452 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
453 (describe-function 'isearch-forward) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
454 (isearch-update)) |
725 | 455 |
456 | |
457 ;;;================================================================== | |
458 ;; isearch-mode only sets up incremental search for the minor mode. | |
459 ;; All the work is done by the isearch-mode commands. | |
460 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
461 ;; Not used yet: |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
462 ;;(defconst isearch-commands '(isearch-forward isearch-backward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
463 ;; isearch-forward-regexp isearch-backward-regexp) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
464 ;; "List of commands for which isearch-mode does not recursive-edit.") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
465 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
466 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
467 (defun isearch-mode (forward &optional regexp op-fun recursive-edit word-p) |
725 | 468 "Start isearch minor mode. Called by isearch-forward, etc." |
469 | |
470 ;; Initialize global vars. | |
471 (setq isearch-forward forward | |
472 isearch-regexp regexp | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
473 isearch-word word-p |
725 | 474 isearch-op-fun op-fun |
475 isearch-case-fold-search case-fold-search | |
476 isearch-string "" | |
477 isearch-message "" | |
478 isearch-cmds nil | |
479 isearch-success t | |
480 isearch-wrapped nil | |
481 isearch-barrier (point) | |
482 isearch-adjusted nil | |
483 isearch-yank-flag nil | |
484 isearch-invalid-regexp nil | |
1162 | 485 ;; Use (baud-rate) for now, for sake of other versions. |
486 isearch-slow-terminal-mode (and (<= (baud-rate) search-slow-speed) | |
725 | 487 (> (window-height) |
488 (* 4 search-slow-window-lines))) | |
489 isearch-other-end nil | |
490 isearch-small-window nil | |
491 | |
492 isearch-opoint (point) | |
493 isearch-window-configuration (current-window-configuration) | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
494 isearch-old-local-map (current-local-map) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
495 search-ring-yank-pointer nil |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
496 regexp-search-ring-yank-pointer nil) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
497 (if isearch-pre-command-hook-exists |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
498 (add-hook 'pre-command-hook 'isearch-pre-command-hook)) |
725 | 499 (setq isearch-mode " Isearch") ;; forward? regexp? |
500 (set-buffer-modified-p (buffer-modified-p)) ; update modeline | |
501 | |
502 (isearch-push-state) | |
503 | |
504 (use-local-map isearch-mode-map) | |
505 (isearch-update) | |
506 (run-hooks 'isearch-mode-hook) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
507 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
508 ;; isearch-mode can be made modal (in the sense of not returning to |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
509 ;; the calling function until searching is completed) by entering |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
510 ;; a recursive-edit and exiting it when done isearching. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
511 (if recursive-edit (recursive-edit)) |
725 | 512 ) |
513 | |
514 | |
515 ;;;==================================================== | |
516 ;; Some high level utilities. Others below. | |
517 | |
518 (defun isearch-update () | |
519 ;; Called after each command to update the display. | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
520 (if (if isearch-event-data-type |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
521 (null unread-command-event) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
522 (if isearch-frames-exist |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
523 (null unread-command-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
524 (< unread-command-char 0))) |
725 | 525 (progn |
526 (if (not (input-pending-p)) | |
527 (isearch-message)) | |
528 (if (and isearch-slow-terminal-mode | |
529 (not (or isearch-small-window | |
530 (pos-visible-in-window-p)))) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
531 (let ((found-point (point))) |
725 | 532 (setq isearch-small-window t) |
533 (move-to-window-line 0) | |
534 (let ((window-min-height 1)) | |
535 (split-window nil (if (< search-slow-window-lines 0) | |
536 (1+ (- search-slow-window-lines)) | |
537 (- (window-height) | |
538 (1+ search-slow-window-lines))))) | |
539 (if (< search-slow-window-lines 0) | |
540 (progn (vertical-motion (- 1 search-slow-window-lines)) | |
541 (set-window-start (next-window) (point)) | |
542 (set-window-hscroll (next-window) | |
543 (window-hscroll)) | |
544 (set-window-hscroll (selected-window) 0)) | |
545 (other-window 1)) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
546 (goto-char found-point))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
547 (if isearch-other-end |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
548 (if (< isearch-other-end (point)) ; isearch-forward? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
549 (isearch-highlight isearch-other-end (point)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
550 (isearch-highlight (point) isearch-other-end))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
551 )) |
725 | 552 (setq ;; quit-flag nil not for isearch-mode |
553 isearch-adjusted nil | |
554 isearch-yank-flag nil) | |
555 ) | |
556 | |
557 | |
1184 | 558 (defun isearch-done (&optional nopush) |
725 | 559 ;; Called by all commands that terminate isearch-mode. |
1184 | 560 ;; If NOPUSH is non-nil, we don't push the string on the search ring. |
725 | 561 (use-local-map isearch-old-local-map) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
562 ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
563 (isearch-dehighlight t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
564 (let ((found-start (window-start (selected-window))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
565 (found-point (point))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
566 (set-window-configuration isearch-window-configuration) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
567 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
568 ;; If there was movement, mark the starting position. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
569 ;; Maybe should test difference between and set mark iff > threshold. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
570 (if (/= (point) isearch-opoint) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
571 (push-mark isearch-opoint) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
572 ;; (message "") why is this needed? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
573 ) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
574 (if isearch-small-window |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
575 (goto-char found-point) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
576 ;; Exiting the save-window-excursion clobbers window-start; restore it. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
577 (set-window-start (selected-window) found-start t))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
578 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
579 (setq isearch-mode nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
580 (set-buffer-modified-p (buffer-modified-p)) ;; update modeline |
725 | 581 |
1184 | 582 (if (and (> (length isearch-string) 0) (not nopush)) |
725 | 583 ;; Update the ring data. |
584 (if isearch-regexp | |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
585 (if (or (null regexp-search-ring) |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
586 (not (string= isearch-string (car regexp-search-ring)))) |
725 | 587 (progn |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
588 (setq regexp-search-ring |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
589 (cons isearch-string regexp-search-ring)) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
590 (if (> (length regexp-search-ring) regexp-search-ring-max) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
591 (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) |
725 | 592 nil)))) |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
593 (if (or (null search-ring) |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
594 (not (string= isearch-string (car search-ring)))) |
725 | 595 (progn |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
596 (setq search-ring (cons isearch-string search-ring)) |
725 | 597 (if (> (length search-ring) search-ring-max) |
598 (setcdr (nthcdr (1- search-ring-max) search-ring) nil)))))) | |
599 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
600 (run-hooks 'isearch-mode-end-hook) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
601 (if isearch-recursive-edit (exit-recursive-edit))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
602 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
603 ;;;======================================================= |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
604 ;;; Switching buffers should first terminate isearch-mode. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
605 ;;; This is done quite differently for each varient of emacs. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
606 ;;; For lemacs, see Exiting in lemacs below |
725 | 607 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
608 ;; For Emacs 19, the frame switch event is handled. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
609 (defun isearch-switch-frame-handler () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
610 (interactive) ;; Is this necessary? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
611 ;; First terminate isearch-mode. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
612 (isearch-done) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
613 (select-frame (car (cdr (isearch-last-command-char))))) |
725 | 614 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
615 ;;;======================================================== |
725 | 616 |
617 | |
618 ;;;==================================================== | |
619 ;; Commands active while inside of the isearch minor mode. | |
620 | |
621 (defun isearch-exit () | |
622 "Exit search normally. | |
623 However, if this is the first command after starting incremental | |
624 search and `search-nonincremental-instead' is non-nil, do a | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
625 nonincremental search instead via `isearch-edit-string'." |
725 | 626 (interactive) |
627 (if (and search-nonincremental-instead | |
628 (= 0 (length isearch-string))) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
629 (let ((isearch-nonincremental t)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
630 (isearch-edit-string))) |
725 | 631 (isearch-done)) |
632 | |
633 | |
634 (defun isearch-edit-string () | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
635 "Edit the search string in the minibuffer. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
636 The following additional command keys are active while editing. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
637 \\<minibuffer-local-isearch-map> |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
638 \\[exit-minibuffer] to resume incremental searching with the edited string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
639 \\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
640 \\[isearch-forward-exit-minibuffer] to resume isearching forward. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
641 \\[isearch-backward-exit-minibuffer] to resume isearching backward. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
642 \\[isearch-ring-advance-edit] to replace the search string with the next item in the search ring. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
643 \\[isearch-ring-retreat-edit] to replace the search string with the previou item in the search ring. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
644 \\[isearch-complete-edit] to complete the search string using the search ring. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
645 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
646 If first char entered is \\[isearch-yank-word], then do word search instead." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
647 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
648 ;; This code is very hairy for several reasons, explained in the code. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
649 ;; Mainly, isearch-mode must be terminated while editing and then restarted. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
650 ;; If there were a way to catch any change of buffer from the minibuffer, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
651 ;; this could be simplified greatly. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
652 ;; Editing doesnt back up the search point. Should it? |
725 | 653 (interactive) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
654 (condition-case err |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
655 (let (isearch-nonincremental ; should search nonincrementally? |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
656 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
657 ;; Locally bind all isearch global variables to protect them |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
658 ;; from recursive isearching. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
659 ;; isearch-string -message and -forward are not bound |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
660 ;; so they may be changed. Instead, save the values. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
661 (isearch-new-string isearch-string) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
662 (isearch-new-message isearch-message) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
663 (isearch-new-forward isearch-forward) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
664 (isearch-new-word isearch-word) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
665 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
666 (isearch-regexp isearch-regexp) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
667 (isearch-op-fun isearch-op-fun) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
668 (isearch-cmds isearch-cmds) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
669 (isearch-success isearch-success) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
670 (isearch-wrapped isearch-wrapped) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
671 (isearch-barrier isearch-barrier) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
672 (isearch-adjusted isearch-adjusted) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
673 (isearch-yank-flag isearch-yank-flag) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
674 (isearch-invalid-regexp isearch-invalid-regexp) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
675 (isearch-other-end isearch-other-end) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
676 (isearch-opoint isearch-opoint) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
677 (isearch-slow-terminal-mode isearch-slow-terminal-mode) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
678 (isearch-small-window isearch-small-window) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
679 (isearch-recursive-edit isearch-recursive-edit) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
680 ;; Save current configuration so we can restore it here. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
681 (isearch-window-configuration (current-window-configuration)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
682 ) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
683 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
684 ;; Actually terminate isearching until editing is done. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
685 ;; This is so that the user can do anything without failure, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
686 ;; like switch buffers and start another isearch, and return. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
687 (condition-case err |
1184 | 688 (isearch-done t) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
689 (exit nil)) ; was recursive editing |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
690 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
691 (isearch-message) ;; for read-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
692 (unwind-protect |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
693 (let* (;; Why does following read-char echo? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
694 ;;(echo-keystrokes 0) ;; not needed with above message |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
695 (cursor-in-echo-area t) |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
696 (e (if isearch-event-data-type (allocate-event) (read-char))) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
697 ;; Binding minibuffer-history-symbol to nil is a work-around |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
698 ;; for some incompatibility with gmhist. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
699 (minibuffer-history-symbol)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
700 ;; If the first character the user types when we prompt them |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
701 ;; for a string is the yank-word character, then go into |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
702 ;; word-search mode. Otherwise unread that character and |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
703 ;; read a key the normal way. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
704 ;; Word search does not apply (yet) to regexp searches, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
705 ;; no check is made here. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
706 (message (isearch-message-prefix nil nil t)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
707 (if (eq 'isearch-yank-word |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
708 (lookup-key |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
709 isearch-mode-map |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
710 (char-to-string |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
711 (if isearch-event-data-type |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
712 (or (event-to-character (next-command-event e)) 0) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
713 e)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
714 (setq isearch-word t ;; so message-prefix is right |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
715 isearch-new-word t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
716 (isearch-unread e)) |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
717 (setq cursor-in-echo-area nil) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
718 (setq isearch-new-string |
1184 | 719 (let (junk-ring) |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
720 (read-from-minibuffer (isearch-message-prefix) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
721 isearch-string |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
722 minibuffer-local-isearch-map nil |
1184 | 723 'junk-ring)) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
724 isearch-new-message (mapconcat 'text-char-description |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
725 isearch-new-string ""))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
726 ;; Always resume isearching by restarting it. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
727 (isearch-mode isearch-forward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
728 isearch-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
729 isearch-op-fun |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
730 isearch-recursive-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
731 isearch-word) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
732 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
733 ;; Copy new local values to isearch globals |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
734 (setq isearch-string isearch-new-string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
735 isearch-message isearch-new-message |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
736 isearch-forward isearch-new-forward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
737 isearch-word isearch-new-word)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
738 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
739 ;; Empty isearch-string means use default. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
740 (if (= 0 (length isearch-string)) |
1169
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
741 (setq isearch-string (car (if isearch-regexp regexp-search-ring |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
742 search-ring))) |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
743 ;; This used to set the last search string, |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
744 ;; but I think it is not right to do that here. |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
745 ;; Only the string actually used should be saved. |
a40b54fcb2ff
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1162
diff
changeset
|
746 ) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
747 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
748 ;; Reinvoke the pending search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
749 (isearch-push-state) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
750 (isearch-search) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
751 (isearch-update) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
752 (if isearch-nonincremental |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
753 (progn |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
754 ;; (sit-for 1) ;; needed if isearch-done does: (message "") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
755 (isearch-done)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
756 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
757 (quit ; handle abort-recursive-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
758 (isearch-abort) ;; outside of let to restore outside global values |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
759 ))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
760 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
761 (defun isearch-nonincremental-exit-minibuffer () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
762 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
763 (setq isearch-nonincremental t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
764 (exit-minibuffer)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
765 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
766 (defun isearch-forward-exit-minibuffer () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
767 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
768 (setq isearch-new-forward t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
769 (exit-minibuffer)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
770 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
771 (defun isearch-reverse-exit-minibuffer () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
772 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
773 (setq isearch-new-forward nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
774 (exit-minibuffer)) |
725 | 775 |
776 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
777 (defun isearch-abort () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
778 "Abort incremental search mode if searching is successful, signalling quit. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
779 Otherwise, revert to previous successful search and continue searching. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
780 Use `isearch-exit' to quit without signalling." |
725 | 781 (interactive) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
782 ;; (ding) signal instead below, if quiting |
725 | 783 (discard-input) |
784 (if isearch-success | |
785 ;; If search is successful, move back to starting point | |
786 ;; and really do quit. | |
787 (progn (goto-char isearch-opoint) | |
1184 | 788 (isearch-done t) ; exit isearch |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
789 (signal 'quit nil)) ; and pass on quit signal |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
790 ;; If search is failing, rub out until it is once more successful. |
725 | 791 (while (not isearch-success) (isearch-pop-state)) |
792 (isearch-update))) | |
793 | |
794 | |
795 (defun isearch-repeat (direction) | |
796 ;; Utility for isearch-repeat-forward and -backward. | |
797 (if (eq isearch-forward (eq direction 'forward)) | |
798 ;; C-s in forward or C-r in reverse. | |
799 (if (equal isearch-string "") | |
800 ;; If search string is empty, use last one. | |
801 (setq isearch-string | |
802 (or (if isearch-regexp | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
803 (car regexp-search-ring) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
804 (car search-ring)) |
725 | 805 "") |
806 isearch-message | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
807 (mapconcat 'isearch-text-char-description |
725 | 808 isearch-string "")) |
809 ;; If already have what to search for, repeat it. | |
810 (or isearch-success | |
811 (progn | |
812 | |
813 (goto-char (if isearch-forward (point-min) (point-max))) | |
814 (setq isearch-wrapped t)))) | |
815 ;; C-s in reverse or C-r in forward, change direction. | |
816 (setq isearch-forward (not isearch-forward))) | |
817 | |
818 (setq isearch-barrier (point)) ; For subsequent \| if regexp. | |
819 (setq isearch-success t) | |
820 (or (equal isearch-string "") | |
821 (progn | |
822 ;; If repeating a search that found | |
823 ;; an empty string, ensure we advance. | |
824 (if (equal (match-end 0) (match-beginning 0)) | |
825 (forward-char (if isearch-forward 1 -1))) | |
826 (isearch-search))) | |
827 (isearch-push-state) | |
828 (isearch-update)) | |
829 | |
830 (defun isearch-repeat-forward () | |
831 "Repeat incremental search forwards." | |
832 (interactive) | |
833 (isearch-repeat 'forward)) | |
834 | |
835 (defun isearch-repeat-backward () | |
836 "Repeat incremental search backwards." | |
837 (interactive) | |
838 (isearch-repeat 'backward)) | |
839 | |
840 (defun isearch-toggle-regexp () | |
841 "Toggle regexp searching on or off." | |
842 ;; The status stack is left unchanged. | |
843 (interactive) | |
844 (setq isearch-regexp (not isearch-regexp)) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
845 (if isearch-regexp (setq isearch-word nil)) |
725 | 846 (isearch-update)) |
847 | |
848 (defun isearch-delete-char () | |
849 "Discard last input item and move point back. | |
850 If no previous match was done, just beep." | |
851 (interactive) | |
852 (if (null (cdr isearch-cmds)) | |
853 (ding) | |
854 (isearch-pop-state)) | |
855 (isearch-update)) | |
856 | |
857 | |
858 (defun isearch-yank (chunk) | |
859 ;; Helper for isearch-yank-word and isearch-yank-line | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
860 (let ((string (save-excursion |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
861 (and (not isearch-forward) isearch-other-end |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
862 (goto-char isearch-other-end)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
863 (buffer-substring |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
864 (point) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
865 (save-excursion |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
866 (cond |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
867 ((eq chunk 'word) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
868 (forward-word 1)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
869 ((eq chunk 'line) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
870 (end-of-line))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
871 (point)))))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
872 ;; Downcase the string if not supposed to case-fold yanked strings. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
873 (if (and isearch-case-fold-search |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
874 (eq 'not-yanks search-upper-case)) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
875 (setq string (downcase string))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
876 (if isearch-regexp (setq string (regexp-quote string))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
877 (setq isearch-string (concat isearch-string string) |
725 | 878 isearch-message |
879 (concat isearch-message | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
880 (mapconcat 'isearch-text-char-description |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
881 string "")) |
725 | 882 ;; Don't move cursor in reverse search. |
883 isearch-yank-flag t)) | |
884 (isearch-search-and-update)) | |
885 | |
886 | |
887 (defun isearch-yank-word () | |
888 "Pull next word from buffer into search string." | |
889 (interactive) | |
890 (isearch-yank 'word)) | |
891 | |
892 (defun isearch-yank-line () | |
893 "Pull rest of line from buffer into search string." | |
894 (interactive) | |
895 (isearch-yank 'line)) | |
896 | |
897 | |
898 (defun isearch-search-and-update () | |
899 ;; Do the search and update the display. | |
900 (if (and (not isearch-success) | |
901 ;; unsuccessful regexp search may become | |
902 ;; successful by addition of characters which | |
903 ;; make isearch-string valid | |
904 (not isearch-regexp)) | |
905 nil | |
906 ;; In reverse search, adding stuff at | |
907 ;; the end may cause zero or many more chars to be | |
908 ;; matched, in the string following point. | |
909 ;; Allow all those possibilities without moving point as | |
910 ;; long as the match does not extend past search origin. | |
911 (if (and (not isearch-forward) (not isearch-adjusted) | |
912 (condition-case () | |
913 (looking-at (if isearch-regexp isearch-string | |
914 (regexp-quote isearch-string))) | |
915 (error nil)) | |
916 (or isearch-yank-flag | |
917 (<= (match-end 0) | |
918 (min isearch-opoint isearch-barrier)))) | |
919 (setq isearch-success t | |
920 isearch-invalid-regexp nil | |
921 isearch-other-end (match-end 0)) | |
922 ;; Not regexp, not reverse, or no match at point. | |
923 (if (and isearch-other-end (not isearch-adjusted)) | |
924 (goto-char (if isearch-forward isearch-other-end | |
925 (min isearch-opoint | |
926 isearch-barrier | |
927 (1+ isearch-other-end))))) | |
928 (isearch-search) | |
929 )) | |
930 (isearch-push-state) | |
931 (if isearch-op-fun (funcall isearch-op-fun)) | |
932 (isearch-update)) | |
933 | |
934 | |
935 ;; *, ?, and | chars can make a regexp more liberal. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
936 ;; They can make a regexp match sooner or make it succeed instead of failing. |
725 | 937 ;; So go back to place last successful search started |
938 ;; or to the last ^S/^R (barrier), whichever is nearer. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
939 ;; + needs no special handling because the string must match at least once. |
725 | 940 |
941 (defun isearch-*-char () | |
942 "Handle * and ? specially in regexps." | |
943 (interactive) | |
944 (if isearch-regexp | |
945 | |
946 (progn | |
947 (setq isearch-adjusted t) | |
948 (let ((cs (nth (if isearch-forward | |
949 5 ; isearch-other-end | |
950 2) ; saved (point) | |
951 (car (cdr isearch-cmds))))) | |
952 ;; (car isearch-cmds) is after last search; | |
953 ;; (car (cdr isearch-cmds)) is from before it. | |
954 (setq cs (or cs isearch-barrier)) | |
955 (goto-char | |
956 (if isearch-forward | |
957 (max cs isearch-barrier) | |
958 (min cs isearch-barrier)))))) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
959 (isearch-process-search-char (isearch-last-command-char))) |
725 | 960 |
961 | |
962 (defun isearch-|-char () | |
963 "If in regexp search, jump to the barrier." | |
964 (interactive) | |
965 (if isearch-regexp | |
966 (progn | |
967 (setq isearch-adjusted t) | |
968 (goto-char isearch-barrier))) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
969 (isearch-process-search-char (isearch-last-command-char))) |
725 | 970 |
971 | |
972 (defun isearch-other-control-char () | |
973 "Any other control char => unread it and exit the search normally. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
974 But only if `search-exit-option' is non-nil, the default. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
975 If it is the symbol `edit', the search string is edited in the minibuffer |
1184 | 976 and the control char is unread so that it applies to editing the string." |
725 | 977 (interactive) |
1184 | 978 (cond ((eq search-exit-option 'edit) |
979 (isearch-unread (isearch-last-command-char)) | |
980 (isearch-edit-string)) | |
981 (search-exit-option;; any other non-nil value | |
982 (isearch-unread (isearch-last-command-char)) | |
983 (isearch-done)) | |
984 (t;; search-exit-option is nil | |
985 (isearch-process-search-char (isearch-last-command-char))))) | |
725 | 986 |
987 | |
988 (defun isearch-other-meta-char () | |
1184 | 989 "Any other meta char => exit the search normally and reread the character. |
990 But only if `search-exit-option' is non-nil, the default. | |
991 If it is the symbol `edit', the search string is edited in the minibuffer | |
992 and the meta character is unread so that it applies to editing the string." | |
725 | 993 (interactive) |
1184 | 994 (cond ((eq search-exit-option 'edit) |
995 (let ((key (this-command-keys))) | |
996 (isearch-unread (+ 128 (aref key (1- (length key)))))) | |
997 (isearch-edit-string)) | |
998 (search-exit-option | |
999 (let ((key (this-command-keys))) | |
1000 (isearch-unread (+ 128 (aref key (1- (length key)))))) | |
1001 (isearch-done)) | |
1002 (t;; otherwise nil | |
1003 (isearch-process-search-string (this-command-keys) | |
1004 (this-command-keys))))) | |
725 | 1005 |
1006 | |
1007 (defun isearch-quote-char () | |
1008 "Quote special characters for incremental search." | |
1009 (interactive) | |
1010 (isearch-process-search-char (read-quoted-char (isearch-message t)))) | |
1011 | |
1012 (defun isearch-return-char () | |
1013 "Convert return into newline for incremental search. | |
1014 Obsolete." | |
1015 (interactive) | |
1016 (isearch-process-search-char ?\n)) | |
1017 | |
1018 (defun isearch-printing-char () | |
1019 "Any other printing character => add it to the search string and search." | |
1020 (interactive) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1021 (isearch-process-search-char (isearch-last-command-char))) |
725 | 1022 |
1023 (defun isearch-whitespace-chars () | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1024 "Match all whitespace chars, if in regexp mode. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1025 If not in regexp mode, activate word search." |
725 | 1026 (interactive) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1027 (if isearch-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1028 (if search-whitespace-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1029 (isearch-process-search-string search-whitespace-regexp " ") |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1030 (isearch-printing-char)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1031 (progn |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1032 ;; This way of doing word search doesnt correctly extend current search. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1033 ;; (setq isearch-word t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1034 ;; (setq isearch-adjusted t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1035 ;; (goto-char isearch-barrier) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1036 (isearch-printing-char)))) |
725 | 1037 |
1038 (defun isearch-process-search-char (char) | |
1039 ;; Append the char to the search string, update the message and re-search. | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1040 (isearch-process-search-string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1041 (isearch-char-to-string char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1042 (isearch-text-char-description char))) |
725 | 1043 |
1044 (defun isearch-process-search-string (string message) | |
1045 (setq isearch-string (concat isearch-string string) | |
1046 isearch-message (concat isearch-message message)) | |
1047 (isearch-search-and-update)) | |
1048 | |
1049 | |
1050 ;;=========================================================== | |
1051 ;; Search Ring | |
1052 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1053 (defun isearch-ring-adjust1 (advance) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1054 ;; Helper for isearch-ring-adjust |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1055 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) |
725 | 1056 (length (length ring)) |
1057 (yank-pointer-name (if isearch-regexp | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1058 'regexp-search-ring-yank-pointer |
725 | 1059 'search-ring-yank-pointer)) |
1060 (yank-pointer (eval yank-pointer-name))) | |
1061 (if (zerop length) | |
1062 () | |
1063 (set yank-pointer-name | |
1064 (setq yank-pointer | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1065 (% (+ (or yank-pointer 0) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1066 (if advance (1- length) 1)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1067 length))) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1068 (setq isearch-string (nth yank-pointer ring) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1069 isearch-message (mapconcat 'isearch-text-char-description |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1070 isearch-string ""))))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1071 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1072 (defun isearch-ring-adjust (advance) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1073 ;; Helper for isearch-ring-advance and isearch-ring-retreat |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1074 (if (cdr isearch-cmds) ;; is there more than one thing on stack? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1075 (isearch-pop-state)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1076 (isearch-ring-adjust1 advance) |
725 | 1077 (isearch-push-state) |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1078 (if search-ring-update |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1079 (progn |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1080 (isearch-search) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1081 (isearch-update)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1082 (isearch-edit-string) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1083 )) |
725 | 1084 |
1085 (defun isearch-ring-advance () | |
1086 "Advance to the next search string in the ring." | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1087 ;; This could be more general to handle a prefix arg, but who would use it. |
725 | 1088 (interactive) |
1089 (isearch-ring-adjust 'advance)) | |
1090 | |
1091 (defun isearch-ring-retreat () | |
1092 "Retreat to the previous search string in the ring." | |
1093 (interactive) | |
1094 (isearch-ring-adjust nil)) | |
1095 | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1096 (defun isearch-ring-advance-edit (n) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1097 "Insert the next element of the search history into the minibuffer." |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1098 (interactive "p") |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1099 (let* ((yank-pointer-name (if isearch-regexp |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1100 'regexp-search-ring-yank-pointer |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1101 'search-ring-yank-pointer)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1102 (yank-pointer (eval yank-pointer-name)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1103 (ring (if isearch-regexp regexp-search-ring search-ring)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1104 (length (length ring))) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1105 (if (zerop length) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1106 () |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1107 (set yank-pointer-name |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1108 (setq yank-pointer |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1109 (% (+ (or yank-pointer 0) |
1184 | 1110 ;; Add LENGTH here to ensure a positive result. |
1111 length | |
1112 (% (- n) length)) | |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1113 length))) |
725 | 1114 |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1115 (erase-buffer) |
1184 | 1116 (insert (nth yank-pointer ring)) |
1117 (goto-char (point-max)))))) | |
725 | 1118 |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1119 (defun isearch-ring-retreat-edit (n) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1120 "Inserts the previous element of the search history into the minibuffer." |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1121 (interactive "p") |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1122 (isearch-ring-advance-edit (- n))) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1123 |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1124 ;;(defun isearch-ring-adjust-edit (advance) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1125 ;; "Use the next or previous search string in the ring while in minibuffer." |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1126 ;; (isearch-ring-adjust1 advance) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1127 ;; (erase-buffer) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1128 ;; (insert isearch-string)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1129 |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1130 ;;(defun isearch-ring-advance-edit () |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1131 ;; (interactive) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1132 ;; (isearch-ring-adjust-edit 'advance)) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1133 |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1134 ;;(defun isearch-ring-retreat-edit () |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1135 ;; "Retreat to the previous search string in the ring while in the minibuffer." |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1136 ;; (interactive) |
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1137 ;; (isearch-ring-adjust-edit nil)) |
725 | 1138 |
1139 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1140 (defun isearch-complete1 () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1141 ;; Helper for isearch-complete and isearch-complete-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1142 ;; Return t if completion OK, nil if no completion exists. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1143 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1144 (alist (mapcar (function (lambda (string) (list string))) ring)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1145 (completion-ignore-case case-fold-search) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1146 (completion (try-completion isearch-string alist))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1147 (cond |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1148 ((eq completion t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1149 ;; isearch-string stays the same |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1150 t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1151 ((or completion ; not nil, must be a string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1152 (= 0 (length isearch-string))) ; shouldnt have to say this |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1153 (if (equal completion isearch-string) ;; no extension? |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1154 (if completion-auto-help |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1155 (with-output-to-temp-buffer "*Isearch completions*" |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1156 (display-completion-list |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1157 (all-completions isearch-string alist)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1158 (setq isearch-string completion)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1159 t) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1160 (t |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1161 (message "No completion") ; waits a second if in minibuffer |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1162 nil)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1163 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1164 (defun isearch-complete () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1165 "Complete the search string from the strings on the search ring. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1166 The completed string is then editable in the minibuffer. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1167 If there is no completion possible, say so and continue searching." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1168 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1169 (if (isearch-complete1) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1170 (isearch-edit-string) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1171 ;; else |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1172 (sit-for 1) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1173 (isearch-update))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1174 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1175 (defun isearch-complete-edit () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1176 "Same as `isearch-complete' except in the minibuffer." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1177 (interactive) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1178 (setq isearch-string (buffer-string)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1179 (if (isearch-complete1) |
725 | 1180 (progn |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1181 (erase-buffer) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1182 (insert isearch-string)))) |
725 | 1183 |
1184 | |
1185 ;;;============================================================== | |
1186 ;; The search status stack (and isearch window-local variables, not used). | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1187 ;; Need a structure for this. |
725 | 1188 |
1189 (defun isearch-top-state () | |
1190 (let ((cmd (car isearch-cmds))) | |
1191 (setq isearch-string (car cmd) | |
1192 isearch-message (car (cdr cmd)) | |
1193 isearch-success (nth 3 cmd) | |
1194 isearch-forward (nth 4 cmd) | |
1195 isearch-other-end (nth 5 cmd) | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1196 isearch-word (nth 6 cmd) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1197 isearch-invalid-regexp (nth 7 cmd) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1198 isearch-wrapped (nth 8 cmd) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1199 isearch-barrier (nth 9 cmd)) |
725 | 1200 (goto-char (car (cdr (cdr cmd)))))) |
1201 | |
1202 (defun isearch-pop-state () | |
1203 (setq isearch-cmds (cdr isearch-cmds)) | |
1204 (isearch-top-state) | |
1205 ) | |
1206 | |
1207 (defun isearch-push-state () | |
1208 (setq isearch-cmds | |
1209 (cons (list isearch-string isearch-message (point) | |
1210 isearch-success isearch-forward isearch-other-end | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1211 isearch-word |
725 | 1212 isearch-invalid-regexp isearch-wrapped isearch-barrier) |
1213 isearch-cmds))) | |
1214 | |
1215 | |
1216 ;;;================================================================== | |
1217 ;; Message string | |
1218 | |
1219 (defun isearch-message (&optional c-q-hack ellipsis) | |
1220 ;; Generate and print the message string. | |
1221 (let ((cursor-in-echo-area ellipsis) | |
1222 (m (concat | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1223 (isearch-message-prefix c-q-hack ellipsis isearch-nonincremental) |
725 | 1224 isearch-message |
1225 (isearch-message-suffix c-q-hack ellipsis) | |
1226 ))) | |
1227 (if c-q-hack m (message "%s" m)))) | |
1228 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1229 (defun isearch-message-prefix (&optional c-q-hack ellipsis nonincremental) |
725 | 1230 ;; If about to search, and previous search regexp was invalid, |
1231 ;; check that it still is. If it is valid now, | |
1232 ;; let the message we display while searching say that it is valid. | |
1233 (and isearch-invalid-regexp ellipsis | |
1234 (condition-case () | |
1235 (progn (re-search-forward isearch-string (point) t) | |
1236 (setq isearch-invalid-regexp nil)) | |
1237 (error nil))) | |
1238 ;; If currently failing, display no ellipsis. | |
1239 (or isearch-success (setq ellipsis nil)) | |
1240 (let ((m (concat (if isearch-success "" "failing ") | |
1241 (if isearch-wrapped "wrapped ") | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1242 (if isearch-word "word " "") |
725 | 1243 (if isearch-regexp "regexp " "") |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1244 (if nonincremental "search" "I-search") |
725 | 1245 (if isearch-forward ": " " backward: ") |
1246 ))) | |
1247 (aset m 0 (upcase (aref m 0))) | |
1248 m)) | |
1249 | |
1250 | |
1251 (defun isearch-message-suffix (&optional c-q-hack ellipsis) | |
1252 (concat (if c-q-hack "^Q" "") | |
1253 (if isearch-invalid-regexp | |
1254 (concat " [" isearch-invalid-regexp "]") | |
1255 ""))) | |
1256 | |
1257 | |
1258 ;;;======================================================== | |
1259 ;;; Searching | |
1260 | |
1261 (defun isearch-search () | |
1262 ;; Do the search with the current search string. | |
1263 (isearch-message nil t) | |
1143
0b4552590bb8
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1142
diff
changeset
|
1264 (if search-upper-case |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1265 (setq isearch-case-fold-search (isearch-no-upper-case-p isearch-string))) |
725 | 1266 (condition-case lossage |
1267 (let ((inhibit-quit nil) | |
1268 (case-fold-search isearch-case-fold-search)) | |
1269 (if isearch-regexp (setq isearch-invalid-regexp nil)) | |
1270 (setq isearch-success | |
1271 (funcall | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1272 (cond (isearch-word |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1273 (if isearch-forward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1274 'word-search-forward 'word-search-backward)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1275 (isearch-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1276 (if isearch-forward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1277 're-search-forward 're-search-backward)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1278 (t |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1279 (if isearch-forward 'search-forward 'search-backward))) |
725 | 1280 isearch-string nil t)) |
1281 (if isearch-success | |
1282 (setq isearch-other-end | |
1283 (if isearch-forward (match-beginning 0) (match-end 0))))) | |
1284 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1285 (quit (isearch-unread ?\C-g) |
725 | 1286 (setq isearch-success nil)) |
1287 | |
1288 (invalid-regexp | |
1289 (setq isearch-invalid-regexp (car (cdr lossage))) | |
1290 (if (string-match | |
1291 "\\`Premature \\|\\`Unmatched \\|\\`Invalid " | |
1292 isearch-invalid-regexp) | |
1293 (setq isearch-invalid-regexp "incomplete input")))) | |
1294 | |
1295 (if isearch-success | |
1296 nil | |
1297 ;; Ding if failed this time after succeeding last time. | |
1298 (and (nth 3 (car isearch-cmds)) | |
1299 (ding)) | |
1300 (goto-char (nth 2 (car isearch-cmds))))) | |
1301 | |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1302 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1303 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1304 ;;;======================================================== |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1305 ;;; Highlighting |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1306 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1307 (defun isearch-highlight (begin end)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1308 (defun isearch-dehighlight (totally)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1309 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1310 ;; lemacs uses faces |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1311 '(progn |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1312 (defvar isearch-extent nil) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1313 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1314 (or (find-face 'isearch) ;; this face is initialized by x-faces.el |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1315 (make-face 'isearch)) ;; since isearch is preloaded |
725 | 1316 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1317 (defun isearch-lemacs-highlight (begin end) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1318 (if (null isearch-highlight) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1319 nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1320 (if (and (extentp isearch-extent) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1321 (eq (extent-buffer isearch-extent) (current-buffer))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1322 (set-extent-endpoints isearch-extent begin end) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1323 (if (and (extentp isearch-extent) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1324 (bufferp (extent-buffer isearch-extent)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1325 (buffer-name (extent-buffer isearch-extent))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1326 (delete-extent isearch-extent)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1327 (setq isearch-extent (make-extent begin end (current-buffer)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1328 (set-extent-face isearch-extent 'isearch))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1329 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1330 (defun isearch-lemacs-dehighlight (totally) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1331 (if (and isearch-highlight isearch-extent) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1332 (if totally |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1333 (let ((inhibit-quit t)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1334 (if (and (extentp isearch-extent) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1335 (bufferp (extent-buffer isearch-extent)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1336 (buffer-name (extent-buffer isearch-extent))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1337 (delete-extent isearch-extent)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1338 (setq isearch-extent nil)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1339 (if (and (extentp isearch-extent) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1340 (bufferp (extent-buffer isearch-extent)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1341 (buffer-name (extent-buffer isearch-extent))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1342 (set-extent-face isearch-extent 'default) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1343 (isearch-dehighlight t))))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1344 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1345 (fset 'isearch-highlight (symbol-function 'isearch-lemacs-highlight)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1346 (fset 'isearch-dehighlight (symbol-function 'isearch-lemacs-dehighlight)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1347 ) |
725 | 1348 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1349 ;;;=========================================================== |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1350 ;;; General utilities |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1351 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1352 ;; (fset 'isearch-member-equal (symbol-function 'member)) ; for emacs 19 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1353 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1354 (defun isearch-member-equal (item list) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1355 "Return non-nil if ITEM is `equal' to some item in LIST. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1356 Actually return the list whose car is that item." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1357 (while (and list (not (equal item (car list)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1358 (setq list (cdr list))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1359 list) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1360 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1361 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1362 (defun isearch-no-upper-case-p (string) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1363 "Return t if there are no upper case chars in string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1364 But upper case chars preceeded by \\ (but not \\\\) do not count since they |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1365 have special meaning in a regexp." |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1366 (let ((case-fold-search nil)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1367 (not (string-match "\\(^\\|\\\\\\\\\\|[^\\]\\)[A-Z]" string)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1368 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1369 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1370 ;;;================================================= |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1371 ;;; Special functions for lemacs events. |
725 | 1372 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1373 ;; To quiet the byte-compiler. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1374 (defvar unread-command-event) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1375 (defvar last-command-event) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1376 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1377 (defun isearch-char-to-string (c) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1378 (if (integerp c) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1379 (make-string 1 c) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1380 (make-string 1 (event-to-character c)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1381 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1382 (defun isearch-text-char-description (c) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1383 (isearch-char-to-string c)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1384 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1385 (defun isearch-unread (char-or-event) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1386 ;; General function to unread a character or event. |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1387 (if isearch-event-data-type |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1388 (setq unread-command-event char-or-event) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1389 (setq unread-command-char char-or-event))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1390 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1391 (defun isearch-last-command-char () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1392 ;; General function to return the last command character. |
1146
02b2f761f9df
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1143
diff
changeset
|
1393 (if isearch-event-data-type |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1394 last-command-event |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1395 last-command-char)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1396 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1397 |
725 | 1398 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1399 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1400 ;;;======================================================== |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1401 ;;; Exiting in lemacs |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1402 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1403 ;; This is a large amount of code to support automatic termination of |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1404 ;; isearch-mode when a command (however it is invoked) is not an |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1405 ;; isearch command, or the buffer is switched out from under |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1406 ;; isearch-mode. Only later versions of lemacs have the pre-command-hook. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1407 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1408 ;;(if isearch-pre-command-hook-exists |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1409 ;;(progn |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1410 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1411 ;;;; This list must be modified whenever the available commands are modified. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1412 ;;(mapcar (function (lambda (command) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1413 ;; (put command 'isearch-command t))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1414 ;; '(isearch-printing-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1415 ;; isearch-return-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1416 ;; isearch-repeat-forward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1417 ;; isearch-repeat-backward |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1418 ;; isearch-delete-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1419 ;; isearch-abort |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1420 ;; isearch-quote-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1421 ;; isearch-exit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1422 ;; isearch-printing-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1423 ;; isearch-printing-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1424 ;; isearch-yank-word |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1425 ;; isearch-yank-line |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1426 ;; isearch-*-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1427 ;; isearch-*-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1428 ;; isearch-|-char |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1429 ;; isearch-toggle-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1430 ;; isearch-edit-string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1431 ;; isearch-mode-help |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1432 ;; isearch-ring-advance |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1433 ;; isearch-ring-retreat |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1434 ;; isearch-ring-advance-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1435 ;; isearch-ring-retreat-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1436 ;; isearch-whitespace-chars |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1437 ;; isearch-complete |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1438 ;; isearch-complete-edit |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1439 ;; isearch-edit-string |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1440 ;; isearch-toggle-regexp |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1441 ;; ;; The following may not be needed since isearch-mode is off already. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1442 ;; isearch-forward-exit-minibuffer |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1443 ;; isearch-reverse-exit-minibuffer |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1444 ;; isearch-nonincremental-exit-minibuffer)) |
725 | 1445 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1446 ;;(defun isearch-pre-command-hook () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1447 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1448 ;; ;; For use as the value of `pre-command-hook' when isearch-mode is active. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1449 ;; ;; If the command about to be executed is not one of the isearch commands, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1450 ;; ;; then isearch-mode is turned off before that command is executed. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1451 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1452 ;; ;; If the command about to be executed is self-insert-command, or is a |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1453 ;; ;; keyboard macro of a single key sequence which is bound to self-insert- |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1454 ;; ;; command, then we add those chars to the search ring instead of inserting |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1455 ;; ;; them in the buffer. In this way, the set of self-searching characters |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1456 ;; ;; need not be exhaustively enumerated, but is derived from other maps. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1457 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1458 ;; (isearch-maybe-frob-keyboard-macros) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1459 ;; (if (and (symbolp this-command) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1460 ;; (get this-command 'isearch-command)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1461 ;; nil |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1462 ;; (isearch-done))) |
725 | 1463 |
1142
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1464 ;;(defun isearch-maybe-frob-keyboard-macros () |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1465 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1466 ;; ;; If the command about to be executed is `self-insert-command' then change |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1467 ;; ;; the command to `isearch-printing-char' instead, meaning add the last- |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1468 ;; ;; typed character to the search string. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1469 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1470 ;; ;; If `this-command' is a string or a vector (that is, a keyboard macro) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1471 ;; ;; and it contains only one command, which is bound to self-insert-command, |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1472 ;; ;; then do the same thing as for self-inserting commands: arrange for that |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1473 ;; ;; character to be added to the search string. If we didn't do this, then |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1474 ;; ;; typing a compose sequence (a la x-compose.el) would terminate the search |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1475 ;; ;; and insert the character, instead of searching for that character. |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1476 ;; ;; |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1477 ;; (cond ((eq this-command 'self-insert-command) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1478 ;; (setq this-command 'isearch-printing-char)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1479 ;; ((and (stringp this-command) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1480 ;; (eq (key-binding this-command) 'self-insert-command)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1481 ;; (setq last-command-char (aref this-command 0) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1482 ;; last-command-event (character-to-event last-command-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1483 ;; this-command 'isearch-printing-char)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1484 ;; ((and (vectorp this-command) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1485 ;; (eq (key-binding this-command) 'self-insert-command)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1486 ;; (let* ((desc (aref this-command 0)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1487 ;; (code (cond ((integerp desc) desc) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1488 ;; ((symbolp desc) (get desc character-set-property)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1489 ;; ((consp desc) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1490 ;; (and (null (cdr desc)) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1491 ;; (get (car desc) character-set-property))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1492 ;; (t nil)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1493 ;; (if code |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1494 ;; (setq last-command-char code |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1495 ;; last-command-event (character-to-event last-command-char) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1496 ;; this-command 'isearch-printing-char)))) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1497 ;; )) |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1498 |
7fc9de9d8cef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
1499 ;;)) |