bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14176: 24.3.50; `bookmark-completing-read': prompt and return value


From: Thierry Volpiatto
Subject: bug#14176: 24.3.50; `bookmark-completing-read': prompt and return value for "" DEFAULT
Date: Sat, 13 Apr 2013 10:16:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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

> For the doc string:
>
>  DEFAULT is a string to return if the user input is empty.
>  If DEFAULT is nil (absent) then return "" for empty input.

Here with the docstring modified, if you want to modify the docstring
(or something else), provide a patch to allow Stefan to apply the
changes.

Thanks.


diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index c1d8a4a..c98ad0c 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -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 (string= "" 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)


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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]