]> code.delx.au - gnu-emacs/blobdiff - src/abbrev.c
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
[gnu-emacs] / src / abbrev.c
index 414a3e98b4850145394fcda810032481ba0fe0c7..c9ea673e6960feb14154ba0757afd1553a80f241 100644 (file)
@@ -1,11 +1,11 @@
 /* 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,
@@ -219,9 +219,14 @@ Returns t if expansion took place.")
   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;
@@ -238,21 +243,21 @@ Returns t if expansion took place.")
     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))
@@ -269,7 +274,7 @@ Returns t if expansion took place.")
   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))
     {
@@ -349,7 +354,9 @@ is not undone.")
       /* 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,
@@ -522,7 +529,7 @@ Calling `expand-abbrev' sets this to nil.");
 Trying to expand an abbrev in any other buffer clears `abbrev-start-location'.");
   Vabbrev_start_location_buffer = Qnil;
 
-  DEFVAR_PER_BUFFER ("local-abbrev-table", &current_buffer->abbrev_table,
+  DEFVAR_PER_BUFFER ("local-abbrev-table", &current_buffer->abbrev_table, Qnil,
     "Local (mode-specific) abbrev table of current buffer.");
 
   DEFVAR_BOOL ("abbrevs-changed", &abbrevs_changed,