I'm trying to change evil-org to evil-insert-state when I add a note to my org files. I've tried to look it up, but can't figure it out. I've configured org-mode to always query me for a note after clocking out with (setq org-log-note-clock-out t), and I'd like to switch to evil-insert-mode after this happens.

The function org-add-log-note seems to be doing the work, but it doesn't define an after hook. So I guess the more general question is: how do I hook a function to another function call?

2 Answers 2


Which version of Org are you using? Mine (9.1.14 from the Org ELPA repo) runs org-log-buffer-setup-hook at the end of org-add-log-note. On my setup I put evil-insert-state in that hook and things work as expected.

  • Great! I use 9.1.14 as well. Apperently even after looking for it for half an hour I didn't see the line (run-hooks 'org-log-buffer-setup-hook))) at the end of the (defun org-add-log-note (&optional _purpose)
    – Japhir
    Dec 8, 2018 at 13:13

Alternate answer, since you also asked a more general question.

In general you can add a function call after another function by using advice, specifically :after advice.

But it's worth noting what the docs have to say in the "Advising Named Functions" section.

advice-add can be useful for altering the behavior of existing calls to an existing function without having to redefine the whole function. However, it can be a source of bugs, since existing callers to the function may assume the old behavior, and work incorrectly when the behavior is changed by advice. Advice can also cause confusion in debugging, if the person doing the debugging does not notice or remember that the function has been modified by advice.

For these reasons, advice should be reserved for the cases where you cannot modify a function's behavior in any other way.

I don't think this is likely to bite you in the specific case you describe, but if you have a recent enough version of Org and can find the org-log-buffer-setup-hook that I mentioned in my other answer that would be the better solution in this case.

  • Thanks for the explanation! The next time I encounter an issue like this I'll look for the hook again, first, and if it doesn't work I can add the advice-add. Cheers!
    – Japhir
    Dec 8, 2018 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.