comparison lisp/prim/isearch-mode.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 9f59509498e1
children 1370575f1259
comparison
equal deleted inserted replaced
119:d101af7320b8 120:cca96a509cfe
90 ;;; Changes for 1.1 90 ;;; Changes for 1.1
91 ;;; 3/18/92 Fixed invalid-regexp. 91 ;;; 3/18/92 Fixed invalid-regexp.
92 ;;; 3/18/92 Fixed yanking in regexps. 92 ;;; 3/18/92 Fixed yanking in regexps.
93 93
94 94
95 (defgroup isearch nil
96 "Incremental search"
97 :group 'matching)
98
99
95 (defun isearch-char-to-string (c) 100 (defun isearch-char-to-string (c)
96 (if (integerp c) 101 (if (integerp c)
97 (make-string 1 c) 102 (make-string 1 c)
98 (make-string 1 (event-to-character c nil nil t)))) 103 (make-string 1 (event-to-character c nil nil t))))
99 104
117 and does not include searches that are aborted.") 122 and does not include searches that are aborted.")
118 123
119 (defconst search-exit-option t 124 (defconst search-exit-option t
120 "Non-nil means random control characters terminate incremental search.") 125 "Non-nil means random control characters terminate incremental search.")
121 126
122 (defvar search-slow-window-lines 1 127 (defcustom search-slow-window-lines 1
123 "*Number of lines in slow search display windows. 128 "*Number of lines in slow search display windows.
124 These are the short windows used during incremental search on slow terminals. 129 These are the short windows used during incremental search on slow terminals.
125 Negative means put the slow search window at the top (normally it's at bottom) 130 Negative means put the slow search window at the top (normally it's at bottom)
126 and the value is minus the number of lines.") 131 and the value is minus the number of lines."
127 132 :type 'integer
128 (defconst search-slow-speed 1200 133 :group 'isearch)
134
135 (defcustom search-slow-speed 1200
129 "*Highest terminal speed at which to use \"slow\" style incremental search. 136 "*Highest terminal speed at which to use \"slow\" style incremental search.
130 This is the style where a one-line window is created to show the line 137 This is the style where a one-line window is created to show the line
131 that the search has reached.") 138 that the search has reached."
132 139 :type 'integer
133 (defvar search-caps-disable-folding t 140 :group 'isearch)
141
142 (defcustom search-caps-disable-folding t
134 "*If non-nil, upper case chars disable case fold searching. 143 "*If non-nil, upper case chars disable case fold searching.
135 This does not apply to \"yanked\" strings.") 144 This does not apply to \"yanked\" strings."
136 145 :type 'boolean
137 (defvar search-nonincremental-instead t 146 :group 'isearch)
138 "*If non-nil, do a nonincremental search instead if exiting immediately.") 147
148 (defcustom search-nonincremental-instead t
149 "*If non-nil, do a nonincremental search instead if exiting immediately."
150 :type 'boolean
151 :group 'isearch)
139 152
140 (defconst search-whitespace-regexp "\\(\\s \\|[\n\r]\\)+" 153 (defcustom search-whitespace-regexp "\\(\\s \\|[\n\r]\\)+"
141 "*If non-nil, regular expression to match a sequence of whitespace chars.") 154 "*If non-nil, regular expression to match a sequence of whitespace chars."
155 :type 'regexp
156 :group 'isearch)
142 157
143 ;;;================================================================== 158 ;;;==================================================================
144 ;;; Search ring. 159 ;;; Search ring.
145 160
146 (defvar search-ring nil 161 (defvar search-ring nil
147 "List of search string sequences.") 162 "List of search string sequences.")
148 (defvar regexp-search-ring nil 163 (defvar regexp-search-ring nil
149 "List of regular expression search string sequences.") 164 "List of regular expression search string sequences.")
150 165
151 (defconst search-ring-max 16 166 (defcustom search-ring-max 16
152 "*Maximum length of search ring before oldest elements are thrown away.") 167 "*Maximum length of search ring before oldest elements are thrown away."
153 (defconst regexp-search-ring-max 16 168 :type 'integer
154 "*Maximum length of regexp search ring before oldest elements are thrown away.") 169 :group 'isearch)
170 (defcustom regexp-search-ring-max 16
171 "*Maximum length of regexp search ring before oldest elements are thrown away."
172 :type 'integer
173 :group 'isearch)
155 174
156 (defvar search-ring-yank-pointer nil 175 (defvar search-ring-yank-pointer nil
157 "The tail of the search ring whose car is the last thing searched for.") 176 "The tail of the search ring whose car is the last thing searched for.")
158 (defvar regexp-search-ring-yank-pointer nil 177 (defvar regexp-search-ring-yank-pointer nil
159 "The tail of the regular expression search ring whose car is the last 178 "The tail of the regular expression search ring whose car is the last
1010 1029
1011 1030
1012 ;;=========================================================== 1031 ;;===========================================================
1013 ;; Search Ring 1032 ;; Search Ring
1014 1033
1015 (defvar search-ring-update nil 1034 (defcustom search-ring-update nil
1016 "*Non-nil if advancing or retreating in the search ring should cause search. 1035 "*Non-nil if advancing or retreating in the search ring should cause search.
1017 Default nil means edit the string from the search ring first.") 1036 Default nil means edit the string from the search ring first."
1037 :type 'boolean
1038 :group 'isearch)
1018 1039
1019 (defun isearch-ring-adjust1 (advance) 1040 (defun isearch-ring-adjust1 (advance)
1020 ;; Helper for isearch-ring-adjust 1041 ;; Helper for isearch-ring-adjust
1021 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) 1042 (let* ((ring (if isearch-regexp regexp-search-ring search-ring))
1022 (length (length ring)) 1043 (length (length ring))
1386 1407
1387 1408
1388 ;;;======================================================== 1409 ;;;========================================================
1389 ;;; Highlighting 1410 ;;; Highlighting
1390 1411
1391 (defvar isearch-highlight t 1412 (defcustom isearch-highlight t
1392 "*Whether isearch and query-replace should highlight the text which 1413 "*Whether isearch and query-replace should highlight the text which
1393 currently matches the search-string.") 1414 currently matches the search-string.")
1394 1415
1395 (defvar isearch-extent nil) 1416 (defvar isearch-extent nil)
1396 1417
1557 But upper case chars preceded by \\ do not count since they 1578 But upper case chars preceded by \\ do not count since they
1558 have special meaning in a regexp." 1579 have special meaning in a regexp."
1559 ;; this incorrectly returns t for "\\\\A" 1580 ;; this incorrectly returns t for "\\\\A"
1560 (let ((case-fold-search nil)) 1581 (let ((case-fold-search nil))
1561 (not (string-match "\\(^\\|[^\\]\\)[A-Z]" string)))) 1582 (not (string-match "\\(^\\|[^\\]\\)[A-Z]" string))))
1583
1584 ;; Used by etags.el and info.el
1585 (defmacro with-caps-disable-folding (string &rest body) "\
1586 Eval BODY with `case-fold-search' let to nil if STRING contains
1587 uppercase letters and `search-caps-disable-folding' is t."
1588 `(let ((case-fold-search
1589 (if (and case-fold-search search-caps-disable-folding)
1590 (isearch-no-upper-case-p ,string)
1591 case-fold-search)))
1592 ,@body))
1593 (put 'with-caps-disable-folding 'lisp-indent-function 1)
1594 (put 'with-caps-disable-folding 'edebug-form-spec '(form body))
1595