unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: 14176@debbugs.gnu.org
Subject: bug#14176: 24.3.50; `bookmark-completing-read': prompt and return value for "" DEFAULT
Date: Thu, 11 Apr 2013 07:59:22 +0200	[thread overview]
Message-ID: <87txnda9qd.fsf@gmail.com> (raw)
In-Reply-To: <7707C9A29C4748B093E2167A99592511@us.oracle.com>

Hi Drew,

"Drew Adams" <drew.adams@oracle.com> writes:

> 1. Do not insert DEFAULT, in parens, into the PROMPT if DEFAULT is "".
>  
> 2. Doc string should mention the return value ("") for empty input ("")
> when DEFAULT is nil.

Isn't there a bad usage of `completing-read' here, IMO the
DEFAULT arg of `completing-read' should be used instead of:

,----
| (if (string-equal "" str) default str)
`----

Also why is 'default' let-bounded ?

Here a patch:

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index c1d8a4a..8698821 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -437,22 +437,21 @@ the empty string."
 						'string-lessp)
 					(bookmark-all-names)))
     (let* ((completion-ignore-case bookmark-completion-ignore-case)
-	   (default default)
 	   (prompt (concat prompt (if default
                                       (format " (%s): " default)
-                                    ": ")))
-	   (str
-	    (completing-read prompt
-			     (lambda (string pred action)
-                               (if (eq action 'metadata)
-                                   '(metadata (category . bookmark))
-                                 (complete-with-action
-                                  action bookmark-alist string pred)))
-			     nil
-			     0
-			     nil
-			     'bookmark-history)))
-      (if (string-equal "" str) default str))))
+                                    ": "))))
+      (completing-read prompt
+                       (lambda (string pred action)
+                         (if (eq action 'metadata)
+                             '(metadata (category . bookmark))
+                             (complete-with-action
+                              action bookmark-alist string pred)))
+                       nil
+                       0
+                       nil
+                       'bookmark-history
+                       default))))
+
 
 
 (defmacro bookmark-maybe-historicize-string (string)


    
> In GNU Emacs 24.3.50.1 (i386-mingw-nt5.1.2600)
>  of 2013-04-02 on ODIEONE
> Bzr revision: 112212 cyd@gnu.org-20130402033331-sqegwhqh7u1o0ars
> Windowing system distributor `Microsoft Corp.', version 5.1.2600
> Configured using:
>  `configure --with-gcc (4.7) --no-opt --enable-checking --cflags
>  -IC:/Devel/emacs/build/include --ldflags -LC:/Devel/emacs/build/lib'
>  
>
>
>
>
>

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






  reply	other threads:[~2013-04-11  5:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 22:04 bug#14176: 24.3.50; `bookmark-completing-read': prompt and return value for "" DEFAULT Drew Adams
2013-04-11  5:59 ` Thierry Volpiatto [this message]
2013-04-11 14:03   ` Stefan Monnier
2013-04-11 15:10     ` Thierry Volpiatto
2013-04-11 21:32   ` Drew Adams
2013-04-12  5:38     ` Thierry Volpiatto
2013-04-12 14:14       ` Drew Adams
2013-04-13  8:16         ` Thierry Volpiatto
2013-04-13 15:46           ` Drew Adams
2013-04-19  5:12           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txnda9qd.fsf@gmail.com \
    --to=thierry.volpiatto@gmail.com \
    --cc=14176@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).