(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))
+ (when multi-isearch-next-buffer-current-function
+ (multi-isearch-switch-buffer))
(goto-char pos1)
pos1)))
(if (or (null multi-isearch-pause)
(and multi-isearch-pause multi-isearch-current-buffer))
(progn
- (switch-to-buffer
- (setq multi-isearch-current-buffer
- (funcall multi-isearch-next-buffer-current-function
- (current-buffer) t)))
+ (setq multi-isearch-current-buffer
+ (funcall multi-isearch-next-buffer-current-function
+ (current-buffer) t))
+ (multi-isearch-switch-buffer)
(goto-char (if isearch-forward (point-min) (point-max))))
(setq multi-isearch-current-buffer (current-buffer))
(setq isearch-wrapped nil)))
(defun multi-isearch-pop-state (_cmd buffer)
"Restore the multiple buffers search state in BUFFER.
Switch to the buffer restored from the search status stack."
- (unless (equal buffer (current-buffer))
- (switch-to-buffer (setq multi-isearch-current-buffer buffer))))
+ (unless (eq buffer (current-buffer))
+ (setq multi-isearch-current-buffer buffer)
+ (multi-isearch-switch-buffer)))
+
+;;;###autoload
+(defun multi-isearch-switch-buffer ()
+ "Switch to the next buffer in multi-buffer search."
+ (when (and (buffer-live-p multi-isearch-current-buffer)
+ (not (eq multi-isearch-current-buffer (current-buffer))))
+ (setq isearch-mode nil)
+ (switch-to-buffer multi-isearch-current-buffer)
+ (setq isearch-mode " M-Isearch")))
\f
;;; Global multi-buffer search invocations