/* Minibuffer input and completion.
Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU Emacs.
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;
}
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);
}
!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));
}