update.
[chise/xemacs-chise.git.1] / src / minibuf.c
index 6e6c5bc..37fe9ec 100644 (file)
@@ -205,7 +205,7 @@ Lowest-level interface to minibuffers.  Don't call this.
    if IGNORE_CASE is true. */
 
 Charcount
-scmp_1 (CONST Bufbyte *s1, CONST Bufbyte *s2, Charcount len,
+scmp_1 (const Bufbyte *s1, const Bufbyte *s2, Charcount len,
        int ignore_case)
 {
   Charcount l = len;
@@ -244,7 +244,7 @@ scmp_1 (CONST Bufbyte *s1, CONST Bufbyte *s2, Charcount len,
 
 
 int
-regexp_ignore_completion_p (CONST Bufbyte *nonreloc,
+regexp_ignore_completion_p (const Bufbyte *nonreloc,
                            Lisp_Object reloc, Bytecount offset,
                            Bytecount length)
 {
@@ -289,38 +289,41 @@ ignore_completion_p (Lisp_Object completion_string,
 }
 
 
-/* #### Maybe we should allow ALIST to be a hashtable.  It is wrong
-   for the use of obarrays to be better-rewarded than the use of
-   hashtables.  By better-rewarded I mean that you can pass an obarray
-   to all of the completion functions, whereas you can't do anything
-   like that with a hashtable.
+/* #### Maybe we should allow COLLECTION to be a hash table.
+   It is wrong for the use of obarrays to be better-rewarded than the
+   use of hash tables.  By better-rewarded I mean that you can pass an
+   obarray to all of the completion functions, whereas you can't do
+   anything like that with a hash table.
 
    To do so, there should probably be a
-   map_obarray_or_alist_or_hashtable function which would be used by
+   map_obarray_or_alist_or_hash_table function which would be used by
    both Ftry_completion and Fall_completions.  But would the
    additional funcalls slow things down?  */
 
 DEFUN ("try-completion", Ftry_completion, 2, 3, 0, /*
-Return common substring of all completions of STRING in ALIST.
-Each car of each element of ALIST is tested to see if it begins with STRING.
+Return common substring of all completions of STRING in COLLECTION.
+COLLECTION must be an alist, an obarray, or a function.
+Each string in COLLECTION is tested to see if it begins with STRING.
 All that match are compared together; the longest initial sequence
-common to all matches is returned as a string.
-If there is no match at all, nil is returned.
-For an exact match, t is returned.
+common to all matches is returned as a string.  If there is no match
+at all, nil is returned.  For an exact match, t is returned.
 
-ALIST can be an obarray instead of an alist.
-Then the print names of all symbols in the obarray are the possible matches.
+If COLLECTION is an alist, the cars of the elements of the alist
+\(which must be strings) form the set of possible completions.
 
-ALIST can also be a function to do the completion itself.
-It receives three arguments: the values STRING, PREDICATE and nil.
-Whatever it returns becomes the value of `try-completion'.
+If COLLECTION is an obarray, the names of all symbols in the obarray
+are the possible completions.
 
-If optional third argument PREDICATE is non-nil,
-it is used to test each possible match.
-The match is a candidate only if PREDICATE returns non-nil.
-The argument given to PREDICATE is the alist element or the symbol from the obarray.
+If COLLECTION is a function, it is called with three arguments: the
+values STRING, PREDICATE and nil.  Whatever it returns becomes the
+value of `try-completion'.
+
+If optional third argument PREDICATE is non-nil, it is used to test
+each possible match.  The match is a candidate only if PREDICATE
+returns non-nil.  The argument given to PREDICATE is the alist element
+or the symbol from the obarray.
 */
-       (string, alist, pred))
+       (string, collection, predicate))
 {
   /* This function can GC */
   Lisp_Object bestmatch, tail;
@@ -334,31 +337,31 @@ The argument given to PREDICATE is the alist element or the symbol from the obar
 
   CHECK_STRING (string);
 
-  if (CONSP (alist))
+  if (CONSP (collection))
     {
-      Lisp_Object tem = XCAR (alist);
+      Lisp_Object tem = XCAR (collection);
       if (SYMBOLP (tem))       /* lambda, autoload, etc.  Emacs-lisp sucks */
-       return call3 (alist, string, pred, Qnil);
+       return call3 (collection, string, predicate, Qnil);
       else
        list = 1;
     }
-  else if (VECTORP (alist))
+  else if (VECTORP (collection))
     list = 0;
-  else if (NILP (alist))
+  else if (NILP (collection))
     list = 1;
   else
-    return call3 (alist, string, pred, Qnil);
+    return call3 (collection, string, predicate, Qnil);
 
   bestmatch = Qnil;
   blength = 0;
   slength = XSTRING_CHAR_LENGTH (string);
 
-  /* If ALIST is not a list, set TAIL just for gc pro.  */
-  tail = alist;
+  /* If COLLECTION is not a list, set TAIL just for gc pro.  */
+  tail = collection;
   if (!list)
     {
-      obsize = XVECTOR_LENGTH (alist);
-      bucket = XVECTOR_DATA (alist)[indice];
+      obsize = XVECTOR_LENGTH (collection);
+      bucket = XVECTOR_DATA (collection)[indice];
     }
   else /* warning suppression */
     {
@@ -387,7 +390,7 @@ The argument given to PREDICATE is the alist element or the symbol from the obar
        {
          if (!ZEROP (bucket))
            {
-              struct Lisp_Symbol *next;
+              Lisp_Symbol *next;
              if (!SYMBOLP (bucket))
                {
                  signal_simple_error ("Bad obarray passed to try-completions",
@@ -405,7 +408,7 @@ The argument given to PREDICATE is the alist element or the symbol from the obar
            break;
          else
            {
-             bucket = XVECTOR_DATA (alist)[indice];
+             bucket = XVECTOR_DATA (collection)[indice];
              continue;
            }
        }
@@ -424,7 +427,7 @@ The argument given to PREDICATE is the alist element or the symbol from the obar
                 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
                 int loser;
                 GCPRO4 (tail, string, eltstring, bestmatch);
-                loser = ignore_completion_p (eltstring, pred, elt);
+                loser = ignore_completion_p (eltstring, predicate, elt);
                 UNGCPRO;
                 if (loser)      /* reject this one */
                   continue;
@@ -509,23 +512,27 @@ The argument given to PREDICATE is the alist element or the symbol from the obar
 
 \f
 DEFUN ("all-completions", Fall_completions, 2, 3, 0, /*
-Search for partial matches to STRING in ALIST.
-Each car of each element of ALIST is tested to see if it begins with STRING.
-The value is a list of all the strings from ALIST that match.
-ALIST can be an obarray instead of an alist.
-Then the print names of all symbols in the obarray are the possible matches.
-
-ALIST can also be a function to do the completion itself.
-It receives three arguments: the values STRING, PREDICATE and t.
-Whatever it returns becomes the value of `all-completions'.
-
-If optional third argument PREDICATE is non-nil,
-it is used to test each possible match.
-The match is a candidate only if PREDICATE returns non-nil.
-The argument given to PREDICATE is the alist element or
-the symbol from the obarray.
+Search for partial matches to STRING in COLLECTION.
+COLLECTION must be an alist, an obarray, or a function.
+Each string in COLLECTION is tested to see if it begins with STRING.
+The value is a list of all the strings from COLLECTION that match.
+
+If COLLECTION is an alist, the cars of the elements of the alist
+\(which must be strings) form the set of possible completions.
+
+If COLLECTION is an obarray, the names of all symbols in the obarray
+are the possible completions.
+
+If COLLECTION is a function, it is called with three arguments: the
+values STRING, PREDICATE and t.  Whatever it returns becomes the
+value of `all-completions'.
+
+If optional third argument PREDICATE is non-nil, it is used to test
+each possible match.  The match is a candidate only if PREDICATE
+returns non-nil.  The argument given to PREDICATE is the alist element
+or the symbol from the obarray.
 */
-       (string, alist, pred))
+       (string, collection, predicate))
 {
   /* This function can GC */
   Lisp_Object tail;
@@ -538,30 +545,30 @@ the symbol from the obarray.
 
   CHECK_STRING (string);
 
-  if (CONSP (alist))
+  if (CONSP (collection))
     {
-      Lisp_Object tem = XCAR (alist);
+      Lisp_Object tem = XCAR (collection);
       if (SYMBOLP (tem))       /* lambda, autoload, etc.  Emacs-lisp sucks */
-       return call3 (alist, string, pred, Qt);
+       return call3 (collection, string, predicate, Qt);
       else
        list = 1;
     }
-  else if (VECTORP (alist))
+  else if (VECTORP (collection))
     list = 0;
-  else if (NILP (alist))
+  else if (NILP (collection))
     list = 1;
   else
-    return call3 (alist, string, pred, Qt);
+    return call3 (collection, string, predicate, Qt);
 
   allmatches = Qnil;
   slength = XSTRING_CHAR_LENGTH (string);
 
-  /* If ALIST is not a list, set TAIL just for gc pro.  */
-  tail = alist;
+  /* If COLLECTION is not a list, set TAIL just for gc pro.  */
+  tail = collection;
   if (!list)
     {
-      obsize = XVECTOR_LENGTH (alist);
-      bucket = XVECTOR_DATA (alist)[indice];
+      obsize = XVECTOR_LENGTH (collection);
+      bucket = XVECTOR_DATA (collection)[indice];
     }
   else /* warning suppression */
     {
@@ -590,7 +597,7 @@ the symbol from the obarray.
        {
          if (!ZEROP (bucket))
            {
-              struct Lisp_Symbol *next = symbol_next (XSYMBOL (bucket));
+              Lisp_Symbol *next = symbol_next (XSYMBOL (bucket));
              elt = bucket;
              eltstring = Fsymbol_name (elt);
               if (next)
@@ -602,7 +609,7 @@ the symbol from the obarray.
            break;
          else
            {
-             bucket = XVECTOR_DATA (alist)[indice];
+             bucket = XVECTOR_DATA (collection)[indice];
              continue;
            }
        }
@@ -611,12 +618,12 @@ the symbol from the obarray.
 
       if (STRINGP (eltstring)
           && (slength <= XSTRING_CHAR_LENGTH (eltstring))
-         /* Reject alternatives that start with space
+          /* Reject alternatives that start with space
             unless the input starts with space.  */
          && ((XSTRING_CHAR_LENGTH (string) > 0 &&
               string_char (XSTRING (string), 0) == ' ')
              || string_char (XSTRING (eltstring), 0) != ' ')
-          && (0 > scmp (XSTRING_DATA (eltstring),
+         && (0 > scmp (XSTRING_DATA (eltstring),
                         XSTRING_DATA (string),
                         slength)))
        {
@@ -624,7 +631,7 @@ the symbol from the obarray.
           struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
           int loser;
           GCPRO4 (tail, eltstring, allmatches, string);
-          loser = ignore_completion_p (eltstring, pred, elt);
+          loser = ignore_completion_p (eltstring, predicate, elt);
           UNGCPRO;
           if (!loser)
             /* Ok => put it on the list. */
@@ -681,8 +688,8 @@ clear_echo_area_internal (struct frame *f, Lisp_Object label, int from_print,
     }
   else
     {
-      write_string_to_stdio_stream (stderr, 0, (CONST Bufbyte *) "\n", 0, 1,
-                                   FORMAT_TERMINAL);
+      write_string_to_stdio_stream (stderr, 0, (const Bufbyte *) "\n", 0, 1,
+                                   Qterminal, 0);
       return Qnil;
     }
 }
@@ -702,7 +709,7 @@ clear_echo_area_from_print (struct frame *f, Lisp_Object label, int no_restore)
 }
 
 void
-echo_area_append (struct frame *f, CONST Bufbyte *nonreloc, Lisp_Object reloc,
+echo_area_append (struct frame *f, const Bufbyte *nonreloc, Lisp_Object reloc,
                  Bytecount offset, Bytecount length,
                  Lisp_Object label)
 {
@@ -711,6 +718,12 @@ echo_area_append (struct frame *f, CONST Bufbyte *nonreloc, Lisp_Object reloc,
   struct gcpro gcpro1;
   Lisp_Object frame;
 
+  /* There is an inlining bug in egcs-20000131 c++ that can be worked
+     around as follows:  */
+#if defined (__GNUC__) && defined (__cplusplus)
+  alloca (4);
+#endif
+
   /* some callers pass in a null string as a way of clearing the echo area.
      check for length == 0 now; if this case, neither nonreloc nor reloc
      may be valid.  */
@@ -745,12 +758,12 @@ echo_area_append (struct frame *f, CONST Bufbyte *nonreloc, Lisp_Object reloc,
       if (STRINGP (reloc))
        nonreloc = XSTRING_DATA (reloc);
       write_string_to_stdio_stream (stderr, 0, nonreloc, offset, length,
-                                   FORMAT_TERMINAL);
+                                   Qterminal, 0);
     }
 }
 
 void
-echo_area_message (struct frame *f, CONST Bufbyte *nonreloc,
+echo_area_message (struct frame *f, const Bufbyte *nonreloc,
                   Lisp_Object reloc, Bytecount offset, Bytecount length,
                   Lisp_Object label)
 {
@@ -795,7 +808,7 @@ echo_area_contents (struct frame *f)
 /* Dump an informative message to the echo area.  This function takes a
    string in internal format. */
 void
-message_internal (CONST Bufbyte *nonreloc, Lisp_Object reloc,
+message_internal (const Bufbyte *nonreloc, Lisp_Object reloc,
                  Bytecount offset, Bytecount length)
 {
   /* This function can call lisp  */
@@ -805,7 +818,7 @@ message_internal (CONST Bufbyte *nonreloc, Lisp_Object reloc,
 }
 
 void
-message_append_internal (CONST Bufbyte *nonreloc, Lisp_Object reloc,
+message_append_internal (const Bufbyte *nonreloc, Lisp_Object reloc,
                         Bytecount offset, Bytecount length)
 {
   /* This function can call lisp  */
@@ -819,7 +832,7 @@ message_append_internal (CONST Bufbyte *nonreloc, Lisp_Object reloc,
    on the format string; message_no_translate() does not. */
 
 static void
-message_1 (CONST char *fmt, va_list args)
+message_1 (const char *fmt, va_list args)
 {
   /* This function can call lisp */
   if (fmt)
@@ -827,7 +840,7 @@ message_1 (CONST char *fmt, va_list args)
       struct gcpro gcpro1;
       /* message_internal() might GC, e.g. if there are after-change-hooks
         on the echo area buffer */
-      Lisp_Object obj = emacs_doprnt_string_va ((CONST Bufbyte *) fmt, Qnil,
+      Lisp_Object obj = emacs_doprnt_string_va ((const Bufbyte *) fmt, Qnil,
                                                -1, args);
       GCPRO1 (obj);
       message_internal (0, obj, 0, -1);
@@ -838,7 +851,7 @@ message_1 (CONST char *fmt, va_list args)
 }
 
 static void
-message_append_1 (CONST char *fmt, va_list args)
+message_append_1 (const char *fmt, va_list args)
 {
   /* This function can call lisp */
   if (fmt)
@@ -846,7 +859,7 @@ message_append_1 (CONST char *fmt, va_list args)
       struct gcpro gcpro1;
       /* message_internal() might GC, e.g. if there are after-change-hooks
         on the echo area buffer */
-      Lisp_Object obj = emacs_doprnt_string_va ((CONST Bufbyte *) fmt, Qnil,
+      Lisp_Object obj = emacs_doprnt_string_va ((const Bufbyte *) fmt, Qnil,
                                                -1, args);
       GCPRO1 (obj);
       message_append_internal (0, obj, 0, -1);
@@ -864,7 +877,7 @@ clear_message (void)
 }
 
 void
-message (CONST char *fmt, ...)
+message (const char *fmt, ...)
 {
   /* This function can call lisp */
   /* I think it's OK to pass the data of Lisp strings as arguments to
@@ -880,7 +893,7 @@ message (CONST char *fmt, ...)
 }
 
 void
-message_append (CONST char *fmt, ...)
+message_append (const char *fmt, ...)
 {
   /* This function can call lisp */
   va_list args;
@@ -893,7 +906,7 @@ message_append (CONST char *fmt, ...)
 }
 
 void
-message_no_translate (CONST char *fmt, ...)
+message_no_translate (const char *fmt, ...)
 {
   /* This function can call lisp */
   /* I think it's OK to pass the data of Lisp strings as arguments to
@@ -936,9 +949,15 @@ syms_of_minibuf (void)
 }
 
 void
-vars_of_minibuf (void)
+reinit_vars_of_minibuf (void)
 {
   minibuf_level = 0;
+}
+
+void
+vars_of_minibuf (void)
+{
+  reinit_vars_of_minibuf ();
 
   staticpro (&Vminibuf_prompt);
   Vminibuf_prompt = Qnil;
@@ -965,7 +984,7 @@ Each completion has to match all regexps in this list.
 }
 
 void
-complex_vars_of_minibuf (void)
+reinit_complex_vars_of_minibuf (void)
 {
   /* This function can GC */
 #ifdef I18N3
@@ -974,8 +993,14 @@ complex_vars_of_minibuf (void)
 #endif
   Vminibuffer_zero
     = Fget_buffer_create
-      (Fpurecopy (build_string (DEFER_GETTEXT (" *Minibuf-0*"))));
+      (build_string (DEFER_GETTEXT (" *Minibuf-0*")));
   Vecho_area_buffer
     = Fget_buffer_create
-      (Fpurecopy (build_string (DEFER_GETTEXT (" *Echo Area*"))));
+      (build_string (DEFER_GETTEXT (" *Echo Area*")));
+}
+
+void
+complex_vars_of_minibuf (void)
+{
+  reinit_complex_vars_of_minibuf ();
 }