]> code.delx.au - gnu-emacs/blobdiff - src/minibuf.c
(message2_nolog): Fix arg types.
[gnu-emacs] / src / minibuf.c
index f96589533d2ec66dc4b2c68cf64a9eb0a11dab64..7de73d069e2b504bcbecbc0d426cbd4a1c0ac888 100644 (file)
@@ -1,5 +1,6 @@
 /* Minibuffer input and completion.
-   Copyright (C) 1985, 1986, 93, 94, 95, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997
+         Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -85,6 +86,9 @@ Lisp_Object Qread_file_name_internal;
 Lisp_Object Qminibuffer_setup_hook, Vminibuffer_setup_hook;
 Lisp_Object Qminibuffer_exit_hook, Vminibuffer_exit_hook;
 
+/* Function to call to read a buffer name.  */
+Lisp_Object Vread_buffer_function; 
+
 /* Nonzero means completion ignores case.  */
 
 int completion_ignore_case;
@@ -179,7 +183,7 @@ without invoking the usual minibuffer commands.")
 \f
 /* Actual minibuffer invocation. */
 
-static void read_minibuf_unwind ();
+static Lisp_Object read_minibuf_unwind ();
 Lisp_Object get_minibuffer ();
 static Lisp_Object read_minibuf ();
 
@@ -376,7 +380,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
   current_buffer->keymap = map;
 
   /* Turn on an input method stored in INPUT_METHOD if any.  */
-  if (STRINGP (input_method) && Ffboundp (Qactivate_input_method))
+  if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method)))
     call1 (Qactivate_input_method, input_method);
 
   /* If appropriate, copy enable-multibyte-characters into the minibuffer.  */
@@ -412,6 +416,10 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
 #endif
 
   /* VAL is the string of minibuffer text.  */
+
+  if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (defalt))
+    val = defalt;
+
   last_minibuf_string = val;
 
   /* Add the value to the appropriate history list unless it is empty.  */
@@ -520,7 +528,7 @@ get_minibuffer (depth)
 /* This function is called on exiting minibuffer, whether normally or not,
  and it restores the current window, buffer, etc. */
 
-static void
+static Lisp_Object
 read_minibuf_unwind (data)
      Lisp_Object data;
 {
@@ -579,6 +587,8 @@ read_minibuf_unwind (data)
   windows_or_buffers_changed++;
   XSETFASTINT (XWINDOW (window)->last_modified, 0);
   XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0);
+
+  return Qnil;
 }
 \f
 
@@ -675,8 +685,6 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1,
                      histvar, histpos, default_value,
                      minibuffer_allow_text_properties,
                      !NILP (inherit_input_method));
-  if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (default_value))
-    val = default_value;
   UNGCPRO;
   return val;
 }
@@ -748,9 +756,20 @@ Prompts with PROMPT.  By default, return DEFAULT-VALUE.")
   (prompt, default_value)
      Lisp_Object prompt, default_value;
 {
-  return Fintern (Fcompleting_read (prompt, Vobarray, Qcommandp, Qt,
-                                   Qnil, Qnil, default_value, Qnil),
-                 Qnil);
+  Lisp_Object name, default_string;
+
+  if (NILP (default_value))
+    default_string = Qnil;
+  else if (SYMBOLP (default_value))
+    default_string = XSYMBOL (default_value)->name;
+  else
+    default_string = default_value;
+    
+  name = Fcompleting_read (prompt, Vobarray, Qcommandp, Qt,
+                          Qnil, Qnil, default_string, Qnil);
+  if (NILP (name))
+    return name;
+  return Fintern (name, Qnil);
 }
 
 #ifdef NOTDEF
