I take notes with org-mode and abbrev-mode. Normally pressing SPC or RET leads to any abbreviations at point expanding before the edit is made.

This doesn't happen when I use C-RET (org-insert-heading-respect-content) or M-RET (org-meta-return). Is there a way to make this happen simpler than advising those functions?


A solution with advice is:

(defun expand-abbrev-eat-args (&rest args)
  "Call `expand-abbrev', ignoring ARGS."
(advice-add 'org-insert-heading :before #'expand-abbrev-eat-args)
(advice-add 'org-table-wrap-region :before #'expand-abbrev-eat-args)
(advice-add 'org-insert-item :before #'expand-abbrev-eat-args)

Adding this in your init.el should do the trick:

(advice-add 'org-meta-return :before #'expand-abbrev)
(advice-add 'org-meta-return :before #'org-insert-heading-respect-content)
  • Thanks! I tried this out and it misses some corner cases (not purely M-RET, such as a universal prefix argument or C-RET) that advising 'org-insert-heading instead gets. – Michael Hoffman Jan 6 '20 at 2:06

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.