[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: saved user abbrevs and system abbrevs
From: |
Glenn Morris |
Subject: |
Re: saved user abbrevs and system abbrevs |
Date: |
Thu, 30 Nov 2006 21:54:47 -0500 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Richard Stallman wrote:
> (defvar foo-abbrev-table nil)
>
> ;; Do not override any user abbrev for "foo".
> (unless (abbrev-expansion "foo" foo-abbrev-table)
> (define-abbrev foo-abbrev-table "foo" "foobar" nil 0 t))
>
> Maybe we should change define-abbrev so that defining a system
> abbrev does not override any user abbrev (unless you specify
> "override") in some way.
OK. I was really wondering if there was some way to avoid the problem
of not being able to initialize an abbrev-table in its defvar, since
it seems a bit odd/annoying/hard to remember. But I guess that there
isn't really, and that it does not matter that much.
Here's a patch for your suggestion.
*** abbrev.c 18 Apr 2006 20:57:56 -0000 1.69
--- abbrev.c 1 Dec 2006 02:47:52 -0000
***************
*** 83,89 ****
Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
! Lisp_Object Qsystem_type, Qcount;
DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table,
0, 0, 0,
doc: /* Create a new, empty abbrev table object. */)
--- 83,89 ----
Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
! Lisp_Object Qsystem_type, Qcount, Qforce;
DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table,
0, 0, 0,
doc: /* Create a new, empty abbrev table object. */)
***************
*** 123,129 ****
\(The default is zero.)
SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation
! which should not be saved in the user's abbreviation file. */)
(table, name, expansion, hook, count, system_flag)
Lisp_Object table, name, expansion, hook, count, system_flag;
{
--- 123,131 ----
\(The default is zero.)
SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation
! which should not be saved in the user's abbreviation file.
! Unless SYSTEM-FLAG is `force', a system abbreviation will not
! overwrite a non-system abbreviation of the same name. */)
(table, name, expansion, hook, count, system_flag)
Lisp_Object table, name, expansion, hook, count, system_flag;
{
***************
*** 131,136 ****
--- 133,148 ----
CHECK_VECTOR (table);
CHECK_STRING (name);
+ /* If defining a system abbrev, do not overwrite a non-system abbrev
+ of the same name, unless 'force is used. */
+ if (!NILP (system_flag) && !EQ (system_flag, Qforce))
+ {
+ sym = Fintern_soft (name, table);
+
+ if (!NILP (SYMBOL_VALUE (sym)) &&
+ NILP (Fplist_get (XSYMBOL (sym)->plist, Qsystem_type))) return Qnil;
+ }
+
if (NILP (count))
count = make_number (0);
else
***************
*** 640,645 ****
--- 652,660 ----
Qcount = intern ("count");
staticpro (&Qcount);
+ Qforce = intern ("force");
+ staticpro (&Qforce);
+
DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list,
doc: /* List of symbols whose values are abbrev tables.
*/);
Vabbrev_table_name_list = Fcons (intern
("fundamental-mode-abbrev-table"),