Add Keywords header.
[bpt/emacs.git] / src / minibuf.c
index 19c0610..a871270 100644 (file)
@@ -1,6 +1,6 @@
 /* Minibuffer input and completion.
-   Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-         Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+   2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA.  */
 #include "frame.h"
 #include "window.h"
 #include "syntax.h"
+#include "intervals.h"
 
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
@@ -86,6 +87,12 @@ Lisp_Object Vminibuffer_history_variable;
 
 Lisp_Object Vminibuffer_history_position;
 
+/* Text properties that are added to minibuffer prompts.
+   These are in addition to the basic `field' property, and stickiness
+   properties.  */
+
+Lisp_Object Vminibuffer_prompt_properties;
+
 Lisp_Object Qminibuffer_history, Qbuffer_name_history;
 
 Lisp_Object Qread_file_name_internal;
@@ -281,6 +288,7 @@ read_minibuf_noninteractive (map, initial, prompt, backup_n, expflag,
   fprintf (stdout, "%s", XSTRING (prompt)->data);
   fflush (stdout);
 
+  val = Qnil;
   size = 100;
   len = 0;
   line = (char *) xmalloc (size * sizeof *line);
@@ -360,8 +368,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
 
   single_kboard_state ();
 #ifdef HAVE_X_WINDOWS
-  if (display_busy_cursor_p)
-    cancel_busy_cursor ();
+  if (display_hourglass_p)
+    cancel_hourglass ();
 #endif
 
   val = Qnil;
@@ -389,9 +397,12 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
     }
 
   if (noninteractive)
-    return read_minibuf_noninteractive (map, initial, prompt, backup_n,
-                                       expflag, histvar, histpos, defalt,
-                                       allow_props, inherit_input_method);
+    {
+      val = read_minibuf_noninteractive (map, initial, prompt, backup_n,
+                                        expflag, histvar, histpos, defalt,
+                                        allow_props, inherit_input_method);
+      return unbind_to (count, val);
+    }
 
   /* Choose the minibuffer window and frame, and take action on them.  */
 
@@ -520,8 +531,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
                          Qrear_nonsticky, Qt, Qnil);
       Fput_text_property (make_number (BEG), make_number (PT),
                          Qfield, Qt, Qnil);
-      Fput_text_property (make_number (BEG), make_number (PT),
-                         Qread_only, Qt, Qnil);
+      Fadd_text_properties (make_number (BEG), make_number (PT),
+                           Vminibuffer_prompt_properties, Qnil);
     }
   
   minibuf_prompt_width = current_column ();
@@ -552,6 +563,9 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
       && !NILP (Vrun_hooks))
     call1 (Vrun_hooks, Qminibuffer_setup_hook);
 
+  /* Don't allow the user to undo past this point.  */
+  current_buffer->undo_list = Qnil;
+
   recursive_edit_1 ();
 
   /* If cursor is on the minibuffer line,
@@ -816,7 +830,7 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1,
   if (NILP (keymap))
     keymap = Vminibuffer_local_map;
   else
-    keymap = get_keymap (keymap);
+    keymap = get_keymap (keymap, 1, 0);
 
   if (SYMBOLP (hist))
     {
@@ -1046,11 +1060,11 @@ is used to further constrain the set of candidates.")
 {
   Lisp_Object bestmatch, tail, elt, eltstring;
   /* Size in bytes of BESTMATCH.  */
-  int bestmatchsize;
+  int bestmatchsize = 0;
   /* These are in bytes, too.  */
   int compare, matchsize;
   int list = CONSP (alist) || NILP (alist);
-  int index, obsize;
+  int index = 0, obsize = 0;
   int matchcount = 0;
   Lisp_Object bucket, zero, end, tem;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -1059,7 +1073,7 @@ is used to further constrain the set of candidates.")
   if (!list && !VECTORP (alist))
     return call3 (alist, string, predicate, Qnil);
 
-  bestmatch = Qnil;
+  bestmatch = bucket = Qnil;
 
   /* If ALIST is not a list, set TAIL just for gc pro.  */
   tail = alist;
