I want to advise org-edit-special so that a function runs before Emacs enters org-src-mode. I am not particularly tied to org-edit-special. If there is a hook like org-src-mode-hook (but that triggers before org-src-mode runs, that would be perfect.
So I have the following code:
#+BEGIN_SRC emacs-lisp (defun my-function () (message "bingo!")) (add-function :before (org-edit-special) #'(lambda () (my-function))) #+END_SRC When I C-c C-c this block, I get user-error: No special environment to edit here. Can you see the mistake?
(org-edit-special)is the result of calling the functionorg-edit-special- that's probably not what you want. Also, you should probably useadvice-add(see the manual), notadd-function.