comparison lisp/isearch.el @ 99756:abaa7407abf7

(isearch-search-string): Simplify and convert docstring.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 21 Nov 2008 05:32:07 +0000
parents 034bef9118e6
children 710b20693a81
comparison
equal deleted inserted replaced
99755:8474e0f67804 99756:abaa7407abf7
2210 (if isearch-forward 're-search-forward 're-search-backward)) 2210 (if isearch-forward 're-search-forward 're-search-backward))
2211 (t 2211 (t
2212 (if isearch-forward 'search-forward 'search-backward))))) 2212 (if isearch-forward 'search-forward 'search-backward)))))
2213 2213
2214 (defun isearch-search-string (string bound noerror) 2214 (defun isearch-search-string (string bound noerror)
2215 ;; Search for the first occurance of STRING or its translation. If 2215 "Search for the first occurance of STRING or its translation. If
2216 ;; found, move point to the end of the occurance, update 2216 found, move point to the end of the occurance, update
2217 ;; isearch-match-beg and isearch-match-end, and return point. 2217 isearch-match-beg and isearch-match-end, and return point."
2218 (let ((func (isearch-search-fun)) 2218 (let* ((func (isearch-search-fun))
2219 (len (length string)) 2219 (pos1 (save-excursion (funcall func string bound noerror)))
2220 pos1 pos2) 2220 pos2)
2221 (setq pos1 (save-excursion (funcall func string bound noerror))) 2221 (when (and (char-table-p translation-table-for-input)
2222 (if (and (char-table-p translation-table-for-input) 2222 (multibyte-string-p string)
2223 (multibyte-string-p string) 2223 ;; Minor optimization.
2224 ;; Minor optimization. 2224 (string-match-p "[^[:ascii:]]" string))
2225 (string-match-p "[^[:ascii:]]" string)) 2225 (let ((translated
2226 (let ((translated 2226 (apply 'string
2227 (apply 'string 2227 (mapcar (lambda (c)
2228 (mapcar (lambda (c) 2228 (or (aref translation-table-for-input c) c))
2229 (or (aref translation-table-for-input c) c)) 2229 string)))
2230 string))) 2230 match-data)
2231 match-data) 2231 (when translated
2232 (when translated 2232 (save-match-data
2233 (save-match-data 2233 (save-excursion
2234 (save-excursion 2234 (if (setq pos2 (funcall func translated bound noerror))
2235 (if (setq pos2 (funcall func translated bound noerror)) 2235 (setq match-data (match-data t)))))
2236 (setq match-data (match-data t))))) 2236 (when (and pos2
2237 (when (and pos2 2237 (or (not pos1)
2238 (or (not pos1) 2238 (if isearch-forward (< pos2 pos1) (> pos2 pos1))))
2239 (if isearch-forward (< pos2 pos1) (> pos2 pos1)))) 2239 (setq pos1 pos2)
2240 (setq pos1 pos2) 2240 (set-match-data match-data)))))
2241 (set-match-data match-data)))))
2242 (when pos1 2241 (when pos1
2243 ;; When using multiple buffers isearch, switch to the new buffer here, 2242 ;; When using multiple buffers isearch, switch to the new buffer here,
2244 ;; because `save-excursion' above doesn't allow doing it inside funcall. 2243 ;; because `save-excursion' above doesn't allow doing it inside funcall.
2245 (if (and multi-isearch-next-buffer-current-function 2244 (if (and multi-isearch-next-buffer-current-function
2246 (buffer-live-p multi-isearch-current-buffer)) 2245 (buffer-live-p multi-isearch-current-buffer))
2247 (switch-to-buffer multi-isearch-current-buffer)) 2246 (switch-to-buffer multi-isearch-current-buffer))
2248 (goto-char pos1)) 2247 (goto-char pos1)
2249 pos1)) 2248 pos1)))
2250 2249
2251 (defun isearch-search () 2250 (defun isearch-search ()
2252 ;; Do the search with the current search string. 2251 ;; Do the search with the current search string.
2253 (if isearch-message-function 2252 (if isearch-message-function
2254 (funcall isearch-message-function nil t) 2253 (funcall isearch-message-function nil t)