# HG changeset patch # User Juri Linkov # Date 1193012391 0 # Node ID 6260015b78025f4e250380d39070c53464e24344 # Parent 7fa3f0c5ecbf7cac365e17dddd9ac57419f77867 Allow minibuffer default to be a list of default values. With empty input use the first element of this list as returned default. (string_to_object): (read_minibuf_noninteractive): If defalt is cons, set val to its car. (read_minibuf): If defalt is cons, set histstring to its car. (Fread_string): If default_value is cons, set val to its car. (Fread_buffer): If def is cons, use its car. (Fcompleting_read): If defalt is cons, set val to its car. diff -r 7fa3f0c5ecbf -r 6260015b7802 src/minibuf.c --- a/src/minibuf.c Mon Oct 22 00:17:55 2007 +0000 +++ b/src/minibuf.c Mon Oct 22 00:19:51 2007 +0000 @@ -257,9 +257,13 @@ 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)); @@ -337,7 +341,7 @@ /* 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; } @@ -785,6 +789,8 @@ histstring = val; else if (STRINGP (defalt)) histstring = defalt; + else if (CONSP (defalt) && STRINGP (XCAR (defalt))) + histstring = XCAR (defalt); else histstring = Qnil; @@ -1102,7 +1108,7 @@ 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; } @@ -1225,7 +1231,7 @@ args[0] = build_string ("%s (default %s): "); args[1] = prompt; - args[2] = def; + args[2] = CONSP (def) ? XCAR (def) : def; prompt = Fformat (3, args); } @@ -1835,7 +1841,7 @@ !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)); }