diff options
| author | Glenn Morris | 2006-12-05 05:29:21 +0000 |
|---|---|---|
| committer | Glenn Morris | 2006-12-05 05:29:21 +0000 |
| commit | 0dcd524c1d91bdaa6aec478248b876f722b7ac3c (patch) | |
| tree | 0be268ff34c8624410ea1a4bb6208afab4d02938 | |
| parent | 3852e553401bf011ce417d01f7995fe81da9641e (diff) | |
| download | emacs-0dcd524c1d91bdaa6aec478248b876f722b7ac3c.tar.gz emacs-0dcd524c1d91bdaa6aec478248b876f722b7ac3c.zip | |
(Qforce): New Lisp_Object.
(Fdefine_abbrev): Do not overwrite non-system abbrevs with system
abbrevs, unless 'force is applied.
(syms_of_abbrev): Add Qforce.
| -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; | |||
| 83 | 83 | ||
| 84 | Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; | 84 | Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook; |
| 85 | 85 | ||
| 86 | Lisp_Object Qsystem_type, Qcount; | 86 | Lisp_Object Qsystem_type, Qcount, Qforce; |
| 87 | 87 | ||
| 88 | DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0, | 88 | DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0, |
| 89 | doc: /* Create a new, empty abbrev table object. */) | 89 | 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, | |||
| 107 | XVECTOR (table)->contents[i] = make_number (0); | 107 | XVECTOR (table)->contents[i] = make_number (0); |
| 108 | return Qnil; | 108 | return Qnil; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 6, 0, | 111 | DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 6, 0, |
| 112 | doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK. | 112 | doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK. |
| 113 | NAME must be a string. | 113 | NAME must be a string. |
| @@ -123,7 +123,9 @@ usage-count, which is incremented each time the abbrev is used. | |||
| 123 | \(The default is zero.) | 123 | \(The default is zero.) |
| 124 | 124 | ||
| 125 | SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation | 125 | SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation |
| 126 | which should not be saved in the user's abbreviation file. */) | 126 | which should not be saved in the user's abbreviation file. |
| 127 | Unless SYSTEM-FLAG is `force', a system abbreviation will not | ||
| 128 | overwrite a non-system abbreviation of the same name. */) | ||
| 127 | (table, name, expansion, hook, count, system_flag) | 129 | (table, name, expansion, hook, count, system_flag) |
| 128 | Lisp_Object table, name, expansion, hook, count, system_flag; | 130 | Lisp_Object table, name, expansion, hook, count, system_flag; |
| 129 | { | 131 | { |
| @@ -131,6 +133,16 @@ which should not be saved in the user's abbreviation file. */) | |||
| 131 | CHECK_VECTOR (table); | 133 | CHECK_VECTOR (table); |
| 132 | CHECK_STRING (name); | 134 | CHECK_STRING (name); |
| 133 | 135 | ||
| 136 | /* If defining a system abbrev, do not overwrite a non-system abbrev | ||
| 137 | of the same name, unless 'force is used. */ | ||
| 138 | if (!NILP (system_flag) && !EQ (system_flag, Qforce)) | ||
| 139 | { | ||
| 140 | sym = Fintern_soft (name, table); | ||
| 141 | |||
| 142 | if (!NILP (SYMBOL_VALUE (sym)) && | ||
| 143 | NILP (Fplist_get (XSYMBOL (sym)->plist, Qsystem_type))) return Qnil; | ||
| 144 | } | ||
| 145 | |||
| 134 | if (NILP (count)) | 146 | if (NILP (count)) |
| 135 | count = make_number (0); | 147 | count = make_number (0); |
| 136 | else | 148 | else |
| @@ -640,6 +652,9 @@ syms_of_abbrev () | |||
| 640 | Qcount = intern ("count"); | 652 | Qcount = intern ("count"); |
| 641 | staticpro (&Qcount); | 653 | staticpro (&Qcount); |
| 642 | 654 | ||
| 655 | Qforce = intern ("force"); | ||
| 656 | staticpro (&Qforce); | ||
| 657 | |||
| 643 | DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list, | 658 | DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list, |
| 644 | doc: /* List of symbols whose values are abbrev tables. */); | 659 | doc: /* List of symbols whose values are abbrev tables. */); |
| 645 | Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"), | 660 | Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"), |