(x_get_customization_string): Don't use value of strcpy.
[bpt/emacs.git] / src / minibuf.c
index 378deeb..e941fd0 100644 (file)
@@ -1,5 +1,5 @@
 /* Minibuffer input and completion.
-   Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -106,14 +106,14 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos)
      Lisp_Object map;
      Lisp_Object initial;
      Lisp_Object prompt;
-     int backup_n;
+     Lisp_Object backup_n;
      int expflag;
      Lisp_Object histvar;
      Lisp_Object histpos;
 {
   register Lisp_Object val;
   int count = specpdl_ptr - specpdl;
-  Lisp_Object mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
+  Lisp_Object mini_frame;
   struct gcpro gcpro1, gcpro2;
 
   if (XTYPE (prompt) != Lisp_String)
@@ -153,16 +153,47 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos)
 
   /* If the minibuffer window is on a different frame, save that
      frame's configuration too.  */
+#ifdef MULTI_FRAME
+  XSET (mini_frame, Lisp_Frame, WINDOW_FRAME (XWINDOW (minibuf_window)));
   if (XFRAME (mini_frame) != selected_frame)
-    {
-      record_unwind_protect (Fset_window_configuration,
-                            Fcurrent_window_configuration (mini_frame));
-    }
+    record_unwind_protect (Fset_window_configuration,
+                          Fcurrent_window_configuration (mini_frame));
+#endif
 
   val = current_buffer->directory;
   Fset_buffer (get_minibuffer (minibuf_level));
-  current_buffer->directory = val;
+
+  /* The current buffer's default directory is usually the right thing
+     for our minibuffer here.  However, if you're typing a command at
+     a minibuffer-only frame when minibuf_level is zero, then buf IS
+     the current_buffer, so reset_buffer leaves buf's default
+     directory unchanged.  This is a bummer when you've just started
+     up Emacs and buf's default directory is Qnil.  Here's a hack; can
+     you think of something better to do?  Find another buffer with a
+     better directory, and use that one instead.  */
+  if (XTYPE (val) == Lisp_String)
+    current_buffer->directory = val;
+  else
+    {
+      Lisp_Object buf_list;
+
+      for (buf_list = Vbuffer_alist;
+          CONSP (buf_list);
+          buf_list = XCONS (buf_list)->cdr)
+       {
+         Lisp_Object other_buf = XCONS (XCONS (buf_list)->car)->cdr;
+
+         if (XTYPE (XBUFFER (other_buf)->directory) == Lisp_String)
+           {
+             current_buffer->directory = XBUFFER (other_buf)->directory;
+             break;
+           }
+       }
+    }
+
+#ifdef MULTI_FRAME
   Fredirect_frame_focus (Fselected_frame (), mini_frame);
+#endif
   Fmake_local_variable (Qprint_escape_newlines);
   print_escape_newlines = 1;
 
@@ -263,6 +294,7 @@ get_minibuffer (depth)
     }
   else
     reset_buffer (XBUFFER (buf));
+
   return buf;
 }
 
@@ -383,7 +415,7 @@ is a string to insert in the minibuffer before reading.")
 {
   CHECK_STRING (prompt, 0);
   if (!NILP (initial_contents))
-    CHECK_STRING (initial_contents, 1)
+    CHECK_STRING (initial_contents, 1);
   return read_minibuf (Vminibuffer_local_map, initial_contents,
                       prompt, Qnil, 1, Qminibuffer_history, make_number (0));
 }
@@ -899,7 +931,7 @@ temp_echo_area_glyphs (m)
   if (!NILP (Vquit_flag))
     {
       Vquit_flag = Qnil;
-      XFASTINT (unread_command_char) = Ctl ('g');
+      unread_command_events = Fcons (make_number (Ctl ('g')), Qnil);
     }
   Vinhibit_quit = oinhibit;
 }
@@ -1217,7 +1249,8 @@ or may be a list of two strings to be printed as if concatenated.")
     set_buffer_internal (XBUFFER (Vstandard_output));
 
   if (NILP (completions))
-    write_string ("There are no possible completions of what you have typed.", -1);
+    write_string ("There are no possible completions of what you have typed.",
+                 -1);
   else
     {
       write_string ("Possible completions are:", -1);
@@ -1265,7 +1298,7 @@ or may be a list of two strings to be printed as if concatenated.")
              if (XTYPE (Vstandard_output) != Lisp_Buffer)
                {
                  Lisp_Object tem;
-                 tem = Flength (elt, Qt);
+                 tem = Flength (elt);
                  column += XINT (tem);
                }
              Fprinc (elt, Qnil);
@@ -1273,6 +1306,9 @@ or may be a list of two strings to be printed as if concatenated.")
        }
     }
 
+  if (!NILP (Vrun_hooks))
+    call1 (Vrun_hooks, intern ("completion-setup-hook"));
+
   if (XTYPE (Vstandard_output) == Lisp_Buffer)
     set_buffer_internal (old);
   return Qnil;