Subject: bug#13972: 24.3.50; Cannot delete bookmark

From: Thierry Volpiatto <[email-masked]>
Date: Sun, 17 Mar 2013 08:47:13 +0100

Thierry Volpiatto <[email-masked]> writes:

> Xue Fuqiao <[email-masked]> writes:
>
>> I have three bookmarks:
>>
>>   TODO			        /usr/local/share/emacs/24.3.50/etc/TODO
>>   startup.el		        ~/emacs-bzr/trunk/lisp/startup.el
>>   text property		        /usr/local/share/info/elisp
>>
>> All of these files exist.  To reproduce this bug:
>>
>>   emacs -Q
>>   C-x r l
>>   d x
>>
>> The echo area says: "Deleting bookmarks...done".
>>
>> But the bookmark isn't deleted.  I have attached my
>> ~/.emacs.d/bookmarks.
>
> diff --git a/lisp/bookmark.el b/lisp/bookmark.el
> index 47e1379..ee6e050 100644
> --- a/lisp/bookmark.el
> +++ b/lisp/bookmark.el
> @@ -1582,8 +1582,8 @@ deletion, or > if it is flagged for displaying."
>      (if bookmark-bmenu-use-header-line
>  	(bookmark-bmenu-set-header)
>        (forward-line bookmark-bmenu-inline-header-height))
> -    (if bookmark-bmenu-toggle-filenames
> -        (bookmark-bmenu-toggle-filenames t))))
> +    (when (and bookmark-alist bookmark-bmenu-toggle-filenames)
> +      (bookmark-bmenu-toggle-filenames t))))
>  
>  ;;;###autoload
>  (defalias 'list-bookmarks 'bookmark-bmenu-list)

And here final patch that delete also the first bookmark in list.
(When forward-line 1, the first bookmark is never deleted because search
start to next bookmark with new header stuff.)
Also the final hook will not save bookmark-alist if empty, I have
removed the check of bookmark-alist.

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 47e1379..c1d8a4a 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1582,8 +1582,8 @@ deletion, or > if it is flagged for displaying."
     (if bookmark-bmenu-use-header-line
 	(bookmark-bmenu-set-header)
       (forward-line bookmark-bmenu-inline-header-height))
-    (if bookmark-bmenu-toggle-filenames
-        (bookmark-bmenu-toggle-filenames t))))
+    (when (and bookmark-alist bookmark-bmenu-toggle-filenames)
+      (bookmark-bmenu-toggle-filenames t))))
 
 ;;;###autoload
 (defalias 'list-bookmarks 'bookmark-bmenu-list)
@@ -1998,7 +1998,8 @@ To carry out the deletions that you've marked, use \\<bookmark-bmenu-mode-map>\\
                        (progn (end-of-line) (point))))))
         (o-col     (current-column)))
     (goto-char (point-min))
-    (forward-line 1)
+    (unless bookmark-bmenu-use-header-line
+      (forward-line 1))
     (while (re-search-forward "^D" (point-max) t)
       (bookmark-delete (bookmark-bmenu-bookmark) t)) ; pass BATCH arg
     (bookmark-bmenu-list)
@@ -2186,8 +2187,7 @@ strings returned are not."
   "Save bookmark state, if necessary, at Emacs exit time.
 This also runs `bookmark-exit-hook'."
   (run-hooks 'bookmark-exit-hook)
-  (and bookmark-alist
-       (bookmark-time-to-save-p t)
+  (and (bookmark-time-to-save-p t)
        (bookmark-save)))
 
 (unless noninteractive

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