I would like for all my text-based modes (org, markdown, message, mu4e-compose, etc) to use a single abbrev-table, and especially, to add new abbrevs to that shared table whenever I'm in one of those modes.

I know that inheritance between modes is possible, and I think something like this should allow one mode to inherit from another:

(defun endless/ispell-word-then-abbrev (p)
  "Call `ispell-word'. Then create an abbrev for the correction made.
   With prefix P, create local abbrev. Otherwise it will be global."
  (interactive "P")
  (let ((bef (downcase (or (thing-at-point 'word) ""))) aft)
    (call-interactively 'ispell-word)
    (setq aft (downcase (or (thing-at-point 'word) "")))
    (unless (string= aft bef)
      (message "\"%s\" now expands to \"%s\" %sally"
               bef aft (if p "glob" "loc" ))
        (if p global-abbrev-table local-abbrev-table)
         bef aft)))

So I would really prefer to set local-abbrev-table to the same table in all those text modes. Is there a good way to do this?

1 Answer 1


Well, I have an answer that seems to be working for me. I just add a hook to abbrev-mode; when it's loaded, it checks to see if it's in a text mode. If so, then it sets the local-abbrev-table to org-mode-abbrev-table. I am doing all of this in the :init phase of the use-package invocation for abbrev-mode. Here's my code, and hopefully it can help someone else out.

(use-package abbrev-mode
  (setq-default abbrev-mode t)
  ;; a hook funtion that sets the abbrev-table to org-mode-abbrev-table
  ;; whenever the major mode is a text mode
  (defun mwp-set-text-mode-abbrev-table ()
    (if (derived-mode-p 'text-mode)
        (setq local-abbrev-table org-mode-abbrev-table)))
  :commands abbrev-mode
  (abbrev-mode . mwp-set-text-mode-abbrev-table)
  ;; (setq default-abbrev-mode t)
  (setq abbrev-file-name "~/.emacs.d/abbrev_defs")
  (read-abbrev-file "~/.emacs.d/abbrev_defs")
  (setq save-abbrevs 'silently))

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.