annotate lisp/isearch-mode.el @ 377:d883f39b8495 r21-2b4

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