#include "lisp.h"
#include "commands.h"
#include "buffer.h"
-#include "charset.h"
+#include "character.h"
#include "dispextern.h"
#include "keyboard.h"
#include "frame.h"
#include "syntax.h"
#include "intervals.h"
#include "keymap.h"
+#include "termhooks.h"
extern int quit_char;
GCPRO2 (val, defalt);
- if (STRINGP (val) && SCHARS (val) == 0
- && STRINGP (defalt))
- val = defalt;
+ if (STRINGP (val) && SCHARS (val) == 0)
+ {
+ if (STRINGP (defalt))
+ val = defalt;
+ else if (CONSP (defalt) && STRINGP (XCAR (defalt)))
+ val = XCAR (defalt);
+ }
expr_and_pos = Fread_from_string (val, Qnil, Qnil);
pos = XINT (Fcdr (expr_and_pos));
/* If Lisp form desired instead of string, parse it. */
if (expflag)
- val = string_to_object (val, defalt);
+ val = string_to_object (val, CONSP (defalt) ? XCAR (defalt) : defalt);
return val;
}
if (EQ (Vminibuffer_completing_file_name, Qlambda))
Vminibuffer_completing_file_name = Qnil;
- single_kboard_state ();
#ifdef HAVE_X_WINDOWS
if (display_hourglass_p)
cancel_hourglass ();
GCPRO5 (map, initial, val, ambient_dir, input_method);
if (!STRINGP (prompt))
- prompt = empty_string;
+ prompt = empty_unibyte_string;
if (!enable_recursive_minibuffers
&& minibuf_level > 0)
if (minibuffer_auto_raise)
Fraise_frame (mini_frame);
+ temporarily_switch_to_single_kboard (XFRAME (mini_frame));
+
/* We have to do this after saving the window configuration
since that is what restores the current buffer. */
XWINDOW (minibuf_window)->cursor.x = 0;
XWINDOW (minibuf_window)->must_be_updated_p = 1;
update_frame (XFRAME (selected_frame), 1, 1);
- if (rif && rif->flush_display)
- rif->flush_display (XFRAME (XWINDOW (minibuf_window)->frame));
+ {
+ struct frame *f = XFRAME (XWINDOW (minibuf_window)->frame);
+ struct redisplay_interface *rif = FRAME_RIF (f);
+ if (rif && rif->flush_display)
+ rif->flush_display (f);
+ }
}
/* Make minibuffer contents into a string. */
histstring = val;
else if (STRINGP (defalt))
histstring = defalt;
+ else if (CONSP (defalt) && STRINGP (XCAR (defalt)))
+ histstring = XCAR (defalt);
else
histstring = Qnil;
doc: /* Return a Lisp object read using the minibuffer, unevaluated.
Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS
is a string to insert in the minibuffer before reading.
-\(INITIAL-CONTENTS can also be a cons of a string and an integer. Such
-arguments are used as in `read-from-minibuffer'.) */)
+\(INITIAL-CONTENTS can also be a cons of a string and an integer.
+Such arguments are used as in `read-from-minibuffer'.) */)
(prompt, initial_contents)
Lisp_Object prompt, initial_contents;
{
doc: /* Return value of Lisp expression read using the minibuffer.
Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS
is a string to insert in the minibuffer before reading.
-\(INITIAL-CONTENTS can also be a cons of a string and an integer. Such
-arguments are used as in `read-from-minibuffer'.) */)
+\(INITIAL-CONTENTS can also be a cons of a string and an integer.
+Such arguments are used as in `read-from-minibuffer'.) */)
(prompt, initial_contents)
Lisp_Object prompt, initial_contents;
{
Qnil, history, default_value,
inherit_input_method);
if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
- val = default_value;
+ val = CONSP (default_value) ? XCAR (default_value) : default_value;
return val;
}
args[0] = build_string ("%s (default %s): ");
args[1] = prompt;
- args[2] = def;
+ args[2] = CONSP (def) ? XCAR (def) : def;
prompt = Fformat (3, args);
}
int bestmatchsize = 0;
/* These are in bytes, too. */
int compare, matchsize;
- int type = (HASH_TABLE_P (collection) ? 3
- : VECTORP (collection) ? 2
- : NILP (collection) || (CONSP (collection)
- && (!SYMBOLP (XCAR (collection))
- || NILP (XCAR (collection)))));
+ enum { function_table, list_table, obarray_table, hash_table}
+ type = (HASH_TABLE_P (collection) ? hash_table
+ : VECTORP (collection) ? obarray_table
+ : ((NILP (collection)
+ || (CONSP (collection)
+ && (!SYMBOLP (XCAR (collection))
+ || NILP (XCAR (collection)))))
+ ? list_table : function_table));
int index = 0, obsize = 0;
int matchcount = 0;
int bindcount = -1;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
CHECK_STRING (string);
- if (type == 0)
+ if (type == function_table)
return call3 (collection, string, predicate, Qnil);
bestmatch = bucket = Qnil;
/* If COLLECTION is not a list, set TAIL just for gc pro. */
tail = collection;
- if (type == 2)
+ if (type == obarray_table)
{
collection = check_obarray (collection);
obsize = XVECTOR (collection)->size;
/* elt gets the alist element or symbol.
eltstring gets the name to check as a completion. */
- if (type == 1)
+ if (type == list_table)
{
if (!CONSP (tail))
break;
eltstring = CONSP (elt) ? XCAR (elt) : elt;
tail = XCDR (tail);
}
- else if (type == 2)
+ else if (type == obarray_table)
{
if (!EQ (bucket, zero))
{
continue;
}
}
- else /* if (type == 3) */
+ else /* if (type == hash_table) */
{
while (index < HASH_TABLE_SIZE (XHASH_TABLE (collection))
&& NILP (HASH_HASH (XHASH_TABLE (collection), index)))
tem = Fcommandp (elt, Qnil);
else
{
- if (bindcount >= 0) {
- unbind_to (bindcount, Qnil);
- bindcount = -1;
- }
+ if (bindcount >= 0)
+ {
+ unbind_to (bindcount, Qnil);
+ bindcount = -1;
+ }
GCPRO4 (tail, string, eltstring, bestmatch);
- tem = type == 3
- ? call2 (predicate, elt,
- HASH_VALUE (XHASH_TABLE (collection), index - 1))
- : call1 (predicate, elt);
+ tem = (type == hash_table
+ ? call2 (predicate, elt,
+ HASH_VALUE (XHASH_TABLE (collection),
+ index - 1))
+ : call1 (predicate, elt));
UNGCPRO;
}
if (NILP (tem)) continue;
See `try-completion' and `all-completions' for more details
on completion, COLLECTION, and PREDICATE.
-If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
- the input is (or completes to) an element of COLLECTION or is null.
- If it is also not t, typing RET does not exit if it does non-null completion.
+REQUIRE-MATCH can take the following values:
+- 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.
+- anything else behaves like t except that typing RET does not exit if it
+ does non-null completion.
+
If the input is null, `completing-read' returns DEF, or an empty string
if DEF is nil, regardless of the value of REQUIRE-MATCH.
!NILP (inherit_input_method));
if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def))
- val = def;
+ val = CONSP (def) ? XCAR (def) : def;
RETURN_UNGCPRO (unbind_to (count, val));
}
if (SYMBOLP (key))
key = Fsymbol_name (key);
- for (tail = list; !NILP (tail); tail = Fcdr (tail))
+ for (tail = list; CONSP (tail); tail = XCDR (tail))
{
register Lisp_Object elt, tem, thiscar;
- elt = Fcar (tail);
+ elt = XCAR (tail);
thiscar = CONSP (elt) ? XCAR (elt) : elt;
if (SYMBOLP (thiscar))
thiscar = Fsymbol_name (thiscar);
goto exit;
}
+ if (EQ (Vminibuffer_completion_confirm, intern ("confirm-only")))
+ { /* The user is permitted to exit with an input that's rejected
+ by test-completion, but at the condition to confirm her choice. */
+ if (EQ (current_kboard->Vlast_command, Vthis_command))
+ goto exit;
+ else
+ {
+ temp_echo_area_glyphs (build_string (" [Confirm]"));
+ return Qnil;
+ }
+ }
+
/* Call do_completion, but ignore errors. */
SET_PT (ZV);
val = internal_condition_case (complete_and_exit_1, Qerror,
/* Now find first word-break in the stuff found by completion.
i gets index in string of where to stop completing. */
- {
- int len, c;
- int bytes = SBYTES (completion);
- register const unsigned char *completion_string = SDATA (completion);
- for (; i_byte < SBYTES (completion); i_byte += len, i++)
- {
- c = STRING_CHAR_AND_LENGTH (completion_string + i_byte,
- bytes - i_byte,
- len);
- if (SYNTAX (c) != Sword)
- {
- i_byte += len;
- i++;
- break;
- }
- }
- }
+ while (i_byte < SBYTES (completion))
+ {
+ int c;
+
+ FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, completion, i, i_byte);
+ if (SYNTAX (c) != Sword)
+ break;
+ }
/* If got no characters, print help for user. */
doc: /* Terminate minibuffer input. */)
()
{
- if (INTEGERP (last_command_char))
+ if (CHARACTERP (last_command_char))
internal_self_insert (XINT (last_command_char), 0);
else
bitch_at_user ();