[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/abbrev.c
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/src/abbrev.c |
Date: |
Fri, 28 Dec 2001 17:14:23 -0500 |
Index: emacs/src/abbrev.c
diff -c emacs/src/abbrev.c:1.47 emacs/src/abbrev.c:1.48
*** emacs/src/abbrev.c:1.47 Sun Nov 25 19:05:33 2001
--- emacs/src/abbrev.c Fri Dec 28 17:14:23 2001
***************
*** 82,87 ****
--- 82,89 ----
/* Hook to run before expanding any abbrev. */
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. */)
***************
*** 105,111 ****
return Qnil;
}
! DEFUN ("define-abbrev", Fdefine_abbrev, Sdefine_abbrev, 3, 5, 0,
doc: /* Define an abbrev in TABLE named NAME, to expand to EXPANSION
and call HOOK.
NAME must be a string.
EXPANSION should usually be a string.
--- 107,113 ----
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.
EXPANSION should usually be a string.
***************
*** 114,123 ****
it is called after EXPANSION is inserted.
If EXPANSION is not a string, the abbrev is a special one,
which does not expand in the usual way but only runs HOOK.
! COUNT, if specified, initializes the abbrev's usage-count
! which is incremented each time the abbrev is used. */)
! (table, name, expansion, hook, count)
! Lisp_Object table, name, expansion, hook, count;
{
Lisp_Object sym, oexp, ohook, tem;
CHECK_VECTOR (table);
--- 116,130 ----
it is called after EXPANSION is inserted.
If EXPANSION is not a string, the abbrev is a special one,
which does not expand in the usual way but only runs HOOK.
!
! COUNT, if specified, gives the initial value for the abbrev's
! 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. */)
! (table, name, expansion, hook, count, system_flag)
! Lisp_Object table, name, expansion, hook, count, system_flag;
{
Lisp_Object sym, oexp, ohook, tem;
CHECK_VECTOR (table);
***************
*** 137,148 ****
&& (tem = Fstring_equal (oexp, expansion), !NILP (tem))))
&&
(EQ (ohook, hook)
! || (tem = Fequal (ohook, hook), !NILP (tem)))))
abbrevs_changed = 1;
Fset (sym, expansion);
Ffset (sym, hook);
! Fsetplist (sym, count);
return name;
}
--- 144,160 ----
&& (tem = Fstring_equal (oexp, expansion), !NILP (tem))))
&&
(EQ (ohook, hook)
! || (tem = Fequal (ohook, hook), !NILP (tem))))
! && NILP (system_flag))
abbrevs_changed = 1;
Fset (sym, expansion);
Ffset (sym, hook);
!
! if (! NILP (system_flag))
! Fsetplist (sym, list4 (Qcount, count, Qsystem_type, system_flag));
! else
! Fsetplist (sym, count);
return name;
}
***************
*** 154,160 ****
Lisp_Object abbrev, expansion;
{
Fdefine_abbrev (Vglobal_abbrev_table, Fdowncase (abbrev),
! expansion, Qnil, make_number (0));
return abbrev;
}
--- 166,172 ----
Lisp_Object abbrev, expansion;
{
Fdefine_abbrev (Vglobal_abbrev_table, Fdowncase (abbrev),
! expansion, Qnil, make_number (0), Qnil);
return abbrev;
}
***************
*** 168,174 ****
error ("Major mode has no abbrev table");
Fdefine_abbrev (current_buffer->abbrev_table, Fdowncase (abbrev),
! expansion, Qnil, make_number (0));
return abbrev;
}
--- 180,186 ----
error ("Major mode has no abbrev table");
Fdefine_abbrev (current_buffer->abbrev_table, Fdowncase (abbrev),
! expansion, Qnil, make_number (0), Qnil);
return abbrev;
}
***************
*** 292,297 ****
--- 304,310 ----
wordend - wordstart, wordend_byte - wordstart_byte);
else
XSETFASTINT (sym, 0);
+
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
sym = oblookup (Vglobal_abbrev_table, buffer,
wordend - wordstart, wordend_byte - wordstart_byte);
***************
*** 314,322 ****
value = sym;
last_abbrev_point = wordstart;
if (INTEGERP (XSYMBOL (sym)->plist))
XSETINT (XSYMBOL (sym)->plist,
! XINT (XSYMBOL (sym)->plist) + 1); /* Increment use count */
/* If this abbrev has an expansion, delete the abbrev
and insert the expansion. */
--- 327,338 ----
value = sym;
last_abbrev_point = wordstart;
+ /* Increment use count. */
if (INTEGERP (XSYMBOL (sym)->plist))
XSETINT (XSYMBOL (sym)->plist,
! XINT (XSYMBOL (sym)->plist) + 1);
! else if (tem = Fget (sym, Qcount))
! Fput (sym, Qcount, make_number (XINT (tem) + 1));
/* If this abbrev has an expansion, delete the abbrev
and insert the expansion. */
***************
*** 427,435 ****
write_abbrev (sym, stream)
Lisp_Object sym, stream;
{
! Lisp_Object name;
! if (NILP (SYMBOL_VALUE (sym)))
return;
insert (" (", 5);
XSETSTRING (name, XSYMBOL (sym)->name);
Fprin1 (name, stream);
--- 443,464 ----
write_abbrev (sym, stream)
Lisp_Object sym, stream;
{
! Lisp_Object name, count, system_flag;
!
! if (INTEGERP (XSYMBOL (sym)->plist))
! {
! count = XSYMBOL (sym)->plist;
! system_flag = Qnil;
! }
! else
! {
! count = Fget (sym, Qcount);
! system_flag = Fget (sym, Qsystem_type);
! }
!
! if (NILP (SYMBOL_VALUE (sym)) || ! NILP (system_flag))
return;
+
insert (" (", 5);
XSETSTRING (name, XSYMBOL (sym)->name);
Fprin1 (name, stream);
***************
*** 438,444 ****
insert (" ", 1);
Fprin1 (XSYMBOL (sym)->function, stream);
insert (" ", 1);
! Fprin1 (XSYMBOL (sym)->plist, stream);
insert (")\n", 2);
}
--- 467,473 ----
insert (" ", 1);
Fprin1 (XSYMBOL (sym)->function, stream);
insert (" ", 1);
! Fprin1 (count, stream);
insert (")\n", 2);
}
***************
*** 446,459 ****
describe_abbrev (sym, stream)
Lisp_Object sym, stream;
{
! Lisp_Object one;
if (NILP (SYMBOL_VALUE (sym)))
return;
one = make_number (1);
Fprin1 (Fsymbol_name (sym), stream);
! Findent_to (make_number (15), one);
! Fprin1 (XSYMBOL (sym)->plist, stream);
Findent_to (make_number (20), one);
Fprin1 (SYMBOL_VALUE (sym), stream);
if (!NILP (XSYMBOL (sym)->function))
--- 475,508 ----
describe_abbrev (sym, stream)
Lisp_Object sym, stream;
{
! Lisp_Object one, count, system_flag;
!
! if (INTEGERP (XSYMBOL (sym)->plist))
! {
! count = XSYMBOL (sym)->plist;
! system_flag = Qnil;
! }
! else
! {
! count = Fget (sym, Qcount);
! system_flag = Fget (sym, Qsystem_type);
! }
if (NILP (SYMBOL_VALUE (sym)))
return;
+
one = make_number (1);
Fprin1 (Fsymbol_name (sym), stream);
!
! if (!NILP (system_flag))
! {
! insert_string (" (sys)");
! Findent_to (make_number (20), one);
! }
! else
! Findent_to (make_number (15), one);
!
! Fprin1 (count, stream);
Findent_to (make_number (20), one);
Fprin1 (SYMBOL_VALUE (sym), stream);
if (!NILP (XSYMBOL (sym)->function))
***************
*** 471,477 ****
If optional 2nd arg READABLE is non-nil, a human-readable description
is inserted. Otherwise the description is an expression,
a call to `define-abbrev-table', which would
! define the abbrev table NAME exactly as it is currently defined. */)
(name, readable)
Lisp_Object name, readable;
{
--- 520,528 ----
If optional 2nd arg READABLE is non-nil, a human-readable description
is inserted. Otherwise the description is an expression,
a call to `define-abbrev-table', which would
! define the abbrev table NAME exactly as it is currently defined.
!
! Abbrevs marked as "system abbrevs" are omitted. */)
(name, readable)
Lisp_Object name, readable;
{
***************
*** 508,519 ****
2, 2, 0,
doc: /* Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of elements
! of the form (ABBREVNAME EXPANSION HOOK USECOUNT). */)
(tablename, definitions)
Lisp_Object tablename, definitions;
{
Lisp_Object name, exp, hook, count;
! Lisp_Object table, elt;
CHECK_SYMBOL (tablename);
table = Fboundp (tablename);
--- 559,571 ----
2, 2, 0,
doc: /* Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of elements
! of the form (ABBREVNAME EXPANSION HOOK USECOUNT SYSTEMFLAG).
! \(If the list is shorter than that, omitted elements default to nil). */)
(tablename, definitions)
Lisp_Object tablename, definitions;
{
Lisp_Object name, exp, hook, count;
! Lisp_Object table, elt, sys;
CHECK_SYMBOL (tablename);
table = Fboundp (tablename);
***************
*** 531,538 ****
name = Fcar (elt); elt = Fcdr (elt);
exp = Fcar (elt); elt = Fcdr (elt);
hook = Fcar (elt); elt = Fcdr (elt);
! count = Fcar (elt);
! Fdefine_abbrev (table, name, exp, hook, count);
}
return Qnil;
}
--- 583,591 ----
name = Fcar (elt); elt = Fcdr (elt);
exp = Fcar (elt); elt = Fcdr (elt);
hook = Fcar (elt); elt = Fcdr (elt);
! count = Fcar (elt); elt = Fcdr (elt);
! sys = Fcar (elt);
! Fdefine_abbrev (table, name, exp, hook, count, sys);
}
return Qnil;
}
***************
*** 540,545 ****
--- 593,604 ----
void
syms_of_abbrev ()
{
+ Qsystem_type = intern ("system-type");
+ staticpro (&Qsystem_type);
+
+ Qcount = intern ("count");
+ staticpro (&Qcount);
+
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"),
- [Emacs-diffs] Changes to emacs/src/abbrev.c,
Richard M. Stallman <=