@@ -1299,7 +1313,7 @@ are ignored unless STRING itself starts with a space.")
   Lisp_Object tail, elt, eltstring;
   Lisp_Object allmatches;
   int list = CONSP (alist) || NILP (alist);
-  int index, obsize;
+  int index = 0, obsize = 0;
   Lisp_Object bucket, tem;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
 
@@ -1308,7 +1322,7 @@ are ignored unless STRING itself starts with a space.")
     {
       return call3 (alist, string, predicate, Qt);
     }
-  allmatches = Qnil;
+  allmatches = bucket = Qnil;
 
   /* If ALIST is not a list, set TAIL just for gc pro.  */
   tail = alist;
@@ -1437,6 +1451,7 @@ If the input is null, `completing-read' returns an empty string,\n\
 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.\n\
   If it is (STRING . POSITION), the initial input\n\
   is STRING, but point is placed POSITION characters into the string.\n\
+  This feature is deprecated--it is best to pass nil for INITIAL.\n\
 HIST, if non-nil, specifies a history list\n\
   and optionally the initial position in the list.\n\
   It can be a symbol, which is the history list variable to use,\n\
@@ -1610,8 +1625,8 @@ do_completion ()
   tem = Fcompare_strings (completion, Qnil, Qnil, string, Qnil, Qnil, Qt);
   completedp = !EQ (tem, Qt);
 
-  tem = Fstring_equal (completion, string);
-  if (NILP (tem))
+  tem = Fcompare_strings (completion, Qnil, Qnil, string, Qnil, Qnil, Qnil);
+  if (!EQ (tem, Qt))
     /* Rewrite the user's input.  */
     {
       Fdelete_field (make_number (ZV)); /* Some completion happened */
@@ -1714,7 +1729,7 @@ scroll the window of possible completions.")
       struct buffer *obuf = current_buffer;
 
       Fset_buffer (XWINDOW (window)->buffer);
-      tem = Fpos_visible_in_window_p (make_number (ZV), window);
+      tem = Fpos_visible_in_window_p (make_number (ZV), window, Qnil);
       if (! NILP (tem))
        /* If end is in view, scroll up to the beginning.  */
        Fset_window_start (window, make_number (BEGV), Qnil);
@@ -1809,7 +1824,7 @@ a repetition of this command will exit.")
       return Qnil;
     }
  exit:
-  Fthrow (Qexit, Qnil);
+  return Fthrow (Qexit, Qnil);
   /* NOTREACHED */
 }
 
@@ -2028,6 +2043,8 @@ It can find the completion buffer in `standard-output'.")
          int length;
          Lisp_Object startpos, endpos;
 
+         startpos = Qnil;
+
          elt = Fcar (tail);
          /* Compute the length of this element.  */
          if (CONSP (elt))
@@ -2202,14 +2219,14 @@ DEFUN ("self-insert-and-exit", Fself_insert_and_exit, Sself_insert_and_exit, 0,
   else
     bitch_at_user ();
 
-  Fthrow (Qexit, Qnil);
+  return Fthrow (Qexit, Qnil);
 }
 
 DEFUN ("exit-minibuffer", Fexit_minibuffer, Sexit_minibuffer, 0, 0, "",
   "Terminate this minibuffer argument.")
   ()
 {
-  Fthrow (Qexit, Qnil);
+  return Fthrow (Qexit, Qnil);
 }
 
 DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0,
@@ -2431,6 +2448,15 @@ This also affects `read-string', but it does not affect `read-minibuffer',\n\
 with completion; they always discard text properties.");
   minibuffer_allow_text_properties = 0;
 
+  DEFVAR_LISP ("minibuffer-prompt-properties", &Vminibuffer_prompt_properties,
+    "Text properties that are added to minibuffer prompts.\n\
+These are in addition to the basic `field' property, and stickiness\n\
+properties.");
+  /* We use `intern' here instead of Qread_only to avoid
+     initialization-order problems.  */
+  Vminibuffer_prompt_properties
+    = Fcons (intern ("read-only"), Fcons (Qt, Qnil));
+
   defsubr (&Sset_minibuffer_window);
   defsubr (&Sread_from_minibuffer);
   defsubr (&Seval_minibuffer);