(run_msdos_command): Support redirection of stderr.
[bpt/emacs.git] / src / abbrev.c
index ea7b619..73ed06d 100644 (file)
@@ -229,7 +229,9 @@ Returns t if expansion took place.")
      expansion".  */
   value = (MODIFF != oldmodiff ? Qt : Qnil);
 
-  if (XBUFFER (Vabbrev_start_location_buffer) != current_buffer)
+  wordstart = 0;
+  if (!(BUFFERP (Vabbrev_start_location_buffer) &&
+       XBUFFER (Vabbrev_start_location_buffer) == current_buffer))
     Vabbrev_start_location = Qnil;
   if (!NILP (Vabbrev_start_location))
     {
@@ -237,10 +239,12 @@ Returns t if expansion took place.")
       CHECK_NUMBER_COERCE_MARKER (tem, 0);
       wordstart = XINT (tem);
       Vabbrev_start_location = Qnil;
-      if (FETCH_CHAR (wordstart) == '-')
+      if (wordstart < BEGV || wordstart > ZV)
+       wordstart = 0;
+      if (wordstart && wordstart != ZV && FETCH_CHAR (wordstart) == '-')
        del_range (wordstart, wordstart + 1);
     }
-  else
+  if (!wordstart)
     wordstart = scan_words (point, -1);
 
   if (!wordstart)
@@ -271,7 +275,7 @@ Returns t if expansion took place.")
   if (VECTORP (current_buffer->abbrev_table))
     sym = oblookup (current_buffer->abbrev_table, buffer, p - buffer);
   else
-    XFASTINT (sym) = 0;
+    XSETFASTINT (sym, 0);
   if (INTEGERP (sym) || NILP (XSYMBOL (sym)->value))
     sym = oblookup (Vglobal_abbrev_table, buffer, p - buffer);
   if (INTEGERP (sym) || NILP (XSYMBOL (sym)->value))
@@ -279,6 +283,8 @@ Returns t if expansion took place.")
 
   if (INTERACTIVE && !EQ (minibuf_window, selected_window))
     {
+      /* Add an undo boundary, in case we are doing this for
+        a self-inserting command which has avoided making one so far.  */
       SET_PT (wordend);
       Fundo_boundary ();
     }
@@ -308,8 +314,8 @@ Returns t if expansion took place.")
       if (!abbrev_all_caps)
        if (scan_words (point, -1) > scan_words (wordstart, 1))
          {
-           upcase_initials_region (make_number (wordstart),
-                                   make_number (point));
+           Fupcase_initials_region (make_number (wordstart),
+                                    make_number (point));
            goto caped;
          }
       /* If expansion is one word, or if user says so, upcase it all. */