squash@math.ufl.edu (Jonathan King) (10/28/90)
An abbrev mode question: I have some mode-specific abbrev tables eg. (tex-mode-abbrev-table) (mail-mode-abbrev-table) ... When tex mode is called, first the text-mode hook is called, then the tex-mode hook. This seems to be the right behavior. I would like abbrevs to work the same way, 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? One unaesthetic and probably dangerous way would be to have the text-mode hook Store away the global-abbrev table somewhere; Setq global-abbrev-table to text-mode-abbrev-table Set local-abbrev-table to tex-mode-abbrev-table Is there a better, less dangerous way? Jonathan squash@math.ufl.edu
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();