]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/bookmark.el (bookmark-completing-read): Improve handling of empty
authorThierry Volpiatto <thierry.volpiatto@gmail.com>
Fri, 19 Apr 2013 05:11:16 +0000 (01:11 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 19 Apr 2013 05:11:16 +0000 (01:11 -0400)
string.

Fixes: debbugs:14176
lisp/ChangeLog
lisp/bookmark.el

index 97ee66dcc0152e79e639d4f7a6da5b2841b6e8ef..a09d37352f7198f0832f56400b2999f97acb5b79 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-19  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
+
+       * bookmark.el (bookmark-completing-read): Improve handling of empty
+       string (bug#14176).
+
 2013-04-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * vc/vc-dispatcher.el (vc-do-command): Get rid of default sentinel msg.
index c1d8a4a0a5ebc36dc8228df9e4f5ce15013a3fd2..482cdf927520a5e17ecf6c518f55c273817237d3 100644 (file)
@@ -427,8 +427,8 @@ just return it."
   "Prompting with PROMPT, read a bookmark name in completion.
 PROMPT will get a \": \" stuck on the end no matter what, so you
 probably don't want to include one yourself.
-Optional second arg DEFAULT is a string to return if the user enters
-the empty string."
+Optional arg DEFAULT is a string to return if the user input is empty.
+If DEFAULT is nil then return empty string for empty input."
   (bookmark-maybe-load-default-file) ; paranoia
   (if (listp last-nonmenu-event)
       (bookmark-menu-popup-paned-menu t prompt
@@ -437,22 +437,17 @@ the empty string."
                                                'string-lessp)
                                        (bookmark-all-names)))
     (let* ((completion-ignore-case bookmark-completion-ignore-case)
-          (default default)
+           (default (unless (equal "" 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)