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))
;;;###autoload
(defun +ivy/wgrep-occur ()
"Invoke the search+replace wgrep buffer on the current ag/rg search results."
(defun +ivy/woccur ()
"Invoke a wgrep buffer on the current ivy results, if supported."
(interactive)
(unless (window-minibuffer-p)
(user-error "No completion session is active"))
(require 'wgrep)
(let* ((caller (ivy-state-caller ivy-last))
(occur-fn (plist-get ivy--occurs-list caller))
(buffer
(generate-new-buffer
(let ((caller (ivy-state-caller ivy-last)))
(if-let* ((occur-fn (plist-get +ivy-edit-functions caller)))
(ivy-exit-with-action
(lambda (_) (funcall occur-fn)))
(if-let* ((occur-fn (plist-get ivy--occurs-list caller)))
(let ((buffer (generate-new-buffer
(format "*ivy-occur%s \"%s\"*"
(if caller (concat " " (prin1-to-string caller)) "")
ivy-text))))
@ -252,7 +254,8 @@ search current file. See `+ivy-task-tags' to customize what this searches for."
(ivy-exit-with-action
`(lambda (_)
(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
(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
"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)
"Returns an interactive lambda that sets the current ivy action and
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 persp-switch-to-buffer] #'+ivy/switch-workspace-buffer)
(define-key ivy-minibuffer-map (kbd "C-c C-e") #'+ivy/woccur)
(ivy-mode +1)
(def-package! ivy-hydra

View file

@ -322,8 +322,6 @@
"C-g" #'keyboard-escape-quit)
(:after counsel
: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
"M-RET" (+ivy-do-action! #'+ivy-git-grep-other-window-action))
"C-M-y" #'counsel-yank-pop)

View file

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