update.
[chise/xemacs-chise.git.1] / src / abbrev.c
index e18efdd..5687ee1 100644 (file)
@@ -1,5 +1,6 @@
 /* Primitives for word-abbrev mode.
    Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
+   Copyright (C) 2001 MORIOKA Tomohiko
 
 This file is part of XEmacs.
 
@@ -69,7 +70,7 @@ Lisp_Object Vlast_abbrev;
 Lisp_Object Vlast_abbrev_text;
 
 /* Character address of start of last abbrev expanded */
-int last_abbrev_location;
+Fixnum last_abbrev_location;
 
 /* Hook to run before expanding any abbrev.  */
 Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
@@ -77,9 +78,9 @@ Lisp_Object Vpre_abbrev_expand_hook, Qpre_abbrev_expand_hook;
 \f
 struct abbrev_match_mapper_closure {
   struct buffer *buf;
-  struct Lisp_Char_Table *chartab;
+  Lisp_Char_Table *chartab;
   Charcount point, maxlen;
-  struct Lisp_Symbol *found;
+  Lisp_Symbol *found;
 };
 
 /* For use by abbrev_match(): Match SYMBOL's name against buffer text
@@ -91,8 +92,8 @@ abbrev_match_mapper (Lisp_Object symbol, void *arg)
   struct abbrev_match_mapper_closure *closure =
     (struct abbrev_match_mapper_closure *)arg;
   Charcount abbrev_length;
-  struct Lisp_Symbol *sym = XSYMBOL (symbol);
-  struct Lisp_String *abbrev;
+  Lisp_Symbol *sym = XSYMBOL (symbol);
+  Lisp_String *abbrev;
 
   /* symbol_value should be OK here, because abbrevs are not expected
      to contain any SYMBOL_MAGIC stuff.  */
@@ -147,7 +148,7 @@ abbrev_match_mapper (Lisp_Object symbol, void *arg)
 
 /* Match the buffer text against names of symbols in obarray.  Returns
    the matching symbol, or 0 if not found.  */
-static struct Lisp_Symbol *
+static Lisp_Symbol *
 abbrev_match (struct buffer *buf, Lisp_Object obarray)
 {
   struct abbrev_match_mapper_closure closure;
@@ -157,7 +158,11 @@ abbrev_match (struct buffer *buf, Lisp_Object obarray)
   closure.buf = buf;
   closure.point = BUF_PT (buf);
   closure.maxlen = closure.point - BUF_BEGV (buf);
+#ifdef UTF2000
+  closure.chartab = XCHAR_TABLE (buf->syntax_table);
+#else
   closure.chartab = XCHAR_TABLE (buf->mirror_syntax_table);
+#endif
   closure.found = 0;
 
   map_obarray (obarray, abbrev_match_mapper, &closure);
@@ -172,10 +177,10 @@ abbrev_match (struct buffer *buf, Lisp_Object obarray)
    It is an order of magnitude faster than the proper abbrev_match(),
    but then again, vi is an order of magnitude faster than Emacs.
 
-   This speed difference should be unnoticable, though.  I have tested
+   This speed difference should be unnoticeable, though.  I have tested
    the degenerated cases of thousands of abbrevs being defined, and
    abbrev_match() was still fast enough for normal operation.  */
-static struct Lisp_Symbol *
+static Lisp_Symbol *
 abbrev_oblookup (struct buffer *buf, Lisp_Object obarray)
 {
   Bufpos wordstart, wordend;
@@ -222,10 +227,11 @@ abbrev_oblookup (struct buffer *buf, Lisp_Object obarray)
         because of consistency with abbrev_match. */
       if (wordend < point)
        return 0;
-      if (wordend <= wordstart)
-       return 0;
     }
 
+  if (wordend <= wordstart)
+    return 0;
+
   p = word = (Bufbyte *) alloca (MAX_EMCHAR_LEN * (wordend - wordstart));
   for (idx = wordstart; idx < wordend; idx++)
     {
@@ -281,10 +287,10 @@ If no abbrev matched, but `pre-abbrev-expand-hook' changed the buffer,
   Bufpos point;                        /* position of point */
   Bufpos abbrev_start;         /* position of abbreviation beginning */
 
-  struct Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object);
+  Lisp_Symbol *(*fun) (struct buffer *, Lisp_Object);
 
-  struct Lisp_Symbol *abbrev_symbol;
-  struct Lisp_String *abbrev_string;
+  Lisp_Symbol *abbrev_symbol;
+  Lisp_String *abbrev_string;
   Lisp_Object expansion, count, hook;
   Charcount abbrev_length;
   int lccount, uccount;
@@ -384,8 +390,14 @@ If no abbrev matched, but `pre-abbrev-expand-hook' changed the buffer,
       Bufpos pos = abbrev_start;
       /* Find the initial.  */
       while (pos < point
+#ifdef UTF2000
+            && !WORD_SYNTAX_P (XCHAR_TABLE (buf->syntax_table),
+                               BUF_FETCH_CHAR (buf, pos))
+#else
             && !WORD_SYNTAX_P (XCHAR_TABLE (buf->mirror_syntax_table),
-                               BUF_FETCH_CHAR (buf, pos)))
+                               BUF_FETCH_CHAR (buf, pos))
+#endif
+            )
        pos++;
       /* Change just that.  */
       Fupcase_initials_region (make_int (pos), make_int (pos + 1),