/* Primitives for word-abbrev mode.
- Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
int uccount = 0, lccount = 0;
register Lisp_Object sym;
Lisp_Object expansion, hook, tem;
+ int oldmodiff = MODIFF;
+ Lisp_Object value;
if (!NILP (Vrun_hooks))
call1 (Vrun_hooks, Qpre_abbrev_expand_hook);
+ /* If the hook changes the buffer, treat that as having "done an
+ expansion". */
+ value = (MODIFF != oldmodiff ? Qt : Qnil);
if (XBUFFER (Vabbrev_start_location_buffer) != current_buffer)
Vabbrev_start_location = Qnil;
wordstart = scan_words (point, -1);
if (!wordstart)
- return Qnil;
+ return value;
wordend = scan_words (wordstart, 1);
if (!wordend)
- return Qnil;
+ return value;
if (wordend > point)
wordend = point;
whitecnt = point - wordend;
if (wordend <= wordstart)
- return Qnil;
+ return value;
p = buffer = (char *) alloca (wordend - wordstart);
- for (idx = wordstart; idx < point; idx++)
+ for (idx = wordstart; idx < wordend; idx++)
{
register int c = FETCH_CHAR (idx);
if (UPPERCASEP (c))
if (XTYPE (sym) == Lisp_Int || NILP (XSYMBOL (sym)->value))
sym = oblookup (Vglobal_abbrev_table, buffer, p - buffer);
if (XTYPE (sym) == Lisp_Int || NILP (XSYMBOL (sym)->value))
- return Qnil;
+ return value;
if (INTERACTIVE && !EQ (minibuf_window, selected_window))
{
/* This isn't correct if Vlast_abbrev->function was used
to do the expansion */
Lisp_Object val;
- XSET (val, Lisp_String, XSYMBOL (Vlast_abbrev)->value);
+ val = XSYMBOL (Vlast_abbrev)->value;
+ if (XTYPE (val) != Lisp_String)
+ error ("value of abbrev-symbol must be a string");
adjust = XSTRING (val)->size;
del_range (point, point + adjust);
insert_from_string (Vlast_abbrev_text, 0,
Trying to expand an abbrev in any other buffer clears `abbrev-start-location'.");
Vabbrev_start_location_buffer = Qnil;
- DEFVAR_PER_BUFFER ("local-abbrev-table", ¤t_buffer->abbrev_table,
+ DEFVAR_PER_BUFFER ("local-abbrev-table", ¤t_buffer->abbrev_table, Qnil,
"Local (mode-specific) abbrev table of current buffer.");
DEFVAR_BOOL ("abbrevs-changed", &abbrevs_changed,