0

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?

2 Answers 2

0

A solution with advice is:

(defun expand-abbrev-eat-args (&rest args)
  "Call `expand-abbrev', ignoring ARGS."
  (expand-abbrev))
(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)
1
  • You can accept your own answer assuming it resolves your question.
    – NickD
    Jan 21, 2022 at 15:50
0

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)
1
  • 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. Jan 6, 2020 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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