/* Minibuffer input and completion.
Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008 Free Software Foundation, Inc.
+ 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include <stdio.h>
+#include <setjmp.h>
#include "lisp.h"
#include "commands.h"
if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (XFRAME (frame))))
&& !(EQ (frame, selected_frame)
&& minibuf_level > 0))
- Fset_frame_selected_window (frame, Fframe_first_window (frame));
+ Fset_frame_selected_window (frame, Fframe_first_window (frame), Qnil);
}
}
build_string ("Command attempted to use minibuffer while in minibuffer"));
}
- if (noninteractive && NILP (Vexecuting_kbd_macro))
+ if ((noninteractive
+ /* In case we are running as a daemon, only do this before
+ detaching from the terminal. */
+ || (IS_DAEMON && (daemon_pipe[1] >= 0)))
+ && NILP (Vexecuting_kbd_macro))
{
val = read_minibuf_noninteractive (map, initial, prompt,
make_number (pos),
Prompt with PROMPT.
Optional second arg DEF is value to return if user enters an empty line.
If DEF is a list of default values, return its first element.
-If optional third arg REQUIRE-MATCH is non-nil,
- only existing buffer names are allowed.
+Optional third arg REQUIRE-MATCH determines whether non-existing
+ buffer names are allowed. It has the same meaning as the
+ REQUIRE-MATCH argument of `confirm-after-completion'.
The argument PROMPT should be a string ending with a colon and a space.
If `read-buffer-completion-ignore-case' is non-nil, completion ignores
case while reading the buffer name.
Additionally to this predicate, `completion-regexp-list'
is used to further constrain the set of candidates.
-If the optional fourth argument HIDE-SPACES is non-nil,
-strings in COLLECTION that start with a space
-are ignored unless STRING itself starts with a space. */)
+An obsolete optional fourth argument HIDE-SPACES is still accepted for
+backward compatibility. If non-nil, strings in COLLECTION that start
+with a space are ignored unless STRING itself starts with a space. */)
(string, collection, predicate, hide_spaces)
Lisp_Object string, collection, predicate, hide_spaces;
{
&& SCHARS (string) <= SCHARS (eltstring)
/* If HIDE_SPACES, reject alternatives that start with space
unless the input starts with space. */
- && ((SBYTES (string) > 0
- && SREF (string, 0) == ' ')
- || SREF (eltstring, 0) != ' '
- || NILP (hide_spaces))
+ && (NILP (hide_spaces)
+ || (SBYTES (string) > 0
+ && SREF (string, 0) == ' ')
+ || SREF (eltstring, 0) != ' ')
&& (tem = Fcompare_strings (eltstring, zero,
make_number (SCHARS (string)),
string, zero,
- t means that the user is not allowed to exit unless
the input is (or completes to) an element of COLLECTION or is null.
- nil means that the user can exit with any input.
-- `confirm-only' means that the user can exit with any input, but she will
- need to confirm her choice if the input is not an element of COLLECTION.
+- `confirm' means that the user can exit with any input, but she needs
+ to confirm her choice if the input is not an element of COLLECTION.
+- `confirm-after-completion' means that the user can exit with any
+ input, but she needs to confirm her choice if she called
+ `minibuffer-complete' right before `minibuffer-complete-and-exit'
+ and the input is not an element of COLLECTION.
- anything else behaves like t except that typing RET does not exit if it
does non-null completion.
minibuf_save_list = Qnil;
staticpro (&minibuf_save_list);
- Qcompletion_ignore_case = intern ("completion-ignore-case");
+ Qcompletion_ignore_case = intern_c_string ("completion-ignore-case");
staticpro (&Qcompletion_ignore_case);
- Qread_file_name_internal = intern ("read-file-name-internal");
+ Qread_file_name_internal = intern_c_string ("read-file-name-internal");
staticpro (&Qread_file_name_internal);
- Qminibuffer_default = intern ("minibuffer-default");
+ Qminibuffer_default = intern_c_string ("minibuffer-default");
staticpro (&Qminibuffer_default);
Fset (Qminibuffer_default, Qnil);
- Qminibuffer_completion_table = intern ("minibuffer-completion-table");
+ Qminibuffer_completion_table = intern_c_string ("minibuffer-completion-table");
staticpro (&Qminibuffer_completion_table);
- Qminibuffer_completion_confirm = intern ("minibuffer-completion-confirm");
+ Qminibuffer_completion_confirm = intern_c_string ("minibuffer-completion-confirm");
staticpro (&Qminibuffer_completion_confirm);
- Qminibuffer_completion_predicate = intern ("minibuffer-completion-predicate");
+ Qminibuffer_completion_predicate = intern_c_string ("minibuffer-completion-predicate");
staticpro (&Qminibuffer_completion_predicate);
staticpro (&last_minibuf_string);
last_minibuf_string = Qnil;
- Quser_variable_p = intern ("user-variable-p");
+ Quser_variable_p = intern_c_string ("user-variable-p");
staticpro (&Quser_variable_p);
- Qminibuffer_history = intern ("minibuffer-history");
+ Qminibuffer_history = intern_c_string ("minibuffer-history");
staticpro (&Qminibuffer_history);
- Qbuffer_name_history = intern ("buffer-name-history");
+ Qbuffer_name_history = intern_c_string ("buffer-name-history");
staticpro (&Qbuffer_name_history);
Fset (Qbuffer_name_history, Qnil);
- Qminibuffer_setup_hook = intern ("minibuffer-setup-hook");
+ Qminibuffer_setup_hook = intern_c_string ("minibuffer-setup-hook");
staticpro (&Qminibuffer_setup_hook);
- Qminibuffer_exit_hook = intern ("minibuffer-exit-hook");
+ Qminibuffer_exit_hook = intern_c_string ("minibuffer-exit-hook");
staticpro (&Qminibuffer_exit_hook);
- Qhistory_length = intern ("history-length");
+ Qhistory_length = intern_c_string ("history-length");
staticpro (&Qhistory_length);
- Qcurrent_input_method = intern ("current-input-method");
+ Qcurrent_input_method = intern_c_string ("current-input-method");
staticpro (&Qcurrent_input_method);
- Qactivate_input_method = intern ("activate-input-method");
+ Qactivate_input_method = intern_c_string ("activate-input-method");
staticpro (&Qactivate_input_method);
- Qcase_fold_search = intern ("case-fold-search");
+ Qcase_fold_search = intern_c_string ("case-fold-search");
staticpro (&Qcase_fold_search);
- Qread_expression_history = intern ("read-expression-history");
+ Qread_expression_history = intern_c_string ("read-expression-history");
staticpro (&Qread_expression_history);
DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
Vminibuffer_completion_predicate = Qnil;
DEFVAR_LISP ("minibuffer-completion-confirm", &Vminibuffer_completion_confirm,
- doc: /* Non-nil means to demand confirmation of completion before exiting minibuffer. */);
+ doc: /* Whether to demand confirmation of completion before exiting minibuffer.
+If nil, confirmation is not required.
+If the value is `confirm', the user may exit with an input that is not
+ a valid completion alternative, but Emacs asks for confirmation.
+If the value is `confirm-after-completion', the user may exit with an
+ input that is not a valid completion alternative, but Emacs asks for
+ confirmation if the user submitted the input right after any of the
+ completion commands listed in `minibuffer-confirm-exit-commands'. */);
Vminibuffer_completion_confirm = Qnil;
DEFVAR_LISP ("minibuffer-completing-file-name",
/* We use `intern' here instead of Qread_only to avoid
initialization-order problems. */
Vminibuffer_prompt_properties
- = Fcons (intern ("read-only"), Fcons (Qt, Qnil));
+ = Fcons (intern_c_string ("read-only"), Fcons (Qt, Qnil));
DEFVAR_LISP ("read-expression-map", &Vread_expression_map,
doc: /* Minibuffer keymap used for reading Lisp expressions. */);