diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/minibuf.c | 26 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3b207c4b509..13c2c0562eb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2005-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 | |||
| 1 | 2005-09-29 Juri Linkov <juri@jurta.org> | 6 | 2005-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, | |||
| 1132 | Prompt with PROMPT. | 1132 | Prompt with PROMPT. |
| 1133 | Optional second arg DEF is value to return if user enters an empty line. | 1133 | Optional second arg DEF is value to return if user enters an empty line. |
| 1134 | If optional third arg REQUIRE-MATCH is non-nil, | 1134 | If optional third arg REQUIRE-MATCH is non-nil, |
| 1135 | only existing buffer names are allowed. */) | 1135 | only existing buffer names are allowed. |
| 1136 | The 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); |