]> code.delx.au - gnu-emacs/blobdiff - src/abbrev.c
*** empty log message ***
[gnu-emacs] / src / abbrev.c
index 7ba0f575a2dfb3790217369fdbcd72d6f81ff052..e3e0e28210b8e803aea4a901b2b1c81988efd713 100644 (file)
@@ -77,7 +77,7 @@ Lisp_Object Vlast_abbrev_text;
 
 /* Character address of start of last abbrev expanded */
 
-int last_abbrev_point;
+EMACS_INT last_abbrev_point;
 
 /* Hook to run before expanding any abbrev.  */
 
@@ -89,6 +89,7 @@ DEFUN ("make-abbrev-table", Fmake_abbrev_table, Smake_abbrev_table, 0, 0, 0,
        doc: /* Create a new, empty abbrev table object.  */)
      ()
 {
+  /* The value 59 is arbitrary chosen prime number.  */
   return Fmake_vector (make_number (59), make_number (0));
 }
 
@@ -289,25 +290,28 @@ Returns the abbrev symbol, if expansion took place.  */)
 
   p = buffer = (char *) alloca (wordend_byte - wordstart_byte);
 
-  for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend;)
+  for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend; )
     {
       register int c;
 
-      FETCH_CHAR_ADVANCE (c, idx, idx_byte);
-      if (! multibyte)
-       MAKE_CHAR_MULTIBYTE (c);
+      if (multibyte)
+       {
+         FETCH_CHAR_ADVANCE (c, idx, idx_byte);
+       }
+      else
+       {
+         c = FETCH_BYTE (idx_byte);
+         idx++, idx_byte++;
+       }
 
       if (UPPERCASEP (c))
        c = DOWNCASE (c), uccount++;
       else if (! NOCASEP (c))
        lccount++;
       if (multibyte)
-       CHAR_STRING_ADVANCE (c, p);
+       p += CHAR_STRING (c, p);
       else
-       {
-         MAKE_CHAR_UNIBYTE (c);
-         *p++ = c;
-       }
+       *p++ = c;
     }
 
   if (VECTORP (current_buffer->abbrev_table))
@@ -342,7 +346,7 @@ Returns the abbrev symbol, if expansion took place.  */)
   if (INTEGERP (XSYMBOL (sym)->plist))
     XSETINT (XSYMBOL (sym)->plist,
             XINT (XSYMBOL (sym)->plist) + 1);
-  else if (!NILP (tem = Fget (sym, Qcount)))
+  else if (INTEGERP (tem = Fget (sym, Qcount)))
     Fput (sym, Qcount, make_number (XINT (tem) + 1));
 
   /* If this abbrev has an expansion, delete the abbrev
@@ -354,8 +358,8 @@ Returns the abbrev symbol, if expansion took place.  */)
 
       del_range_both (wordstart, wordstart_byte, wordend, wordend_byte, 1);
 
-      insert_from_string (expansion, 0, 0, XSTRING (expansion)->size,
-                         STRING_BYTES (XSTRING (expansion)), 1);
+      insert_from_string (expansion, 0, 0, SCHARS (expansion),
+                         SBYTES (expansion), 1);
       SET_PT (PT + whitecnt);
 
       if (uccount && !lccount)
@@ -381,9 +385,15 @@ Returns the abbrev symbol, if expansion took place.  */)
          int pos = wordstart_byte;
 
          /* Find the initial.  */
-         while (pos < PT_BYTE
-                && SYNTAX (FETCH_CHAR_AS_MULTIBYTE (pos)) != Sword)
-           pos++;
+         if (multibyte)
+           while (pos < PT_BYTE
+                  && SYNTAX (FETCH_MULTIBYTE_CHAR (pos)) != Sword)
+             INC_POS (pos);
+         else
+           while (pos < PT_BYTE
+                  && (SYNTAX (*BUF_BYTE_ADDRESS (current_buffer, pos))
+                      != Sword))
+             pos++;
 
          /* Change just that.  */
          pos = BYTE_TO_CHAR (pos);
@@ -399,8 +409,8 @@ Returns the abbrev symbol, if expansion took place.  */)
       /* 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
+      /* In addition, if the hook function is a symbol with
+        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.  */
 
@@ -437,11 +447,11 @@ is not undone.  */)
       if (!STRINGP (val))
        error ("value of abbrev-symbol must be a string");
       zv_before = ZV;
-      del_range_byte (PT_BYTE, PT_BYTE + STRING_BYTES (XSTRING (val)), 1);
+      del_range_byte (PT_BYTE, PT_BYTE + SBYTES (val), 1);
       /* Don't inherit properties here; just copy from old contents.  */
       insert_from_string (Vlast_abbrev_text, 0, 0,
-                         XSTRING (Vlast_abbrev_text)->size,
-                         STRING_BYTES (XSTRING (Vlast_abbrev_text)), 0);
+                         SCHARS (Vlast_abbrev_text),
+                         SBYTES (Vlast_abbrev_text), 0);
       Vlast_abbrev_text = Qnil;
       /* Total number of characters deleted.  */
       adjust = ZV - zv_before;
@@ -471,7 +481,7 @@ write_abbrev (sym, stream)
     return;
 
   insert ("    (", 5);
-  XSETSTRING (name, XSYMBOL (sym)->name);
+  name = SYMBOL_NAME (sym);
   Fprin1 (name, stream);
   insert (" ", 1);
   Fprin1 (SYMBOL_VALUE (sym), stream);
@@ -588,9 +598,9 @@ of the form (ABBREVNAME EXPANSION HOOK USECOUNT SYSTEMFLAG).
     }
   CHECK_VECTOR (table);
 
-  for (; !NILP (definitions); definitions = Fcdr (definitions))
+  for (; CONSP (definitions); definitions = XCDR (definitions))
     {
-      elt = Fcar (definitions);
+      elt = XCAR (definitions);
       name  = Fcar (elt);      elt = Fcdr (elt);
       exp   = Fcar (elt);      elt = Fcdr (elt);
       hook  = Fcar (elt);      elt = Fcdr (elt);
@@ -645,7 +655,7 @@ nil if the abbrev has already been unexpanded.  */);
 
   DEFVAR_LISP ("abbrev-start-location", &Vabbrev_start_location,
               doc: /* Buffer position for `expand-abbrev' to use as the start of the abbrev.
-nil means use the word before point as the abbrev.
+When nil, use the word before point as the abbrev.
 Calling `expand-abbrev' sets this to nil.  */);
   Vabbrev_start_location = Qnil;