mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-23 00:10:48 -08:00
(isearch-search-string): Simplify and convert docstring.
This commit is contained in:
parent
e1ff8dd08b
commit
3be5da9e6f
2 changed files with 30 additions and 29 deletions
|
|
@ -1,5 +1,7 @@
|
|||
2008-11-21 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* isearch.el (isearch-search-string): Simplify and convert docstring.
|
||||
|
||||
* buff-menu.el (Buffer-menu-short-ellipsis): Partly undo last change.
|
||||
|
||||
2008-11-20 Juanma Barranquero <lekktu@gmail.com>
|
||||
|
|
|
|||
|
|
@ -2212,41 +2212,40 @@ Can be changed via `isearch-search-fun-function' for special needs."
|
|||
(if isearch-forward 'search-forward 'search-backward)))))
|
||||
|
||||
(defun isearch-search-string (string bound noerror)
|
||||
;; Search for the first occurance of STRING or its translation. If
|
||||
;; found, move point to the end of the occurance, update
|
||||
;; isearch-match-beg and isearch-match-end, and return point.
|
||||
(let ((func (isearch-search-fun))
|
||||
(len (length string))
|
||||
pos1 pos2)
|
||||
(setq pos1 (save-excursion (funcall func string bound noerror)))
|
||||
(if (and (char-table-p translation-table-for-input)
|
||||
(multibyte-string-p string)
|
||||
;; Minor optimization.
|
||||
(string-match-p "[^[:ascii:]]" string))
|
||||
(let ((translated
|
||||
(apply 'string
|
||||
(mapcar (lambda (c)
|
||||
(or (aref translation-table-for-input c) c))
|
||||
string)))
|
||||
match-data)
|
||||
(when translated
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(if (setq pos2 (funcall func translated bound noerror))
|
||||
(setq match-data (match-data t)))))
|
||||
(when (and pos2
|
||||
(or (not pos1)
|
||||
(if isearch-forward (< pos2 pos1) (> pos2 pos1))))
|
||||
(setq pos1 pos2)
|
||||
(set-match-data match-data)))))
|
||||
"Search for the first occurance of STRING or its translation. If
|
||||
found, move point to the end of the occurance, update
|
||||
isearch-match-beg and isearch-match-end, and return point."
|
||||
(let* ((func (isearch-search-fun))
|
||||
(pos1 (save-excursion (funcall func string bound noerror)))
|
||||
pos2)
|
||||
(when (and (char-table-p translation-table-for-input)
|
||||
(multibyte-string-p string)
|
||||
;; Minor optimization.
|
||||
(string-match-p "[^[:ascii:]]" string))
|
||||
(let ((translated
|
||||
(apply 'string
|
||||
(mapcar (lambda (c)
|
||||
(or (aref translation-table-for-input c) c))
|
||||
string)))
|
||||
match-data)
|
||||
(when translated
|
||||
(save-match-data
|
||||
(save-excursion
|
||||
(if (setq pos2 (funcall func translated bound noerror))
|
||||
(setq match-data (match-data t)))))
|
||||
(when (and pos2
|
||||
(or (not pos1)
|
||||
(if isearch-forward (< pos2 pos1) (> pos2 pos1))))
|
||||
(setq pos1 pos2)
|
||||
(set-match-data match-data)))))
|
||||
(when pos1
|
||||
;; When using multiple buffers isearch, switch to the new buffer here,
|
||||
;; because `save-excursion' above doesn't allow doing it inside funcall.
|
||||
(if (and multi-isearch-next-buffer-current-function
|
||||
(buffer-live-p multi-isearch-current-buffer))
|
||||
(switch-to-buffer multi-isearch-current-buffer))
|
||||
(goto-char pos1))
|
||||
pos1))
|
||||
(goto-char pos1)
|
||||
pos1)))
|
||||
|
||||
(defun isearch-search ()
|
||||
;; Do the search with the current search string.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue