aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Francoise2005-09-30 18:30:10 +0000
committerRomain Francoise2005-09-30 18:30:10 +0000
commit97c3e4cc37decbf26618ce80b215f1a6aea2a7b8 (patch)
tree52f32dad2f4f08d11fe70633f195fc2cb20dbaf2
parent42b5e85ecd6609f0c35edb9eeb24936b431e940c (diff)
downloademacs-97c3e4cc37decbf26618ce80b215f1a6aea2a7b8.tar.gz
emacs-97c3e4cc37decbf26618ce80b215f1a6aea2a7b8.zip
(High-Level Completion): Explain that the prompt
given to `read-buffer' should end with a colon and a space. Update usage examples.
-rw-r--r--lispref/ChangeLog6
-rw-r--r--lispref/minibuf.texi9
-rw-r--r--src/ChangeLog5
-rw-r--r--src/minibuf.c26
4 files changed, 42 insertions, 4 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 6e8f20024d2..332ec14df3a 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,9 @@
12005-09-30 Romain Francoise <romain@orebokech.com>
2
3 * minibuf.texi (High-Level Completion): Explain that the prompt
4 given to `read-buffer' should end with a colon and a space.
5 Update usage examples.
6
12005-09-29 Juri Linkov <juri@jurta.org> 72005-09-29 Juri Linkov <juri@jurta.org>
2 8
3 * display.texi (Displaying Messages): Rename argument name 9 * display.texi (Displaying Messages): Rename argument name
diff --git a/lispref/minibuf.texi b/lispref/minibuf.texi
index 04443c493f3..bc2342fc18e 100644
--- a/lispref/minibuf.texi
+++ b/lispref/minibuf.texi
@@ -1044,6 +1044,11 @@ return if the user exits with an empty minibuffer. If non-@code{nil},
1044it should be a string or a buffer. It is mentioned in the prompt, but 1044it should be a string or a buffer. It is mentioned in the prompt, but
1045is not inserted in the minibuffer as initial input. 1045is not inserted in the minibuffer as initial input.
1046 1046
1047The argument @var{prompt} should be a string ending with a colon and a
1048space. If @var{default} is non-@code{nil}, the function inserts it in
1049@var{prompt} before the colon to follow the convention for reading from
1050the minibuffer with a default value (@pxref{Programming Tips}).
1051
1047If @var{existing} is non-@code{nil}, then the name specified must be 1052If @var{existing} is non-@code{nil}, then the name specified must be
1048that of an existing buffer. The usual commands to exit the minibuffer 1053that of an existing buffer. The usual commands to exit the minibuffer
1049do not exit if the text is not valid, and @key{RET} does completion to 1054do not exit if the text is not valid, and @key{RET} does completion to
@@ -1058,7 +1063,7 @@ only buffer name starting with the given input is
1058@samp{minibuffer.texi}, so that name is the value. 1063@samp{minibuffer.texi}, so that name is the value.
1059 1064
1060@example 1065@example
1061(read-buffer "Buffer name? " "foo" t) 1066(read-buffer "Buffer name: " "foo" t)
1062@group 1067@group
1063;; @r{After evaluation of the preceding expression,} 1068;; @r{After evaluation of the preceding expression,}
1064;; @r{the following prompt appears,} 1069;; @r{the following prompt appears,}
@@ -1067,7 +1072,7 @@ only buffer name starting with the given input is
1067 1072
1068@group 1073@group
1069---------- Buffer: Minibuffer ---------- 1074---------- Buffer: Minibuffer ----------
1070Buffer name? (default foo) @point{} 1075Buffer name (default foo): @point{}
1071---------- Buffer: Minibuffer ---------- 1076---------- Buffer: Minibuffer ----------
1072@end group 1077@end group
1073 1078
diff --git a/src/ChangeLog b/src/ChangeLog
index 3b207c4b509..13c2c0562eb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12005-09-30 Romain Francoise <romain@orebokech.com>
2
3 * minibuf.c (Fread_buffer): Follow convention for reading from the
4 minibuffer with a default value. Doc fix.
5
12005-09-29 Juri Linkov <juri@jurta.org> 62005-09-29 Juri Linkov <juri@jurta.org>
2 7
3 * editfns.c (Fmessage, Fmessage_box, Fmessage_or_box): 8 * editfns.c (Fmessage, Fmessage_box, Fmessage_or_box):
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,
1132Prompt with PROMPT. 1132Prompt with PROMPT.
1133Optional second arg DEF is value to return if user enters an empty line. 1133Optional second arg DEF is value to return if user enters an empty line.
1134If optional third arg REQUIRE-MATCH is non-nil, 1134If optional third arg REQUIRE-MATCH is non-nil,
1135 only existing buffer names are allowed. */) 1135 only existing buffer names are allowed.
1136The argument PROMPT should be a string ending with a colon and a space. */)
1136 (prompt, def, require_match) 1137 (prompt, def, require_match)
1137 Lisp_Object prompt, def, require_match; 1138 Lisp_Object prompt, def, require_match;
1138{ 1139{
1139 Lisp_Object args[4]; 1140 Lisp_Object args[4];
1141 unsigned char *s;
1142 int len;
1140 1143
1141 if (BUFFERP (def)) 1144 if (BUFFERP (def))
1142 def = XBUFFER (def)->name; 1145 def = XBUFFER (def)->name;
@@ -1145,7 +1148,26 @@ If optional third arg REQUIRE-MATCH is non-nil,
1145 { 1148 {
1146 if (!NILP (def)) 1149 if (!NILP (def))
1147 { 1150 {
1148 args[0] = build_string ("%s(default %s) "); 1151 /* A default value was provided: we must change PROMPT,
1152 editing the default value in before the colon. To achieve
1153 this, we replace PROMPT with a substring that doesn't
1154 contain the terminal space and colon (if present). They
1155 are then added back using Fformat. */
1156
1157 if (STRINGP (prompt))
1158 {
1159 s = SDATA (prompt);
1160 len = strlen (s);
1161 if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ')
1162 len = len - 2;
1163 else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' '))
1164 len--;
1165
1166 prompt = make_specified_string (s, -1, len,
1167 STRING_MULTIBYTE (prompt));
1168 }
1169
1170 args[0] = build_string ("%s (default %s): ");
1149 args[1] = prompt; 1171 args[1] = prompt;
1150 args[2] = def; 1172 args[2] = def;
1151 prompt = Fformat (3, args); 1173 prompt = Fformat (3, args);