Standardize C-c C-e for ivy wgrep

Removes backtab in favor of standardizing C-c C-e. Already used by helm,
wgrep and dired.
This commit is contained in:
Henrik Lissner 2019-05-20 21:06:06 -04:00
parent 3e15b71568
commit fe36bbca1f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 30 additions and 31 deletions

View file

@ -229,16 +229,18 @@ search current file. See `+ivy-task-tags' to customize what this searches for."
:caller '+ivy/tasks)) :caller '+ivy/tasks))
;;;###autoload ;;;###autoload
(defun +ivy/wgrep-occur () (defun +ivy/woccur ()
"Invoke the search+replace wgrep buffer on the current ag/rg search results." "Invoke a wgrep buffer on the current ivy results, if supported."
(interactive) (interactive)
(unless (window-minibuffer-p) (unless (window-minibuffer-p)
(user-error "No completion session is active")) (user-error "No completion session is active"))
(require 'wgrep) (require 'wgrep)
(let* ((caller (ivy-state-caller ivy-last)) (let ((caller (ivy-state-caller ivy-last)))
(occur-fn (plist-get ivy--occurs-list caller)) (if-let* ((occur-fn (plist-get +ivy-edit-functions caller)))
(buffer (ivy-exit-with-action
(generate-new-buffer (lambda (_) (funcall occur-fn)))
(if-let* ((occur-fn (plist-get ivy--occurs-list caller)))
(let ((buffer (generate-new-buffer
(format "*ivy-occur%s \"%s\"*" (format "*ivy-occur%s \"%s\"*"
(if caller (concat " " (prin1-to-string caller)) "") (if caller (concat " " (prin1-to-string caller)) "")
ivy-text)))) ivy-text))))
@ -252,7 +254,8 @@ search current file. See `+ivy-task-tags' to customize what this searches for."
(ivy-exit-with-action (ivy-exit-with-action
`(lambda (_) `(lambda (_)
(pop-to-buffer ,buffer) (pop-to-buffer ,buffer)
(ivy-wgrep-change-to-wgrep-mode))))) (ivy-wgrep-change-to-wgrep-mode))))
(user-error "%S doesn't support wgrep" caller)))))
;;;###autoload ;;;###autoload
(defun +ivy-yas-prompt (prompt choices &optional display-fn) (defun +ivy-yas-prompt (prompt choices &optional display-fn)

View file

@ -26,6 +26,10 @@ If you want to already use git-grep or grep, set this to nil.")
(defvar +ivy-buffer-unreal-face 'font-lock-comment-face (defvar +ivy-buffer-unreal-face 'font-lock-comment-face
"The face for unreal buffers in `ivy-switch-to-buffer'.") "The face for unreal buffers in `ivy-switch-to-buffer'.")
(defvar +ivy-edit-functions nil
"A plist mapping ivy/counsel commands to commands that generate an editable
results buffer.")
(defmacro +ivy-do-action! (action) (defmacro +ivy-do-action! (action)
"Returns an interactive lambda that sets the current ivy action and "Returns an interactive lambda that sets the current ivy action and
immediately runs it on the current candidate (ending the ivy session)." immediately runs it on the current candidate (ending the ivy session)."
@ -86,6 +90,8 @@ immediately runs it on the current candidate (ending the ivy session)."
[remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window [remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer) [remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer)
(define-key ivy-minibuffer-map (kbd "C-c C-e") #'+ivy/woccur)
(ivy-mode +1) (ivy-mode +1)
(def-package! ivy-hydra (def-package! ivy-hydra

View file

@ -322,8 +322,6 @@
"C-g" #'keyboard-escape-quit) "C-g" #'keyboard-escape-quit)
(:after counsel (:after counsel
:map counsel-ag-map :map counsel-ag-map
"C-c C-e" #'+ivy/wgrep-occur ; search/replace on results
[backtab] #'+ivy/wgrep-occur ; search/replace on results
"C-SPC" #'ivy-call-and-recenter ; preview "C-SPC" #'ivy-call-and-recenter ; preview
"M-RET" (+ivy-do-action! #'+ivy-git-grep-other-window-action)) "M-RET" (+ivy-do-action! #'+ivy-git-grep-other-window-action))
"C-M-y" #'counsel-yank-pop) "C-M-y" #'counsel-yank-pop)

View file

@ -220,12 +220,7 @@
:map counsel-ag-map :map counsel-ag-map
"C-SPC" #'ivy-call-and-recenter ; preview "C-SPC" #'ivy-call-and-recenter ; preview
"C-l" #'ivy-done "C-l" #'ivy-done
"C-c C-e" #'+ivy/wgrep-occur ; search/replace on results [C-return] (+ivy-do-action! #'+ivy-git-grep-other-window-action)))
[backtab] #'+ivy/wgrep-occur ; search/replace on results
[C-return] (+ivy-do-action! #'+ivy-git-grep-other-window-action))
(:after swiper
:map swiper-map
[backtab] #'+ivy/wgrep-occur))
(:when (featurep! :completion helm) (:when (featurep! :completion helm)
(:after helm (:after helm
@ -249,13 +244,10 @@
"TAB" #'helm-execute-persistent-action "TAB" #'helm-execute-persistent-action
[tab] #'helm-execute-persistent-action [tab] #'helm-execute-persistent-action
"C-z" #'helm-select-action) "C-z" #'helm-select-action)
(:after swiper-helm
:map swiper-helm-keymap [backtab] #'helm-ag-edit)
(:after helm-ag (:after helm-ag
:map helm-ag-map :map helm-ag-map
"C--" #'+helm-do-ag-decrease-context "C--" #'+helm-do-ag-decrease-context
"C-=" #'+helm-do-ag-increase-context "C-=" #'+helm-do-ag-increase-context
[backtab] #'helm-ag-edit
[left] nil [left] nil
[right] nil) [right] nil)
(:after helm-files (:after helm-files