evil
evil copied to clipboard
Advising evil-delete breaks evil-surround-delete
Wasn't sure if I should file this issue over at the evil-surround
repo, but I think this is not an evil-surround
problem but rather a problem on how I'm trying to advise evil-delete
.
Issue type
- Question/Bug
Environment
Emacs version: GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS appkit-1348.17 Version 10.10.5 (Build 14F2511)) of 2018-05-31
Operating System: macOS Catalina (10.15.5)
Evil version: 1.14.0
Evil installation type: manual
Graphical/Terminal: both
Tested in a make emacs
session (see CONTRIBUTING.md): Yes
Reproduction steps
- Start emacs using
make terminal
in evil repo - Paste the latest version of evil-surround and
M-x eval-buffer
- Delete everything
- Insert the following text:
(global-evil-surround-mode 1)
;; simple advice that should send all deletes to black-hole register
(defun evil-delete-advice
(orig-fn beg end type register &rest args)
(apply orig-fn beg end type ?_ args))
(advice-add 'evil-delete :around #'evil-delete-advice)
-
M-x eval-buffer
- Place cursor somewhere between
()
and typed s (
Expected behavior
Only the parentheses are deleted.
Actual behavior
Instead of deleting just the parenthesis, everything between the opening parentheses and point is deleted too.
Further notes
When the advice is removed, everything works as expected. How do I correctly advise evil-delete
without breaking evil-surround
?
in case anybody has similar problems, I was able to work around the issue by not advising evil-delete
and instead defining a new operator and making sure it works with evil-surround
:
(after! evil
(evil-define-operator evil-destroy (beg end type)
"Delete text from BEG to END with TYPE. Just like evil-delete but always
deletes to black-hole"
(evil-delete beg end type ?_ nil))
(map! :n "d" #'evil-destroy)
(map! :n "m" #'evil-delete))
(after! evil-surround
(add-to-list 'evil-surround-operator-alist '(evil-destroy . delete)))
I actually like this solution better than what I originally intended, but the problem that advising evil-delete
breaks evil-surround
still persists.