(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.