[gnu.emacs.help] How? A "global" text-mode abbrev table?

wmesard@oracle.com (Wayne Mesard) (11/13/90)

squash@math.ufl.edu (Jonathan King) writes:
>  Eg. when I'm in TeX mode, my effective abbrev table is the
>*concatenation* of
>
>    (text-mode-abbrev-table)
>with
>    (tex-mode-abbrev-table)
>
>
>
>What is the right way to do this?  

IMHO, the granularity of control in abbrev definition is way too coarse.
I had a similar problem:  I wanted to merge two abbrev tables.  

Everyone in my group loads a common abbrev table.  Previosuly, if they
wanted to add to or modify it, they had to make a copy of the file
containing the common abbrevs, then make changes to that file.  Every
time the administrator changed the common file, they'd have to get the
new one and again merge it by hand.

To solve this problem, I wrote the following function.  It takes the
same arguments as DEFINE-ABBREV-TABLE, but it doesn't clobber any
abbrevs that are already in the table (unless, of course, there is a
name conflict).

   ;;; Modify an abbrev table.  WMesard@Oracle.COM

   (defun add-abbrevs (tabname new-abbrevs)
     "Just like define-abbrev-table, except existing abbrevs are not
   destroyed.  Args are the same too: TABNAME is a symbol, NEW-ABBREVS
   is a list of elements of the form (ABBREVNAME EXPANSION HOOK USECOUNT)."
     (while new-abbrevs
       (apply 'define-abbrev (symbol-value tabname)
	      (car new-abbrevs))
       (setq new-abbrevs (cdr new-abbrevs))
       ))


If you say:

   (setq tex-mode-abbrev-table (copy-sequence text-mode-abbrev-table))

and then

   (add-abbrevs 'tex-mode-abbrev-table
     (
	...your abbrevs go here...
      ))

you should be all set.

Wayne();