bug#81467: [PATCH] Make bookmark-jump work with other-window/frame/tab-prefix

Stéphane Marks <[email protected]> Fri, 31 Jul 2026 17:57:38 +0200
Newsgroups gmane.emacs.bugs
Message-ID <CAN+1Hbp+OiDNTGipAqAhQtf99ES+1fsUzv3=4nkLm_yFHoLLLg@mail.gmail.com>
On Fri, Jul 31, 2026 at 11:38 AM Stéphane Marks <[email protected]> wrote:

> On Fri, Jul 31, 2026 at 11:20 AM Stéphane Marks <[email protected]>
> wrote:
>
>> On Fri, Jul 31, 2026 at 10:48 AM Stéphane Marks <[email protected]>
>> wrote:
>>
>>> On Fri, Jul 31, 2026 at 10:35 AM Stefan Monnier <
>>> [email protected]> wrote:
>>>
>>>> > 1. A bookmark handler 'shell-bookmark-jump' calls the function
>>>> 'shell',
>>>> > because for the authors it was the simplest way to implement the
>>>> handler.
>>>>
>>>> And that's the part that needs fixing.
>>>> E.g. by adding a `shell-no-select`.
>>>>
>>>
>>> I'm happy to prepare a patch for that and at least a demonstration of
>>> how I see using the bookmark-inhibit handler property that we'd assign to
>>> the bufferlo handlers and bypass save-window-excursion, et.al.  Would
>>> these be for emacs-31 or leave it alone for now and focus on master?
>>>
>>
>> Thinking more about shell-bookmark-jump, if the default changes to
>> shell-no-select, it would break bufferlo bookmarks that contain shell
>> bookmarks.  Bufferlo currently passes #'ignore as display-function (via the
>> advice I discussed earlier).  We'd need to come up with a way not to break
>> those kinds of use cases.
>>
>
> Thinking even more, shell-bookmark-jump selecting or not will not
> negatively impact bufferlo.  Each bufferlo tab handler which contains
> things like shell bookmarks, invokes each bookmark's handler directly,
> bypassing --jump-via's assumptions, and then restores the tab's window
> configuration which can't bypass the originating --jump-via which may have
> come from a bookmark-jump command (a somewhat nasty hack was written to
> avoid the new save-window-excursion call which).  Top-level bufferlo frame
> and tab bookmarks would still want bookmark-inhibit display-function
> treatment for themselves.
>

This is a touch messy ATM, but it gets the point across for the
bookmark-inhibit handler property.

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 77136308573..0024ecef1b6 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1265,12 +1265,23 @@ bookmark--jump-via
 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."
-  (let (buf point)
-    (save-window-excursion
-      (bookmark-handle-bookmark bookmark-name-or-record)
-      (setq buf (current-buffer)
-            point (point)))
-    (funcall display-function buf)
+  (let (buf
+        point
+        (inhibit-display-function
+         (memq 'display-function
+               (get (or (bookmark-get-handler bookmark-name-or-record)
+                        #'bookmark-default-handler)
+                    'bookmark-inhibit))))
+    (if inhibit-display-function
+        (progn
+          (bookmark-handle-bookmark bookmark-name-or-record)
+          (setq buf (current-buffer)
+                point (point)))
+      (save-window-excursion
+        (bookmark-handle-bookmark bookmark-name-or-record)
+        (setq buf (current-buffer)
+              point (point)))
+      (funcall display-function buf))
     (when-let* ((win (get-buffer-window buf 0)))
       (set-window-point win point))
     (when bookmark-fringe-mark