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:
parent
3e15b71568
commit
fe36bbca1f
4 changed files with 30 additions and 31 deletions
|
@ -229,30 +229,33 @@ 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)))
|
||||||
(format "*ivy-occur%s \"%s\"*"
|
(if-let* ((occur-fn (plist-get ivy--occurs-list caller)))
|
||||||
(if caller (concat " " (prin1-to-string caller)) "")
|
(let ((buffer (generate-new-buffer
|
||||||
ivy-text))))
|
(format "*ivy-occur%s \"%s\"*"
|
||||||
(with-current-buffer buffer
|
(if caller (concat " " (prin1-to-string caller)) "")
|
||||||
(let ((inhibit-read-only t))
|
ivy-text))))
|
||||||
(erase-buffer)
|
(with-current-buffer buffer
|
||||||
(funcall occur-fn))
|
(let ((inhibit-read-only t))
|
||||||
(setf (ivy-state-text ivy-last) ivy-text)
|
(erase-buffer)
|
||||||
(setq ivy-occur-last ivy-last)
|
(funcall occur-fn))
|
||||||
(setq-local ivy--directory ivy--directory))
|
(setf (ivy-state-text ivy-last) ivy-text)
|
||||||
(ivy-exit-with-action
|
(setq ivy-occur-last ivy-last)
|
||||||
`(lambda (_)
|
(setq-local ivy--directory ivy--directory))
|
||||||
(pop-to-buffer ,buffer)
|
(ivy-exit-with-action
|
||||||
(ivy-wgrep-change-to-wgrep-mode)))))
|
`(lambda (_)
|
||||||
|
(pop-to-buffer ,buffer)
|
||||||
|
(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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue