I would like to chose which extra-modes would be turned on in temporary buffers, which are dedicated to editing code, through org-edit-special (C-x ').

For an example, auto-complete-mode and rainbow-delimiters-mode in every org-edit-special buffer etc.

1 Answer 1


org-edit-special turns on org-src-mode, a minor mode, whose mode hook is called when entering (or exiting) the mode. So you can turn on your minor modes in the org-src-mode hook:

(add-to-hook 'org-src-mode-hook (lambda () (auto-complete-mode 1) (rainbow-delimiters-mode 1) ...))

The doc string for org-src-mode-hook says:

org-src-mode-hook is a variable defined in ‘org-src.el’.

Its value is
(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
Original value was nil

  This variable may be risky if used as a file-local variable.
  You can customize this variable.

Hook run after Org switched a source code snippet to its Emacs mode.

This hook will run:
- when editing a source code snippet with ‘C-c '’
- when formatting a source code snippet for export with htmlize.

You may want to use this hook for example to turn off ‘outline-minor-mode’
or similar things which you want to have when editing a source code file,
but which mess up the display of a snippet in Org exported files.

Untested, but (dare I say it?) it should work :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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