It is a common practice to write Emacs configuration files using literate-programming style in Org mode.
Unfortunately, while improving readability, this comes with significant programming disadvantages. In particular, since there is no backing .el
file, Emacs is only aware of the code in the current source block. This means that except for the currently-edited block, navigation, symbol definition, and flycheck are all unavailable.
#+BEGIN_SRC emacs-lisp
(defun literate-but-invisible ()
(interactive)
(message "I close my eyes..."))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun humans-can-read-but-emacs-cannot ()
(interactive)
(literate-but-invisible) ; No navigation! Flycheck reports undefined symbol!
(message "...so that the room will be empty"))
#+END_SRC
Is there any way to tell Emacs to tangle and use the generated .el
file to provide these features in Org mode? Such a feature would improve the maintainability of literate Emacs Lisp code.
Note that while it would be a fantastic feature to see Flycheck working for Org and Emacs Lisp simultaneously in one buffer, I am only asking about how to instrument org-edit
buffers (the environment you get when you invoke org-edit-special
(usually C-c '
)). This should be easier since there is only one active mode for the buffer.
I have opened a feature request on the Flycheck repository here, and there is some relevant research in another issue here. However, I am not yet able to construct a solution.
find-file-hook
etc to detect whether opening emacs config org file.