]> code.delx.au - gnu-emacs/blobdiff - src/minibuf.c
(Fdocumentation, Fdocumentation_property, Fsubstitute_command_keys):
[gnu-emacs] / src / minibuf.c
index f9d3cf603f2be82b18d40113efba2899b854024d..c2a11a1d62a35cec7d955d5142d6f82b84465088 100644 (file)
@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "frame.h"
 #include "window.h"
 #include "syntax.h"
+#include "keyboard.h"
 
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
@@ -98,6 +99,33 @@ Lisp_Object Quser_variable_p;
 /* Non-nil means it is the window for C-M-v to scroll
    when the minibuffer is selected.  */
 extern Lisp_Object Vminibuf_scroll_window;
+
+extern Lisp_Object Voverriding_local_map;
+\f
+/* Put minibuf on currently selected frame's minibuffer.
+   We do this whenever the user starts a new minibuffer
+   or when a minibuffer exits.  */
+
+void
+choose_minibuf_frame ()
+{
+  if (selected_frame != 0
+      && !EQ (minibuf_window, selected_frame->minibuffer_window))
+    {
+#if defined(MSDOS) && !defined(HAVE_X_WINDOWS)
+      selected_frame->minibuffer_window = minibuf_window;
+#else
+      /* I don't think that any frames may validly have a null minibuffer
+        window anymore.  */
+      if (NILP (selected_frame->minibuffer_window))
+       abort ();
+
+      Fset_window_buffer (selected_frame->minibuffer_window,
+                         XWINDOW (minibuf_window)->buffer);
+      minibuf_window = selected_frame->minibuffer_window;
+#endif
+    }
+}
 \f
 /* Actual minibuffer invocation. */
 
@@ -131,9 +159,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos)
   Lisp_Object mini_frame;
   struct gcpro gcpro1, gcpro2, gcpro3;
 
-#ifdef MULTI_PERDISPLAY
-  display_locked = 1;
-#endif
+  single_kboard_state ();
 
   val = Qnil;
   /* Don't need to protect PROMPT, HISTVAR, and HISTPOS because we
@@ -147,25 +173,28 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos)
   if (!enable_recursive_minibuffers
       && minibuf_level > 0
       && (EQ (selected_window, minibuf_window)))
-#if 0
-         || selected_frame != XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)))
-#endif
     error ("Command attempted to use minibuffer while in minibuffer");
 
   /* Could we simply bind these variables instead?  */
+  minibuf_save_list
+    = Fcons (Voverriding_local_map,
+            Fcons (minibuf_window, minibuf_save_list));
   minibuf_save_list
     = Fcons (minibuf_prompt,
             Fcons (make_number (minibuf_prompt_width),
                    Fcons (Vhelp_form,
-                          Fcons (current_perdisplay->Vcurrent_prefix_arg,
+                          Fcons (Vcurrent_prefix_arg,
                                  Fcons (Vminibuffer_history_position,
                                         Fcons (Vminibuffer_history_variable,
                                                minibuf_save_list))))));
+
   minibuf_prompt_width = 0;    /* xdisp.c puts in the right value.  */
   minibuf_prompt = Fcopy_sequence (prompt);
   Vminibuffer_history_position = histpos;
   Vminibuffer_history_variable = histvar;
 
+  choose_minibuf_frame ();
+
   record_unwind_protect (Fset_window_configuration,
                         Fcurrent_window_configuration (Qnil));
 
@@ -269,8 +298,10 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos)
     }
 
   /* Make minibuffer contents into a string */
-  val = make_buffer_string (1, Z);
+  val = make_buffer_string (1, Z, 1);
+#if 0  /* make_buffer_string should handle the gap.  */
   bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT);
+#endif
 
   /* VAL is the string of minibuffer text.  */
   last_minibuf_string = val;
@@ -371,7 +402,7 @@ read_minibuf_unwind (data)
      so run the hook.  */
   if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound)
       && !NILP (Vrun_hooks))
-    call1 (Vrun_hooks, Qminibuffer_exit_hook);
+    safe_run_hooks (Qminibuffer_exit_hook);
 
   /* Erase the minibuffer we were using at this level.  */
   Fset_buffer (XWINDOW (minibuf_window)->buffer);
@@ -397,12 +428,16 @@ read_minibuf_unwind (data)
   minibuf_save_list = Fcdr (minibuf_save_list);
   Vhelp_form = Fcar (minibuf_save_list);
   minibuf_save_list = Fcdr (minibuf_save_list);
