branch: master commit cb0cf0258dd59bf1bc00eba6bd6c23e3cbaefb8b Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-call): Remove with-selected-window * counsel.el (counsel-git-grep-action): Add with-selected-window. * ivy.el (ivy-dispatching-done): Remove trailing ": ". (ivy-switch-buffer): Add extra action "j" calls `switch-to-buffer-other-window'. The change `ivy-dispatching-done' had to be done because of this. --- counsel.el | 21 +++++++++++---------- ivy.el | 16 +++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/counsel.el b/counsel.el index 15a14db..e892c3e 100644 --- a/counsel.el +++ b/counsel.el @@ -310,16 +310,17 @@ (defun counsel-git-grep-action (x) (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" x) - (let ((file-name (match-string-no-properties 1 x)) - (line-number (match-string-no-properties 2 x))) - (find-file (expand-file-name file-name counsel--git-grep-dir)) - (goto-char (point-min)) - (forward-line (1- (string-to-number line-number))) - (re-search-forward (ivy--regex ivy-text t) (line-end-position) t) - (unless (eq ivy-exit 'done) - (setq swiper--window (selected-window)) - (swiper--cleanup) - (swiper--add-overlays (ivy--regex ivy-text)))))) + (with-selected-window (ivy-state-window ivy-last) + (let ((file-name (match-string-no-properties 1 x)) + (line-number (match-string-no-properties 2 x))) + (find-file (expand-file-name file-name counsel--git-grep-dir)) + (goto-char (point-min)) + (forward-line (1- (string-to-number line-number))) + (re-search-forward (ivy--regex ivy-text t) (line-end-position) t) + (unless (eq ivy-exit 'done) + (setq swiper--window (selected-window)) + (swiper--cleanup) + (swiper--add-overlays (ivy--regex ivy-text))))))) (defvar counsel-git-grep-history nil "History for `counsel-git-grep'.") diff --git a/ivy.el b/ivy.el index 989a34e..28463b7 100644 --- a/ivy.el +++ b/ivy.el @@ -286,7 +286,7 @@ When non-nil, it should contain one %d.") (nth 2 x))) (cdr actions) "\n") - "\n: ")) + "\n")) (key (string (read-key hint))) (action (assoc key (cdr actions)))) (cond ((string= key "")) @@ -578,11 +578,10 @@ If the input is empty, select the previous history element instead." (x (if (and (consp collection) (consp (car collection))) (cdr (assoc ivy--current collection)) - ivy--current))) - (if (eq (ivy-state-history ivy-last) 'extended-command-history) - (funcall action x) - (with-selected-window (ivy-state-window ivy-last) - (funcall action x))))))) + (if (equal ivy--current "") + ivy-text + ivy--current)))) + (funcall action x))))) (defun ivy-next-line-and-call (&optional arg) "Move cursor vertically down ARG candidates. @@ -1559,7 +1558,10 @@ BUFFER may be a string or nil." (lambda (x) (kill-buffer x) (ivy--reset-state ivy-last)) - "kill"))) + "kill") + ("j" + switch-to-buffer-other-window + "other"))) (defun ivy-switch-buffer () "Switch to another buffer."