--- bookmark.el 2015-03-20 14:25:37.325230039 -0400 +++ bookmark-new.el 2015-03-20 14:40:51.425200402 -0400 @@ -1901,9 +1901,20 @@ (bookmark-bmenu-other-window)))) +(defvar bookmark-bmenu-toggle-auto-display-annotations nil +"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'.") + (defun bookmark-bmenu-show-annotation () "Show the annotation for the current bookmark in another window." (interactive) + (when (and (called-interactively-p "any") + bookmark-bmenu-toggle-auto-display-annotations) + (if bookmark-bmenu-auto-display-annotations + (setq bookmark-bmenu-auto-display-annotations nil) + (setq bookmark-bmenu-auto-display-annotations t))) (let ((bookmark (bookmark-bmenu-bookmark))) (bookmark-show-annotation bookmark))) @@ -2068,6 +2079,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".