The default mode is fundamental, which is not really comfortable to edit elisp code did I miss something ?
A first idea is to to use an after advice to ensure
emacs-lisp-mode is turned on after
org-table-edit-formulas is run.
(advice-add #'org-table-edit-formulas :after #'emacs-lisp-mode)
However, this does not work well. Examining the source of the
function (in file
org-table.el) shows that it turns
fundamental-mode on then sets up a few things (variables and
keybindings) that the call to
emacs-lisp-mode will undo.
We want to call
emacs-lisp-mode just after (or ideally, instead of)
the call to
fundamental mode in
how to do it:
(defun my--advice-for-edit-formulas (orig-fun &rest args) (advice-add #'fundamental-mode :after #'emacs-lisp-mode) (apply orig-fun args) (advice-remove #'fundamental-mode #'emacs-lisp-mode)) (advice-add #'org-table-edit-formulas :around #'my--advice-for-edit-formulas)
We set an around advice to
org-table-edit-formulas whose job is
add an after advice to
fundamental-modeto make it run
- remove the advice to
emacs-lisp-mode only when itself
Now it's possible it would be better to add an option to choose the
org-table-edit-formulas will use, or to make it automatically
emacs-lisp-mode when the formulas are in elisp.