diff options
| author | Richard M. Stallman | 2001-12-28 22:14:38 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-12-28 22:14:38 +0000 |
| commit | 2d6c1fc09aa71d47fea2b7489837312a83893191 (patch) | |
| tree | 13099cc0c533d7fdec6c2c6c217d3bfc627e7cde /src | |
| parent | 07025a551c4b398f6527a11505678a931da041f1 (diff) | |
| download | emacs-2d6c1fc09aa71d47fea2b7489837312a83893191.tar.gz emacs-2d6c1fc09aa71d47fea2b7489837312a83893191.zip | |
Use the plist of an abbrev for multiple params if nec.
(Fdefine_abbrev): New arg SYSTEM-FLAG for a system abbrev.
(Fdefine_global_abbrev, Fdefine_mode_abbrev):
Update calls to Fdefine_abbrev.
(write_abbrev): Update for changed data format.
Don't list "system" abbrevs.
(Fexpand_abbrev): Update use count with new data format.
(describe_abbrev): Update for changed data format.
(Fdefine_abbrev_table): Handle the new SYSTEM-FLAG.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/abbrev.c | 101 |
2 files changed, 90 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ed80f7a59cd..116d8ec26e4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 2001-12-28 Richard M. Stallman <rms@gnu.org> | 1 | 2001-12-28 Richard M. Stallman <rms@gnu.org> |
| 2 | 2 | ||
| 3 | * abbrev.c: Use the plist of an abbrev for multiple params if nec. | ||
| 4 | (Fdefine_abbrev): New arg SYSTEM-FLAG for a system abbrev. | ||
| 5 | (Fdefine_global_abbrev, Fdefine_mode_abbrev): | ||
| 6 | Update calls to Fdefine_abbrev. | ||
| 7 | (write_abbrev): Update for changed data format. | ||
| 8 | Don't list "system" abbrevs. | ||
| 9 | (Fexpand_abbrev): Update use count with new data format. | ||
| 10 | (describe_abbrev): Update for changed data format. | ||
| 11 | (Fdefine_abbrev_table): Handle the new SYSTEM-FLAG. | ||
| 12 | |||
| 3 | * config.in (HAVE_MBSINIT): Add #undef. | 13 | * config.in (HAVE_MBSINIT): Add #undef. |
| 4 | 14 | ||
| 5 | * strftime.c (mbsinit): Define as no-op if not available. | 15 | * strftime.c (mbsinit): Define as no-op if not available. |
diff --git a/src/abbrev.c b/src/abbrev.c index 58ddd6dba49..217de1c5a6e 100644 --- a/src/abbrev.c +++ b/src/abbrev.c | |||
| @@ -82,6 +82,8 @@ int last_abbrev_point; | |||
| 82 | /* Hook to run before expanding any abbrev. */ | 82 | /* Hook to run before expanding any abbrev. */ |
| 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 | |||
| 86 | Lisp_Object Qsystem_type, Qcount; | ||
| 85 | 87 | ||
| 86 | 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, |
| 87 | doc: /* Create a new, empty abbrev table object. */) | 89 | doc: /* Create a new, empty abbrev table object. */) |
| @@ -105,7 +107,7 @@ DEFUN ("clear-abbrev-table", Fclear_abbrev_table, Sclear_abbrev_table, 1, 1, 0, | |||
| 105 | return Qnil; | 107 | return Qnil; |
| 106 | } | 108 | } |
| 107 | 109 | ||
| 108 | DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 5, 0, | 110 | DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 6, 0, |
| 109 | doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK. | 111 | doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION and call HOOK. |
| 110 | NAME must be a string. | 112 | NAME must be a string. |
| 111 | EXPANSION should usually be a string. | 113 | EXPANSION should usually be a string. |
| @@ -114,10 +116,15 @@ If HOOK is non-nil, it should be a function of no arguments; | |||
| 114 | it is called after EXPANSION is inserted. | 116 | it is called after EXPANSION is inserted. |
| 115 | If EXPANSION is not a string, the abbrev is a special one, | 117 | If EXPANSION is not a string, the abbrev is a special one, |
| 116 | which does not expand in the usual way but only runs HOOK. | 118 | which does not expand in the usual way but only runs HOOK. |
| 117 | COUNT, if specified, initializes the abbrev's usage-count | 119 | |
| 118 | which is incremented each time the abbrev is used. */) | 120 | COUNT, if specified, gives the initial value for the abbrev's |
| 119 | (table, name, expansion, hook, count) | 121 | usage-count, which is incremented each time the abbrev is used. |
| 120 | Lisp_Object table, name, expansion, hook, count; | 122 | \(The default is zero.) |
| 123 | |||
| 124 | SYSTEM-FLAG, if non-nil, says that this is a "system" abbreviation | ||
| 125 | which should not be saved in the user's abbreviation file. */) | ||
| 126 | (table, name, expansion, hook, count, system_flag) | ||
| 127 | Lisp_Object table, name, expansion, hook, count, system_flag; | ||
| 121 | { | 128 | { |
| 122 | Lisp_Object sym, oexp, ohook, tem; | 129 | Lisp_Object sym, oexp, ohook, tem; |
| 123 | CHECK_VECTOR (table); | 130 | CHECK_VECTOR (table); |
| @@ -137,12 +144,17 @@ which is incremented each time the abbrev is used. */) | |||
| 137 | && (tem = Fstring_equal (oexp, expansion), !NILP (tem)))) | 144 | && (tem = Fstring_equal (oexp, expansion), !NILP (tem)))) |
| 138 | && | 145 | && |
| 139 | (EQ (ohook, hook) | 146 | (EQ (ohook, hook) |
| 140 | || (tem = Fequal (ohook, hook), !NILP (tem))))) | 147 | || (tem = Fequal (ohook, hook), !NILP (tem)))) |
| 148 | && NILP (system_flag)) | ||
| 141 | abbrevs_changed = 1; | 149 | abbrevs_changed = 1; |
| 142 | 150 | ||
| 143 | Fset (sym, expansion); | 151 | Fset (sym, expansion); |
| 144 | Ffset (sym, hook); | 152 | Ffset (sym, hook); |
| 145 | Fsetplist (sym, count); | 153 | |
| 154 | if (! NILP (system_flag)) | ||
| 155 | Fsetplist (sym, list4 (Qcount, count, Qsystem_type, system_flag)); | ||
| 156 | else | ||
| 157 | Fsetplist (sym, count); | ||
| 146 | 158 | ||
| 147 | return name; | 159 | return name; |
| 148 | } | 160 | } |
| @@ -154,7 +166,7 @@ DEFUN ("define-global-abbrev", Fdefine_global_abbrev, Sdefine_global_abbrev, 2, | |||
| 154 | Lisp_Object abbrev, expansion; | 166 | Lisp_Object abbrev, expansion; |
| 155 | { | 167 | { |
| 156 | Fdefine_abbrev (Vglobal_abbrev_table, Fdowncase (abbrev), | 168 | Fdefine_abbrev (Vglobal_abbrev_table, Fdowncase (abbrev), |
| 157 | expansion, Qnil, make_number (0)); | 169 | expansion, Qnil, make_number (0), Qnil); |
| 158 | return abbrev; | 170 | return abbrev; |
| 159 | } | 171 | } |
| 160 | 172 | ||
| @@ -168,7 +180,7 @@ DEFUN ("define-mode-abbrev", Fdefine_mode_abbrev, Sdefine_mode_abbrev, 2, 2, | |||
| 168 | error ("Major mode has no abbrev table"); | 180 | error ("Major mode has no abbrev table"); |
| 169 | 181 | ||
| 170 | Fdefine_abbrev (current_buffer->abbrev_table, Fdowncase (abbrev), | 182 | Fdefine_abbrev (current_buffer->abbrev_table, Fdowncase (abbrev), |
| 171 | expansion, Qnil, make_number (0)); | 183 | expansion, Qnil, make_number (0), Qnil); |
| 172 | return abbrev; | 184 | return abbrev; |
| 173 | } | 185 | } |
| 174 | 186 | ||
| @@ -292,6 +304,7 @@ Returns the abbrev symbol, if expansion took place. */) | |||
| 292 | wordend - wordstart, wordend_byte - wordstart_byte); | 304 | wordend - wordstart, wordend_byte - wordstart_byte); |
| 293 | else | 305 | else |
| 294 | XSETFASTINT (sym, 0); | 306 | XSETFASTINT (sym, 0); |
| 307 | |||
| 295 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) | 308 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
| 296 | sym = oblookup (Vglobal_abbrev_table, buffer, | 309 | sym = oblookup (Vglobal_abbrev_table, buffer, |
| 297 | wordend - wordstart, wordend_byte - wordstart_byte); | 310 | wordend - wordstart, wordend_byte - wordstart_byte); |
| @@ -314,9 +327,12 @@ Returns the abbrev symbol, if expansion took place. */) | |||
| 314 | value = sym; | 327 | value = sym; |
| 315 | last_abbrev_point = wordstart; | 328 | last_abbrev_point = wordstart; |
| 316 | 329 | ||
| 330 | /* Increment use count. */ | ||
| 317 | if (INTEGERP (XSYMBOL (sym)->plist)) | 331 | if (INTEGERP (XSYMBOL (sym)->plist)) |
| 318 | XSETINT (XSYMBOL (sym)->plist, | 332 | XSETINT (XSYMBOL (sym)->plist, |
| 319 | XINT (XSYMBOL (sym)->plist) + 1); /* Increment use count */ | 333 | XINT (XSYMBOL (sym)->plist) + 1); |
| 334 | else if (tem = Fget (sym, Qcount)) | ||
| 335 | Fput (sym, Qcount, make_number (XINT (tem) + 1)); | ||
| 320 | 336 | ||
| 321 | /* If this abbrev has an expansion, delete the abbrev | 337 | /* If this abbrev has an expansion, delete the abbrev |
| 322 | and insert the expansion. */ | 338 | and insert the expansion. */ |
| @@ -427,9 +443,22 @@ static void | |||
| 427 | write_abbrev (sym, stream) | 443 | write_abbrev (sym, stream) |
| 428 | Lisp_Object sym, stream; | 444 | Lisp_Object sym, stream; |
| 429 | { | 445 | { |
| 430 | Lisp_Object name; | 446 | Lisp_Object name, count, system_flag; |
| 431 | if (NILP (SYMBOL_VALUE (sym))) | 447 | |
| 448 | if (INTEGERP (XSYMBOL (sym)->plist)) | ||
| 449 | { | ||
| 450 | count = XSYMBOL (sym)->plist; | ||
| 451 | system_flag = Qnil; | ||
| 452 | } | ||
| 453 | else | ||
| 454 | { | ||
| 455 | count = Fget (sym, Qcount); | ||
| 456 | system_flag = Fget (sym, Qsystem_type); | ||
| 457 | } | ||
| 458 | |||
| 459 | if (NILP (SYMBOL_VALUE (sym)) || ! NILP (system_flag)) | ||
| 432 | return; | 460 | return; |
| 461 | |||
| 433 | insert (" (", 5); | 462 | insert (" (", 5); |
| 434 | XSETSTRING (name, XSYMBOL (sym)->name); | 463 | XSETSTRING (name, XSYMBOL (sym)->name); |
| 435 | Fprin1 (name, stream); | 464 | Fprin1 (name, stream); |
| @@ -438,7 +467,7 @@ write_abbrev (sym, stream) | |||
| 438 | insert (" ", 1); | 467 | insert (" ", 1); |
| 439 | Fprin1 (XSYMBOL (sym)->function, stream); | 468 | Fprin1 (XSYMBOL (sym)->function, stream); |
| 440 | insert (" ", 1); | 469 | insert (" ", 1); |
| 441 | Fprin1 (XSYMBOL (sym)->plist, stream); | 470 | Fprin1 (count, stream); |
| 442 | insert (")\n", 2); | 471 | insert (")\n", 2); |
| 443 | } | 472 | } |
| 444 | 473 | ||
| @@ -446,14 +475,34 @@ static void | |||
| 446 | describe_abbrev (sym, stream) | 475 | describe_abbrev (sym, stream) |
| 447 | Lisp_Object sym, stream; | 476 | Lisp_Object sym, stream; |
| 448 | { | 477 | { |
| 449 | Lisp_Object one; | 478 | Lisp_Object one, count, system_flag; |
| 479 | |||
| 480 | if (INTEGERP (XSYMBOL (sym)->plist)) | ||
| 481 | { | ||
| 482 | count = XSYMBOL (sym)->plist; | ||
| 483 | system_flag = Qnil; | ||
| 484 | } | ||
| 485 | else | ||
| 486 | { | ||
| 487 | count = Fget (sym, Qcount); | ||
| 488 | system_flag = Fget (sym, Qsystem_type); | ||
| 489 | } | ||
| 450 | 490 | ||
| 451 | if (NILP (SYMBOL_VALUE (sym))) | 491 | if (NILP (SYMBOL_VALUE (sym))) |
| 452 | return; | 492 | return; |
| 493 | |||
| 453 | one = make_number (1); | 494 | one = make_number (1); |
| 454 | Fprin1 (Fsymbol_name (sym), stream); | 495 | Fprin1 (Fsymbol_name (sym), stream); |
| 455 | Findent_to (make_number (15), one); | 496 | |
| 456 | Fprin1 (XSYMBOL (sym)->plist, stream); | 497 | if (!NILP (system_flag)) |
| 498 | { | ||
| 499 | insert_string (" (sys)"); | ||
| 500 | Findent_to (make_number (20), one); | ||
| 501 | } | ||
| 502 | else | ||
| 503 | Findent_to (make_number (15), one); | ||
| 504 | |||
| 505 | Fprin1 (count, stream); | ||
| 457 | Findent_to (make_number (20), one); | 506 | Findent_to (make_number (20), one); |
| 458 | Fprin1 (SYMBOL_VALUE (sym), stream); | 507 | Fprin1 (SYMBOL_VALUE (sym), stream); |
| 459 | if (!NILP (XSYMBOL (sym)->function)) | 508 | if (!NILP (XSYMBOL (sym)->function)) |
| @@ -471,7 +520,9 @@ NAME is a symbol whose value is an abbrev table. | |||
| 471 | If optional 2nd arg READABLE is non-nil, a human-readable description | 520 | If optional 2nd arg READABLE is non-nil, a human-readable description |
| 472 | is inserted. Otherwise the description is an expression, | 521 | is inserted. Otherwise the description is an expression, |
| 473 | a call to `define-abbrev-table', which would | 522 | a call to `define-abbrev-table', which would |
| 474 | define the abbrev table NAME exactly as it is currently defined. */) | 523 | define the abbrev table NAME exactly as it is currently defined. |
| 524 | |||
| 525 | Abbrevs marked as "system abbrevs" are omitted. */) | ||
| 475 | (name, readable) | 526 | (name, readable) |
| 476 | Lisp_Object name, readable; | 527 | Lisp_Object name, readable; |
| 477 | { | 528 | { |
| @@ -508,12 +559,13 @@ DEFUN ("define-abbrev-table", Fdefine_abbrev_table, Sdefine_abbrev_table, | |||
| 508 | 2, 2, 0, | 559 | 2, 2, 0, |
| 509 | doc: /* Define TABLENAME (a symbol) as an abbrev table name. | 560 | doc: /* Define TABLENAME (a symbol) as an abbrev table name. |
| 510 | Define abbrevs in it according to DEFINITIONS, which is a list of elements | 561 | Define abbrevs in it according to DEFINITIONS, which is a list of elements |
| 511 | of the form (ABBREVNAME EXPANSION HOOK USECOUNT). */) | 562 | of the form (ABBREVNAME EXPANSION HOOK USECOUNT SYSTEMFLAG). |
| 563 | \(If the list is shorter than that, omitted elements default to nil). */) | ||
| 512 | (tablename, definitions) | 564 | (tablename, definitions) |
| 513 | Lisp_Object tablename, definitions; | 565 | Lisp_Object tablename, definitions; |
| 514 | { | 566 | { |
| 515 | Lisp_Object name, exp, hook, count; | 567 | Lisp_Object name, exp, hook, count; |
| 516 | Lisp_Object table, elt; | 568 | Lisp_Object table, elt, sys; |
| 517 | 569 | ||
| 518 | CHECK_SYMBOL (tablename); | 570 | CHECK_SYMBOL (tablename); |
| 519 | table = Fboundp (tablename); | 571 | table = Fboundp (tablename); |
| @@ -531,8 +583,9 @@ of the form (ABBREVNAME EXPANSION HOOK USECOUNT). */) | |||
| 531 | name = Fcar (elt); elt = Fcdr (elt); | 583 | name = Fcar (elt); elt = Fcdr (elt); |
| 532 | exp = Fcar (elt); elt = Fcdr (elt); | 584 | exp = Fcar (elt); elt = Fcdr (elt); |
| 533 | hook = Fcar (elt); elt = Fcdr (elt); | 585 | hook = Fcar (elt); elt = Fcdr (elt); |
| 534 | count = Fcar (elt); | 586 | count = Fcar (elt); elt = Fcdr (elt); |
| 535 | Fdefine_abbrev (table, name, exp, hook, count); | 587 | sys = Fcar (elt); |
| 588 | Fdefine_abbrev (table, name, exp, hook, count, sys); | ||
| 536 | } | 589 | } |
| 537 | return Qnil; | 590 | return Qnil; |
| 538 | } | 591 | } |
| @@ -540,6 +593,12 @@ of the form (ABBREVNAME EXPANSION HOOK USECOUNT). */) | |||
| 540 | void | 593 | void |
| 541 | syms_of_abbrev () | 594 | syms_of_abbrev () |
| 542 | { | 595 | { |
| 596 | Qsystem_type = intern ("system-type"); | ||
| 597 | staticpro (&Qsystem_type); | ||
| 598 | |||
| 599 | Qcount = intern ("count"); | ||
| 600 | staticpro (&Qcount); | ||
| 601 | |||
| 543 | DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list, | 602 | DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list, |
| 544 | doc: /* List of symbols whose values are abbrev tables. */); | 603 | doc: /* List of symbols whose values are abbrev tables. */); |
| 545 | Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"), | 604 | Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"), |