branch: master commit c82b852d30e9d6385116bd9177f1598ab27de287 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-occur-revert-buffer): Simplify Re #2203 --- ivy.el | 19 +++++++------------ swiper.el | 5 ++--- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ivy.el b/ivy.el index 8073665..bdc3e2e 100644 --- a/ivy.el +++ b/ivy.el @@ -4810,18 +4810,13 @@ updated original buffer." (interactive) (let ((caller (ivy-state-caller ivy-occur-last)) (ivy-last ivy-occur-last)) - (cond ((member caller '(swiper swiper-isearch)) - (let ((inhibit-read-only t)) - (erase-buffer) - (funcall (plist-get ivy--occurs-list caller) t) - (ivy-occur-grep-mode))) - ((memq caller ivy-highlight-grep-commands) - (let ((inhibit-read-only t) - (line (line-number-at-pos))) - (erase-buffer) - (funcall (plist-get ivy--occurs-list caller)) - (goto-char (point-min)) - (forward-line (1- line))))) + (when (memq caller (append '(swiper swiper-isearch) ivy-highlight-grep-commands)) + (let ((inhibit-read-only t) + (line (line-number-at-pos))) + (erase-buffer) + (funcall (plist-get ivy--occurs-list caller)) + (goto-char (point-min)) + (forward-line (1- line)))) (setq ivy-occur-last ivy-last))) (declare-function wgrep-change-to-wgrep-mode "ext:wgrep") diff --git a/swiper.el b/swiper.el index 964ea51..0d97bc1 100644 --- a/swiper.el +++ b/swiper.el @@ -652,9 +652,8 @@ When non-nil, INITIAL-INPUT is the initial search pattern." (setf (ivy-state-window ivy-last) (selected-window))) buffer)) -(defun swiper-occur (&optional revert) +(defun swiper-occur () "Generate a custom occur buffer for `swiper'. -When REVERT is non-nil, regenerate the current *ivy-occur* buffer. When capture groups are present in the input, print them instead of lines." (let* ((buffer (swiper--occur-buffer)) (fname (propertize @@ -671,7 +670,7 @@ When capture groups are present in the input, print them instead of lines." (cands (swiper--occur-cands fname - (if (not revert) + (if (not (eq this-command 'ivy-occur-revert-buffer)) ivy--old-cands (setq ivy--old-re nil) (save-window-excursion