What I want to do: have the function
evil-delete do one more task after its usual code. (I'm presuming that
evil-delete is the underlying workhorse that is called by
evil-delete-line and about five other functions.)
evil-delete takes optional parameters.
In a scheme, I'd write:
(define original-evil-delete evil-delete) ; capture the original binding (define (evil-delete-then-gui-set-selection . args) "Delete, and copy deleted-text into the OS clipboard." (prog1 (apply original-evil-delete args) (gui-set-selection 'CLIPBOARD (current-kill 0)))) (set! evil-delete evil-delete-then-gui-set-selection) ; I want this "new" binding to be used in other functions that call `evil-delete`.
But between lisp's defvar-vs-defun distinction, possibly-dynamic scoping, and forwarding optional-args, I'm having a bit of trouble translating this scheme to elisp. Any help appreciated. (I don't think I need to worry about "interactive", at least?)
Also, if there is a better way of doing this -- e.g. some hook available -- then I'd appreciate hearing that too. Finally, it's not out-of-question that I instead make new versions of the ~dozen "wrapper" functions and re-bind all the keys to use these new versions, thereby avoiding most issues except forwarding-default-args.