]> git.eshelyaron.com Git - emacs.git/commitdiff
(High-Level Completion): Explain that the prompt
authorRomain Francoise <romain@orebokech.com>
Fri, 30 Sep 2005 18:30:10 +0000 (18:30 +0000)
committerRomain Francoise <romain@orebokech.com>
Fri, 30 Sep 2005 18:30:10 +0000 (18:30 +0000)
given to `read-buffer' should end with a colon and a space.
Update usage examples.

lispref/ChangeLog
lispref/minibuf.texi
src/ChangeLog
src/minibuf.c

index 6e8f20024d22a8b830ca943cd8d9de52de16126e..332ec14df3afc466e833b88fcebe6966363f29fb 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-30  Romain Francoise  <romain@orebokech.com>
+
+       * minibuf.texi (High-Level Completion): Explain that the prompt
+       given to `read-buffer' should end with a colon and a space.
+       Update usage examples.
+
 2005-09-29  Juri Linkov  <juri@jurta.org>
 
        * display.texi (Displaying Messages): Rename argument name
index 04443c493f337bd74808bf5f9abe20c11d639079..bc2342fc18e460d956e2373d3cda53e2d3993d7f 100644 (file)
@@ -1044,6 +1044,11 @@ return if the user exits with an empty minibuffer.  If non-@code{nil},
 it should be a string or a buffer.  It is mentioned in the prompt, but
 is not inserted in the minibuffer as initial input.
 
+The argument @var{prompt} should be a string ending with a colon and a
+space.  If @var{default} is non-@code{nil}, the function inserts it in
+@var{prompt} before the colon to follow the convention for reading from
+the minibuffer with a default value (@pxref{Programming Tips}).
+
 If @var{existing} is non-@code{nil}, then the name specified must be
 that of an existing buffer.  The usual commands to exit the minibuffer
 do 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
 @samp{minibuffer.texi}, so that name is the value.
 
 @example
-(read-buffer "Buffer name? " "foo" t)
+(read-buffer "Buffer name: " "foo" t)
 @group
 ;; @r{After evaluation of the preceding expression,}
 ;;   @r{the following prompt appears,}
@@ -1067,7 +1072,7 @@ only buffer name starting with the given input is
 
 @group
 ---------- Buffer: Minibuffer ----------
-Buffer name? (default foo) @point{}
+Buffer name (default foo): @point{}
 ---------- Buffer: Minibuffer ----------
 @end group
 
index 3b207c4b509d23a4d2a0ff2f97423b4fc75ee1ab..13c2c0562ebac40cdb9593ede376bf52fd5513ad 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-30  Romain Francoise  <romain@orebokech.com>
+
+       * minibuf.c (Fread_buffer): Follow convention for reading from the
+       minibuffer with a default value.  Doc fix.
+
 2005-09-29  Juri Linkov  <juri@jurta.org>
 
        * editfns.c (Fmessage, Fmessage_box, Fmessage_or_box):
index ace1e0dda76e3a424db0c7d9ab49581d0cf7790f..28789b60bdeb3eafd92f1565d492c7f4ac8a6d7b 100644 (file)
@@ -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);