-  current_perdisplay->Vcurrent_prefix_arg = Fcar (minibuf_save_list);
+  Vcurrent_prefix_arg = Fcar (minibuf_save_list);
   minibuf_save_list = Fcdr (minibuf_save_list);
   Vminibuffer_history_position = Fcar (minibuf_save_list);
   minibuf_save_list = Fcdr (minibuf_save_list);
   Vminibuffer_history_variable = Fcar (minibuf_save_list);
   minibuf_save_list = Fcdr (minibuf_save_list);
+  Voverriding_local_map = Fcar (minibuf_save_list);
+  minibuf_save_list = Fcdr (minibuf_save_list);
+  minibuf_window = Fcar (minibuf_save_list);
+  minibuf_save_list = Fcdr (minibuf_save_list);
 }
 \f
 
@@ -1042,6 +1077,7 @@ temp_echo_area_glyphs (m)
      char *m;
 {
   int osize = ZV;
+  int opoint = PT;
   Lisp_Object oinhibit;
   oinhibit = Vinhibit_quit;
 
@@ -1050,10 +1086,11 @@ temp_echo_area_glyphs (m)
 
   SET_PT (osize);
   insert_string (m);
-  SET_PT (osize);
+  SET_PT (opoint);
   Vinhibit_quit = Qt;
   Fsit_for (make_number (2), Qnil, Qnil);
-  del_range (PT, ZV);
+  del_range (osize, ZV);
+  SET_PT (opoint);
   if (!NILP (Vquit_flag))
     {
       Vquit_flag = Qnil;
@@ -1215,7 +1252,7 @@ scroll the window of possible completions.")
 
   /* If the previous command was not this, then mark the completion
      buffer obsolete.  */
-  if (! EQ (last_command, this_command))
+  if (! EQ (current_kboard->Vlast_command, this_command))
     Vminibuf_scroll_window = Qnil;
 
   window = Vminibuf_scroll_window;
@@ -1471,16 +1508,19 @@ It can find the completion buffer in `standard-output'.")
   (completions)
      Lisp_Object completions;
 {
-  register Lisp_Object tail, elt;
+  Lisp_Object tail, elt;
   register int i;
   int column = 0;
-  struct gcpro gcpro1;
+  struct gcpro gcpro1, gcpro2;
   struct buffer *old = current_buffer;
   int first = 1;
 
   /* Note that (when it matters) every variable
-     points to a non-string that is pointed to by COMPLETIONS.  */
-  GCPRO1 (completions);
+     points to a non-string that is pointed to by COMPLETIONS,
+     except for ELT.  ELT can be pointing to a string
+     when terpri or Findent_to calls a change hook.  */
+  elt = Qnil;
+  GCPRO2 (completions, elt);
 
   if (BUFFERP (Vstandard_output))
     set_buffer_internal (XBUFFER (Vstandard_output));
@@ -1495,6 +1535,7 @@ It can find the completion buffer in `standard-output'.")
        {
          Lisp_Object tem;
          int length;
+         Lisp_Object startpos, endpos;
 
          elt = Fcar (tail);
          /* Compute the length of this element.  */
@@ -1518,6 +1559,9 @@ It can find the completion buffer in `standard-output'.")
             Sadly, the window it will appear in is not known
             until after the text has been made.  */
 
+         if (BUFFERP (Vstandard_output))
+           XSETINT (startpos, BUF_PT (XBUFFER (Vstandard_output)));
+
          /* If the previous completion was very wide,
             or we have two on this line already,
             don't put another on the same line.  */
@@ -1534,6 +1578,7 @@ It can find the completion buffer in `standard-output'.")
              if (BUFFERP (Vstandard_output))
                {
                  tem = Findent_to (make_number (35), make_number (2));
+                 
                  column = XINT (tem);
                }
              else
@@ -1547,6 +1592,13 @@ It can find the completion buffer in `standard-output'.")
                }
            }
 
+         if (BUFFERP (Vstandard_output))
+           {
+             XSETINT (endpos, BUF_PT (XBUFFER (Vstandard_output)));
+             Fset_text_properties (startpos, endpos,
+                                   Qnil, Vstandard_output);
+           }
+
          /* Output this element and update COLUMN.  */
          if (CONSP (elt))
            {
@@ -1747,7 +1799,8 @@ t means to return a list of all possible completions of STRING.\n\
 
   DEFVAR_LISP ("minibuffer-history-variable", &Vminibuffer_history_variable,
     "History list symbol to add minibuffer values to.\n\
-Each minibuffer output is added with\n\
+Each string of minibuffer input, as it appears on exit from the minibuffer,\n\
+is added with\n\
   (set minibuffer-history-variable\n\
        (cons STRING (symbol-value minibuffer-history-variable)))");
   XSETFASTINT (Vminibuffer_history_variable, 0);