@@ -772,10 +791,21 @@ A user variable is one whose documentation starts with a `*' character.")
   (prompt, default_value)
      Lisp_Object prompt, default_value;
 {
-  return Fintern (Fcompleting_read (prompt, Vobarray,
-                                   Quser_variable_p, Qt,
-                                   Qnil, Qnil, default_value, Qnil),
-                 Qnil);
+  Lisp_Object name, default_string;
+
+  if (NILP (default_value))
+    default_string = Qnil;
+  else if (SYMBOLP (default_value))
+    default_string = XSYMBOL (default_value)->name;
+  else
+    default_string = default_value;
+    
+  name = Fcompleting_read (prompt, Vobarray,
+                          Quser_variable_p, Qt,
+                          Qnil, Qnil, default_string, Qnil);
+  if (NILP (name))
+    return name;
+  return Fintern (name, Qnil);
 }
 
 DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 3, 0,
@@ -787,19 +817,32 @@ If optional third arg REQUIRE-MATCH is non-nil, only existing buffer names are a
      Lisp_Object prompt, def, require_match;
 {
   Lisp_Object tem;
-  Lisp_Object args[3];
-
+  Lisp_Object args[4];
+  
   if (BUFFERP (def))
     def = XBUFFER (def)->name;
-  if (!NILP (def))
+
+  if (NILP (Vread_buffer_function))
+    {
+      if (!NILP (def))
+       {
+         args[0] = build_string ("%s(default %s) ");
+         args[1] = prompt;
+         args[2] = def;
+         prompt = Fformat (3, args);
+       }
+
+      return Fcompleting_read (prompt, Vbuffer_alist, Qnil,
+                              require_match, Qnil, Qnil, def, Qnil);
+    }
+  else
     {
-      args[0] = build_string ("%s(default %s) ");
+      args[0] = Vread_buffer_function;
       args[1] = prompt;
       args[2] = def;
-      prompt = Fformat (3, args);
+      args[3] = require_match;
+      return Ffuncall(4, args);
     }
-  return Fcompleting_read (prompt, Vbuffer_alist, Qnil,
-                          require_match, Qnil, Qnil, def, Qnil);
 }
 \f
 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
@@ -1255,8 +1298,6 @@ DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
                      init, prompt, make_number (pos), 0,
                      histvar, histpos, def, 0,
                      !NILP (inherit_input_method));
-  if (STRINGP (val) && XSTRING (val)->size == 0 && ! NILP (def))
-    val = def;
   RETURN_UNGCPRO (unbind_to (count, val));
 }
 \f
@@ -1880,6 +1921,7 @@ DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width,
    that has no possible completions, and other quick, unobtrusive
    messages.  */
 
+void
 temp_echo_area_glyphs (m)
      char *m;
 {
@@ -1918,12 +1960,14 @@ or until the next input event arrives, whichever comes first.")
   return Qnil;
 }
 \f
+void
 init_minibuf_once ()
 {
   Vminibuffer_list = Qnil;
   staticpro (&Vminibuffer_list);
 }
 
+void
 syms_of_minibuf ()
 {
   minibuf_level = 0;
@@ -1976,6 +2020,10 @@ syms_of_minibuf ()
   Qactivate_input_method = intern ("activate-input-method");
   staticpro (&Qactivate_input_method);
 
+  DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, 
+    "If this is non-nil, `read-buffer' does its work by calling this function.");
+  Vread_buffer_function = Qnil;
+
   DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, 
     "Normal hook run just after entry to minibuffer.");
   Vminibuffer_setup_hook = Qnil;
@@ -2001,9 +2049,7 @@ property of a history variable overrides this default.");
 
   DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers,
     "*Non-nil means to allow minibuffer commands while in the minibuffer.\n\
-More precisely, this variable makes a difference when the minibuffer window\n\
-is the selected window.  If you are in some other window, minibuffer commands\n\
-are allowed even if a minibuffer is active.");
+This variable makes a difference whenever the minibuffer window is active.");
   enable_recursive_minibuffers = 0;
 
   DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table,
@@ -2089,6 +2135,7 @@ with completion; they always discard text properties.");
   defsubr (&Sminibuffer_message);
 }
 
+void
 keys_of_minibuf ()
 {
   initial_define_key (Vminibuffer_local_map, Ctl ('g'),