(bookmark--jump-via): Ensure 'window-point' is set correctly
authorEshel Yaron <me@eshelyaron.com>
Mon, 17 Jun 2024 14:48:43 +0000 (16:48 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 17 Jun 2024 14:48:43 +0000 (16:48 +0200)
* lisp/bookmark.el (bookmark--jump-via): Record
bookmark-prescribed point before calling DISPLAY-FUNCTION, and
use it to set 'window-point' afterwards.  (Bug#71603)

lisp/bookmark.el

index 06f8e24b51824384dd6fb6694c60a24e94bfc21a..223a7fedc8d55dedcbbde52ae1717f844aa82355 100644 (file)
@@ -1265,10 +1265,12 @@ After calling DISPLAY-FUNCTION, set window point to the point specified
 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))))
+  ;; Store `point' now, because `display-function' might change it.
+  (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