From 54280123f79a0ebed6fcdc5961f5c9e4ef42f848 Mon Sep 17 00:00:00 2001 From: Ruiyang Wu <58066925+ywwry66@users.noreply.github.com> Date: Mon, 20 May 2024 10:49:18 -0400 Subject: [PATCH] swiper.el: remove `with-ivy-window` wrapper around actions `with-ivy-window` wrapper is legacy for actions. --- swiper.el | 90 ++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/swiper.el b/swiper.el index ca2975ba..fd846761 100644 --- a/swiper.el +++ b/swiper.el @@ -238,11 +238,10 @@ If the input is empty, select the previous history element instead." (swiper--cleanup) (ivy-exit-with-action (lambda (_) - (with-ivy-window - (move-beginning-of-line 1) - (let ((inhibit-read-only t)) - (perform-replace from to - t t nil)))))) + (move-beginning-of-line 1) + (let ((inhibit-read-only t)) + (perform-replace from to + t t nil))))) (swiper--query-replace-cleanup))))) (ivy-configure 'swiper-query-replace @@ -1122,25 +1121,24 @@ WND, when specified is the window." (case-fold-search (ivy--case-fold-p ivy-text))) (if (null x) (user-error "No candidates") - (with-ivy-window - (unless (equal (current-buffer) - (ivy-state-buffer ivy-last)) - (switch-to-buffer (ivy-state-buffer ivy-last))) - (goto-char - (if (buffer-narrowed-p) - swiper--point-min - (point-min))) - (funcall (if swiper-use-visual-line - #'line-move - #'forward-line) - ln) - (when (and (re-search-forward re (line-end-position) t) - swiper-goto-start-of-match) - (goto-char (match-beginning 0))) - (swiper--ensure-visible) - (swiper--maybe-recenter) - (swiper--push-mark) - (swiper--remember-search-history re))))) + (unless (equal (current-buffer) + (ivy-state-buffer ivy-last)) + (switch-to-buffer (ivy-state-buffer ivy-last))) + (goto-char + (if (buffer-narrowed-p) + swiper--point-min + (point-min))) + (funcall (if swiper-use-visual-line + #'line-move + #'forward-line) + ln) + (when (and (re-search-forward re (line-end-position) t) + swiper-goto-start-of-match) + (goto-char (match-beginning 0))) + (swiper--ensure-visible) + (swiper--maybe-recenter) + (swiper--push-mark) + (swiper--remember-search-history re)))) (defun swiper--remember-search-history (re) "Add the search pattern RE to the search history ring." @@ -1228,19 +1226,18 @@ otherwise continue prompting for buffers." (when (> (length x) 0) (let ((buffer-name (get-text-property 0 'buffer x))) (when buffer-name - (with-ivy-window - (switch-to-buffer buffer-name) - (goto-char (point-min)) - (forward-line (1- (swiper--line-number x))) - (re-search-forward - (ivy--regex ivy-text) - (line-end-position) t) - (funcall isearch-filter-predicate - (line-beginning-position) - (line-end-position)) - (unless (eq ivy-exit 'done) - (swiper--cleanup) - (swiper--add-overlays (ivy--regex ivy-text)))))))) + (switch-to-buffer buffer-name) + (goto-char (point-min)) + (forward-line (1- (swiper--line-number x))) + (re-search-forward + (ivy--regex ivy-text) + (line-end-position) t) + (funcall isearch-filter-predicate + (line-beginning-position) + (line-end-position)) + (unless (eq ivy-exit 'done) + (swiper--cleanup) + (swiper--add-overlays (ivy--regex ivy-text))))))) (defun swiper-all-buffer-p (buffer) "Return non-nil if BUFFER should be considered by `swiper-all'." @@ -1357,15 +1354,14 @@ See `ivy-format-functions-alist' for further information." (when (> (length x) 0) (let ((buffer-name (get-text-property 0 'buffer x))) (when buffer-name - (with-ivy-window - (switch-to-buffer buffer-name) - (goto-char (get-text-property 0 'point x)) - (funcall isearch-filter-predicate - (line-beginning-position) - (line-end-position)) - (unless (eq ivy-exit 'done) - (swiper--cleanup) - (swiper--add-overlays (ivy--regex ivy-text)))))))) + (switch-to-buffer buffer-name) + (goto-char (get-text-property 0 'point x)) + (funcall isearch-filter-predicate + (line-beginning-position) + (line-end-position)) + (unless (eq ivy-exit 'done) + (swiper--cleanup) + (swiper--add-overlays (ivy--regex ivy-text))))))) (defun swiper--multi-candidates (buffers) "Extract candidates from BUFFERS." @@ -1514,7 +1510,7 @@ Signal an error on failure." (defun swiper-isearch-action (x) "Move to X for `swiper-isearch'." (if (setq x (swiper--isearch-candidate-pos x)) - (with-ivy-window + (progn (goto-char x) (when (and (or (eq this-command 'ivy-previous-line-or-history) (and (eq this-command 'ivy-done)