#include "commands.h"
#include "buffer.h"
#include "window.h"
+#include "charset.h"
#include "syntax.h"
/* An abbrev table is an obarray.
If HOOK is non-nil, it should be a function of no arguments;\n\
it is called after EXPANSION is inserted.\n\
If EXPANSION is not a string, the abbrev is a special one,\n\
- which does not expand in the usual way but only runs HOOK.")
+ which does not expand in the usual way but only runs HOOK.\n\
+COUNT, if specified, initializes the abbrev's usage-count\n\
+which is incremented each time the abbrev is used.")
(table, name, expansion, hook, count)
Lisp_Object table, name, expansion, hook, count;
{
int uccount = 0, lccount = 0;
register Lisp_Object sym;
Lisp_Object expansion, hook, tem;
- int oldmodiff = MODIFF;
Lisp_Object value;
value = Qnil;
hook = XSYMBOL (sym)->function;
if (!NILP (hook))
- call0 (hook);
+ {
+ Lisp_Object expanded, prop;
+
+ /* If the abbrev has a hook function, run it. */
+ expanded = call0 (hook);
+
+ /* In addition, if the hook function is a symbol with a a
+ non-nil `no-self-insert' property, let the value it returned
+ specify whether we consider that an expansion took place. If
+ it returns nil, no expansion has been done. */
+
+ if (SYMBOLP (hook)
+ && NILP (expanded)
+ && (prop = Fget (hook, intern ("no-self-insert")),
+ !NILP (prop)))
+ value = Qnil;
+ }
return value;
}
/* Total number of characters deleted. */
adjust = ZV - zv_before;
}
- SET_PT (last_abbrev_point < opoint ? opoint - adjust : opoint);
+ SET_PT (last_abbrev_point < opoint ? opoint + adjust : opoint);
return Qnil;
}
\f