]> git.eshelyaron.com Git - emacs.git/commitdiff
(describe_abbrev): Return void.
authorRichard M. Stallman <rms@gnu.org>
Wed, 31 Dec 1997 05:05:32 +0000 (05:05 +0000)
committerRichard M. Stallman <rms@gnu.org>
Wed, 31 Dec 1997 05:05:32 +0000 (05:05 +0000)
(write_abbrev): Return void.
(Fexpand_abbrev): Scan in bytepos along with charpos.
(Funexpand_abbrev): Use bytepos to delete the expansion.

src/abbrev.c

index 8c28e1c3ff01a027f5cb2af6fb004cddb647fb61..49b94565aa0ed0eff03510a076ff7b2e66bf21a1 100644 (file)
@@ -218,7 +218,8 @@ Returns the abbrev symbol, if expansion took place.")
   ()
 {
   register char *buffer, *p;
-  register int wordstart, wordend, idx;
+  int wordstart, wordend;
+  register int wordstart_byte, wordend_byte, idx;
   int whitecnt;
   int uccount = 0, lccount = 0;
   register Lisp_Object sym;
@@ -243,8 +244,12 @@ Returns the abbrev symbol, if expansion took place.")
       Vabbrev_start_location = Qnil;
       if (wordstart < BEGV || wordstart > ZV)
        wordstart = 0;
-      if (wordstart && wordstart != ZV && FETCH_BYTE (wordstart) == '-')
-       del_range (wordstart, wordstart + 1);
+      if (wordstart && wordstart != ZV)
+       {
+         wordstart_byte = CHAR_TO_BYTE (wordstart);
+         if (FETCH_BYTE (wordstart_byte) == '-')
+           del_range (wordstart, wordstart + 1);
+       }
     }
   if (!wordstart)
     wordstart = scan_words (PT, -1);
@@ -252,20 +257,24 @@ Returns the abbrev symbol, if expansion took place.")
   if (!wordstart)
     return value;
 
+  wordstart_byte = CHAR_TO_BYTE (wordstart);
   wordend = scan_words (wordstart, 1);
   if (!wordend)
     return value;
 
   if (wordend > PT)
     wordend = PT;
+
+  wordend_byte = CHAR_TO_BYTE (wordend);
   whitecnt = PT - wordend;
   if (wordend <= wordstart)
     return value;
 
-  p = buffer = (char *) alloca (wordend - wordstart);
+  p = buffer = (char *) alloca (wordend_byte - wordstart_byte);
 
-  for (idx = wordstart; idx < wordend; idx++)
+  for (idx = wordstart_byte; idx < wordend_byte; idx++)
     {
+      /* ??? This loop needs to go by characters!  */
       register int c = FETCH_BYTE (idx);
       if (UPPERCASEP (c))
        c = DOWNCASE (c), uccount++;
@@ -310,7 +319,7 @@ Returns the abbrev symbol, if expansion took place.")
     {
       SET_PT (wordstart);
 
-      del_range (wordstart, wordend);
+      del_range_both (wordstart, wordend, wordstart_byte, wordend_byte, 1);
 
       insert_from_string (expansion, 0, XSTRING (expansion)->size, 1);
       SET_PT (PT + whitecnt);
@@ -335,14 +344,15 @@ Returns the abbrev symbol, if expansion took place.")
       else if (uccount)
        {
          /* Abbrev included some caps.  Cap first initial of expansion */
-         int pos = wordstart;
+         int pos = wordstart_byte;
 
          /* Find the initial.  */
-         while (pos < PT
-                && SYNTAX (*BUF_CHAR_ADDRESS (current_buffer, pos)) != Sword)
+         while (pos < PT_BYTE
+                && SYNTAX (*BUF_BYTE_ADDRESS (current_buffer, pos)) != Sword)
            pos++;
 
          /* Change just that.  */
+         pos = BYTE_TO_CHAR (pos);
          Fupcase_initials_region (make_number (pos), make_number (pos + 1));
        }
     }
@@ -371,22 +381,25 @@ is not undone.")
       /* This isn't correct if Vlast_abbrev->function was used
          to do the expansion */
       Lisp_Object val;
+      int zv_before;
+
       val = XSYMBOL (Vlast_abbrev)->value;
       if (!STRINGP (val))
        error ("value of abbrev-symbol must be a string");
-      adjust = XSTRING (val)->size;
-      del_range (PT, PT + adjust);
+      zv_before = ZV;
+      del_range_byte (PT_BYTE, PT_BYTE + XSTRING (val)->size, 1);
       /* Don't inherit properties here; just copy from old contents.  */
       insert_from_string (Vlast_abbrev_text, 0,
                          XSTRING (Vlast_abbrev_text)->size, 0);
-      adjust -= XSTRING (Vlast_abbrev_text)->size;
       Vlast_abbrev_text = Qnil;
+      /* Total number of characters deleted.  */
+      adjust = ZV - zv_before;
     }
   SET_PT (last_abbrev_point < opoint ? opoint - adjust : opoint);
   return Qnil;
 }
 \f
-static
+static void
 write_abbrev (sym, stream)
      Lisp_Object sym, stream;
 {
@@ -405,7 +418,7 @@ write_abbrev (sym, stream)
   insert (")\n", 2);
 }
 
-static
+static void
 describe_abbrev (sym, stream)
      Lisp_Object sym, stream;
 {