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

From: Stefan Monnier <[email-masked]>
Date: Wed, 25 Mar 2015 21:41:30 -0400

> In the bookmark list buffer, after viewing an annotation for a
> bookmark, navigating to another bookmark entry does not kill the
> annotation buffer display, leading to confusion about which entry
> the still-visible annotation refers.

Indeed.  How 'bout we only fix this part, not by removing the window,
but by keeping it up-to-date as long as the annotations buffer
is displayed?
Can you provide a patch which does just that?

> +(defvar bookmark-bmenu-toggle-auto-display-annotations nil

I think this is not needed: if the user wants to see the annotations,
she can hit `a' after which they'll be auto-updated as she moves in
the list.  And if she doesn't want to see the annotations, she can hit
`q' in the annotations buffer (which should call quit-window).

> +"When not `nil', function `bookmark-bmenu-show-annotation' (by
> +default, bound to `a`), toggles whether to automatically display
> +a bookmark's annotation as one navigates through the bookmark
> +list. Default is `nil'.")

We typically use "non-nil" and "nil" rather than "not `nil'" and
"`nil'".  Same for t which we don't put in `...'.  All other symbols
indeed do get `...'.

> +    (if bookmark-bmenu-auto-display-annotations
> +      (setq bookmark-bmenu-auto-display-annotations nil)
> +     (setq bookmark-bmenu-auto-display-annotations t)))

Aka (setq bookmark-bmenu-auto-display-annotations
          (not bookmark-bmenu-auto-display-annotations))

> +(defvar bookmark-bmenu-auto-display-annotations nil

I don't think we need this either, just use
(get-buffer-window "*Bookmark Annotation*" t) instead.

> +(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)

Better keep bookmark-bmenu-mode-hook nil by default.  IOW, the code
should simply be added to bookmark-bmenu-mode instead.

        Stefan