Subject: Re: bug#20152: 24.4: bookmarks display wrong annotation (FIX INCLUDED)

From: Boruch Baum <[email-masked]>
Date: Fri, 20 Mar 2015 14:32:34 -0400

Stefan,

I noticed that my solution, while good, was partial, in that it didn't
cover ALL the possible navigation commands.

Attached is a more elegant, smaller, and more thorough fix, especially
appropriate or a buffer such as bookmark-bmenu, as so many of the
keystrokes within the buffer will be navigation commands.

This patch replaces `emacs_bug_20152-a.patch'.

Signing off for Shabbat,

Boruch.

On 03/20/2015 10:31 AM, Stefan Monnier wrote:
> Same here, please resend your fix as a patch ("diff -u" or "diff -c").-- 

hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

--- bookmark.el	2015-03-20 14:25:37.325230039 -0400
+++ bookmark-new.el	2015-03-20 14:22:03.981236956 -0400
@@ -2068,6 +2068,31 @@
     (forward-line 1))
   (forward-line 0))
 
+(defvar bookmark-bmenu-auto-display-annotations nil
+"Whether to automatically display a bookmark's annotation as one
+navigates through the bookmark list. `t' for yes. Default is
+`nil'.")
+
+(defvar bookmark-bmenu-last-post-command-line 1
+"The line number at point, within the bookmark list buffer, after
+the last command had been run in that buffer.")
+
+(defun bookmark-bmenu-motion-hook-function ()
+"This function is added to the `post-command-hook' locally for
+bookmark list buffers, in order to update any visible annotations
+as one navigates within the buffer."
+  (let ((annotation-buffer))
+    (when (/= bookmark-bmenu-last-post-command-line (line-number-at-pos))
+      (when (setq annotation-buffer (get-buffer "*Bookmark Annotation*"))
+        (kill-buffer annotation-buffer))
+      (when bookmark-bmenu-auto-display-annotations
+        (bookmark-bmenu-show-annotation)))))
+
+(defun bookmark-bmenu-post-command-hook-function ()
+  (add-hook 'post-command-hook 'bookmark-bmenu-motion-hook-function t t))
+
+(add-hook 'bookmark-bmenu-mode-hook 'bookmark-bmenu-post-command-hook-function)
+
 
 
 ;;; Menu bar stuff.  Prefix is "bookmark-menu".