diff options
author | Glenn Morris <rgm@gnu.org> | 2006-12-05 05:29:21 +0000 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2006-12-05 05:29:21 +0000 |
commit | 0dcd524c1d91bdaa6aec478248b876f722b7ac3c (patch) | |
tree | 0be268ff34c8624410ea1a4bb6208afab4d02938 /src/abbrev.c | |
parent | 3852e553401bf011ce417d01f7995fe81da9641e (diff) | |
download | emacs-0dcd524c1d91bdaa6aec478248b876f722b7ac3c.tar.gz |
(Qforce): New Lisp_Object.
(Fdefine_abbrev): Do not overwrite non-system abbrevs with system
abbrevs, unless 'force is applied.
(syms_of_abbrev): Add Qforce.
Diffstat (limited to 'src/abbrev.c')
-rw-r--r-- | src/abbrev.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/abbrev.c b/src/abbrev.c index e371797f139..09c42030fe8 100644 --- a/src/abbrev.c +++ b/src/abbrev.c @@ -83,7 +83,7 @@ EMACS_INT last_abbrev_point; Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; -Lisp_Object Qsystem_type, Qcount; +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. */) @@ -107,7 +107,7 @@ DEFUN ("clear-abbrev-table", Fclear_abbrev_table, Sclear_abbrev_table, 1, 1, 0, XVECTOR (table)->contents[i] = make_number (0); return Qnil; } - + DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 6, 0, doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK. NAME must be a string. @@ -123,7 +123,9 @@ usage-count, which is incremented each time the abbrev is used. \(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. */) +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,6 +133,16 @@ which should not be saved in the user's abbreviation file. */) 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,6 +652,9 @@ syms_of_abbrev () 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"), |