How can I prepend a function call in Elisp?
E.g. I have a key binding (C-c C-c C-t
) that runs some tests (command rustic-cargo-test
) and it always asks me if I want to save - I'd like to run (save-some-buffers 'no-prompt)
each time before this, so it doesn't ask.
With the standard recompile
function I created my own function and rebound the key, e.g.:
(defun save-and-recompile ()
(interactive)
(save-some-buffers 'no-prompt)
(recompile))
(global-set-key (kbd "C-c C-k") 'save-and-recompile)
But this feels a bit hacky, and I would want to do it for other rustic-cargo-*
functions. Is there a better way than writing a function/macro to automate the above? (Probably putting it in the rustic-hook
and not making it global though!)