diff options
author | Romain Francoise <romain@orebokech.com> | 2005-09-30 18:30:10 +0000 |
---|---|---|
committer | Romain Francoise <romain@orebokech.com> | 2005-09-30 18:30:10 +0000 |
commit | 97c3e4cc37decbf26618ce80b215f1a6aea2a7b8 (patch) | |
tree | 52f32dad2f4f08d11fe70633f195fc2cb20dbaf2 /src/minibuf.c | |
parent | 42b5e85ecd6609f0c35edb9eeb24936b431e940c (diff) | |
download | emacs-97c3e4cc37decbf26618ce80b215f1a6aea2a7b8.tar.gz |
(High-Level Completion): Explain that the prompt
given to `read-buffer' should end with a colon and a space.
Update usage examples.
Diffstat (limited to 'src/minibuf.c')
-rw-r--r-- | src/minibuf.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index ace1e0dda76..28789b60bde 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -1132,11 +1132,14 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 3, 0, Prompt with PROMPT. Optional second arg DEF is value to return if user enters an empty line. If optional third arg REQUIRE-MATCH is non-nil, - only existing buffer names are allowed. */) + only existing buffer names are allowed. +The argument PROMPT should be a string ending with a colon and a space. */) (prompt, def, require_match) Lisp_Object prompt, def, require_match; { Lisp_Object args[4]; + unsigned char *s; + int len; if (BUFFERP (def)) def = XBUFFER (def)->name; @@ -1145,7 +1148,26 @@ If optional third arg REQUIRE-MATCH is non-nil, { if (!NILP (def)) { - args[0] = build_string ("%s(default %s) "); + /* A default value was provided: we must change PROMPT, + editing the default value in before the colon. To achieve + this, we replace PROMPT with a substring that doesn't + contain the terminal space and colon (if present). They + are then added back using Fformat. */ + + if (STRINGP (prompt)) + { + s = SDATA (prompt); + len = strlen (s); + if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ') + len = len - 2; + else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' ')) + len--; + + prompt = make_specified_string (s, -1, len, + STRING_MULTIBYTE (prompt)); + } + + args[0] = build_string ("%s (default %s): "); args[1] = prompt; args[2] = def; prompt = Fformat (3, args); |