5

I've defined a lot of abbrevs in latex-mode-abbrev-table and I'd like to use all the contents in latex-mode-abbrev-table and org-mode-abbrev-table when in org-mode.

A possible "solution" would be to write all the abbrevs in global-abbrev-table but I'd like to keep the global table clean.

So how can I use the merged version(LaTeX + Org) of abbrev table in org-mode?

Dan
  • 32,584
  • 6
  • 98
  • 168
Saddle Point
  • 481
  • 7
  • 23
  • that's a good idea! I don't think abbrevs support any kind of inheritance to link one table to another. You could just copy all your latex abbrevs into your org-mode abbrev table, but that would mean you have to maintain the two tables in parallel. – Tyler Feb 24 '17 at 14:25

2 Answers2

3

Use the :parents property to hold a list of tables from which to inherit abbrevs.

In your case, you can do:

(abbrev-table-put org-mode-abbrev-table
                  :parents (list latex-mode-abbrev-table))
Dan
  • 32,584
  • 6
  • 98
  • 168
0

It looks like the original answer is working for you, but the difficulty I had with it was that abbrevs added in the two modes were added to separate tables. This meant that if I added new autocorrects in org-mode, they would not be available in latex-mode. I'm not sure if this is what you want, but I did a two-way merge by setting the local-abbrev-table in a hook that I configure when I load the abbrev-mode package. For your case this would be something like:

(use-package abbrev-mode
  :init
  (setq-default abbrev-mode t)
  ;; a hook function 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 'org-mode)
        (setq local-abbrev-table latex-mode-abbrev-table)))
  :commands abbrev-mode
  :hook
  (abbrev-mode . mwp-set-text-mode-abbrev-table)

See also my similar question here: use a single abbrev-table for multiple modes?

Matt
  • 43
  • 6