Skip to content

Commit

Permalink
Add a shim for grep-edit
Browse files Browse the repository at this point in the history
grep-edit is a major mode introduced in Emacs 31 which enables the
editing of Grep results, by typing 'e' in '*grep*' buffers. 'C-c C-c'
exits this mode and saves changes.
  • Loading branch information
gs-101 committed Nov 10, 2024
1 parent 38af7f1 commit 0d7c391
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions meow-shims.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ Argument ENABLE non-nil means turn on."
(advice-remove 'wgrep-finish-edit #'meow--switch-to-motion)
(advice-remove 'wgrep-save-all-buffers #'meow--switch-to-motion)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; grep-edit


(defvar meow--grep-edit-setup nil
"Wheter already setup grep-edit.")

(defvar grep-edit-mode-hook)

(declare-function grep-edit-save-changes "grep")

(defun meow--setup-grep-edit (enable)
"Setup grep-edit.
Argument ENABLE non-nil means turn on."
(if enable
(progn
(add-hook 'grep-edit-mode-hook #'meow--switch-to-normal)
(advice-add #'grep-edit-save-changes :after #'meow--switch-to-motion))
(remove-hook 'grep-edit-mode-hook #'meow--switch-to-normal)
(advice-remove 'grep-edit-save-changes #'meow--switch-to-motion)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; wdired

Expand Down Expand Up @@ -294,8 +316,8 @@ Argument ENABLE non-nil means turn on."
(defun meow--which-key-describe-keymap ()
(if which-key-mode
(setq meow-keypad-describe-keymap-function
(lambda (keymap)
(which-key--create-buffer-and-show nil keymap nil (concat "Meow: " (meow--keypad-format-keys)))))
(lambda (keymap)
(which-key--create-buffer-and-show nil keymap nil (concat "Meow: " (meow--keypad-format-keys)))))
(setq meow-keypad-describe-keymap-function 'meow-describe-keymap)))

(defun meow--setup-which-key (enable)
Expand Down Expand Up @@ -382,6 +404,7 @@ Argument ENABLE non-nil means turn on."
(eval-after-load "macrostep" (lambda () (meow--setup-macrostep t)))
(eval-after-load "wdired" (lambda () (meow--setup-wdired t)))
(eval-after-load "wgrep" (lambda () (meow--setup-wgrep t)))
(eval-after-load "grep" (lambda () (meow--setup-grep-edit t)))
(eval-after-load "polymode" (lambda () (meow--setup-polymode t)))
(eval-after-load "sly" (lambda () (meow--setup-sly t)))
(eval-after-load "realgud" (lambda () (meow--setup-realgud t)))
Expand All @@ -399,6 +422,7 @@ Argument ENABLE non-nil means turn on."
(when meow--rectangle-mark-setup (meow--setup-rectangle-mark nil))
(when meow--wdired-setup (meow--setup-wdired nil))
(when meow--wgrep-setup (meow--setup-wgrep nil))
(when meow--grep-edit-setup (meow--setup-grep-edit nil))
(when meow--polymode-setup (meow--setup-polymode nil))
(when meow--which-key-setup (meow--setup-which-key nil))
;; (when meow--diff-hl-setup (meow--setup-diff-hl nil))
Expand Down

0 comments on commit 0d7c391

Please sign in to comment.