I apologize if this is a duplicate, but the essence of the question is whether it is possible to create "around" advice for an existing function and bind that to a new one.
In my case, I'm trying to change how
evil-delete and similar functions handle the kill ring, namely by inserting into the second position instead of the first. I already have a function that accomplishes this, called
yf-kill-new-second-pos, however I cannot figure out how to cleanly define a derivative of
evil-delete that uses this instead of
kill-new without either copying and pasting or (I admit I haven't tried this) advising
evil-delete, which would undesirably change it's functionality.
I attempted to solve the issue by using
symbol-function to grab the source for
evil-delete and then wrapping that in an
flet to redefine
kill-new, but that did nothing to change the function's behavior (even when set to nil). Code:
(evil-define-operator yf-d (beg end type register yank-handler) "Evil-delete that dumps to 2nd in kill ring by default" ;;Same interactive clause as evil-delete (interactive "<R><x><y>") (cl-flet ((kill-new #'yf-kill-new-second-pos)) (funcall (symbol-function 'evil-delete) beg end type register))) ;;testing measure (bind-key (kbd "<f7>") 'yf-d)
This may not be changing anything because
evil-delete is byte-compiled, but I'm not entirely sure. It could also have something to do with evil-define-operator, but again, I don't know how to test around this. Any help in solving this issue would be greatly appreciated :)