Skip to content

Commit

Permalink
swiper.el: remove with-ivy-window wrapper around actions
Browse files Browse the repository at this point in the history
`with-ivy-window` wrapper is legacy for actions.
  • Loading branch information
ywwry66 committed Jun 9, 2024
1 parent 1805fb9 commit 5428012
Showing 1 changed file with 43 additions and 47 deletions.
90 changes: 43 additions & 47 deletions swiper.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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'."
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5428012

Please sign in to comment.