1

I have tried this out of guesswork but it doesn't work:

(add-hook 'org-add-note-mode-hook 'evil-insert-state)

Which follows the syntax of something that does work:

(add-hook 'org-capture-mode-hook 'evil-insert-state)

Bonus: How do I find out more information about the hooks available so I can call them correctly?

1 Answer 1

4

Your example is almost correct, but uses a non-existent hook. This is not considered an error by the interpreter because hook variables don't have to be defined before adding a function to them, this allows customizing them before a package has been loaded. The correct example would be as follows:

(add-hook 'org-log-buffer-setup-hook 'evil-insert-state)

I found this hook by looking through the Org sources. It should be possible to find it by consulting the documentation as well, however I didn't manage finding either org-add-note or org-log-buffer-setup-hook in the Org info manual. Therefore, your only realistic chance would have been to check out M-x customize-group RET org RET (where it's one of the first variables) or doing the same as me (and look for defcustom with a hook type in the sources). Perhaps you'll want to report an Org bug to remedy this in a future version, this can be done with M-x org-submit-bug-report.

3
  • Excellent, thanks @wasamasa. I'm curious about where exactly you looked at the defcustom hook in the source file. I'm new to programming overall and don't know where to look. 1. Do you have a URL of where you looked? 2. Do you have any tips for how to explore source files? 3. What is your process if you are entering a new codebase and want to learn more about it? Commented Apr 30, 2018 at 6:10
  • 1
    Emacs ships with its own elisp sources and help files, so consult these. If you don't have them, install them via your OS package manager. For org, it's a M-x find-library RET org RET or if you know the problematic function, M-x find-function RET org-add-note. I went through the sources a bit with searching to figure out the control flow (using edebug is useful if the control flow makes no sense) and noticed it ends up calling org-add-log-note which uses run-hooks on org-log-buffer-setup-hook.
    – wasamasa
    Commented May 1, 2018 at 10:18
  • Large elisp code bases are rare (most packages are tiny to medium-sized and most likely a single file), but if you encounter them, familiarize yourself with the file layout (like, by using your favorite file manager) and just navigate the individual files as needed. Jumping to definitions and finding usages of function calls is crucial here, the combination of M-., the many help commands and Evil's * to do a symbol search at point (vanilla Emacs has M-s . and M-s _) works for me.
    – wasamasa
    Commented May 1, 2018 at 10:21

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.