Subject: Re: bug#71603: Mouse clicking on a list-bookmarks' entry can not jump the cursor

From: Eshel Yaron <[email-masked]>
Date: Mon, 17 Jun 2024 08:34:29 +0200

Hi there,

Siyuan Chen <[email-masked]> writes:

> The reproduce steps:
>
> 1. Open Emacs 29.3 on Windows with -Q
>
> 2. Open a .el file which included some code, e.g. init.el
>
> 3. M-x `bookmark-delete-all` to cleanup bookmarks if you have
>
> 4. M-x `bookmark-set` at some locations, e.g. bk1 bk2
>
> 5. M-x `list-bookmarks` to open *Bookmark List* which should have 2 entries
>
> 6. Split 2 windows, the up window displays init.el, the bottom window displays *Bookmark List*
>
> 7. Mouse left click (or press 'on' ) on bk1 or bk2 in *Bookmark List* 
>
> The expected behavior: jump cursor to bk1 or bk2
>
> The actual behavior: nothing happens, except the left fringe displays an additional bookmark icon if your current
> point is not at one of the bookmark locations.

Thanks, I can reproduce this issue on master.  Does the diff below yield
the expected behavior?

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 06f8e24b518..d87d4e473ac 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1265,10 +1265,11 @@ bookmark--jump-via
 by BOOKMARK-NAME-OR-RECORD, if necessary, run `bookmark-after-jump-hook',
 and then show any annotations for this bookmark."
   (bookmark-handle-bookmark bookmark-name-or-record)
-  (save-current-buffer
-    (funcall display-function (current-buffer)))
-  (let ((win (get-buffer-window (current-buffer) 0)))
-    (if win (set-window-point win (point))))
+  (let ((point (point)))
+    (save-current-buffer
+      (funcall display-function (current-buffer)))
+    (let ((win (get-buffer-window (current-buffer) 0)))
+      (if win (set-window-point win point))))
   ;; FIXME: we used to only run bookmark-after-jump-hook in
   ;; `bookmark-jump' itself, but in none of the other commands.
   (when bookmark-fringe-mark