From: Karl Fogel <kfogel@red-bean.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Drew Adams <drew.adams@oracle.com>,
"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] Let bookmark handlers do everything, including display the destination
Date: Mon, 29 Aug 2022 18:45:31 -0500 [thread overview]
Message-ID: <87ilma397o.fsf@red-bean.com> (raw)
In-Reply-To: <jwvpmgjks21.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 29 Aug 2022 11:28:37 -0400")
On 29 Aug 2022, Stefan Monnier wrote:
>> There's some parallelism-unsafety going on here, obviously.
>> I'd love a way
>> to wrap all this in a clean closure, instead of setting a
>> global variable
>> which then retains that setting until the next time we happen
>> to set it.
>
> Indeed :-(
>
>> But I don't really see a way to do tihngs more cleanly than
>> with the
>> carry-out variable you propose. If there's some creative
>> solution for
>> connecting `bookmark--jump-via' to the "corresponding" handler
>> call that
>> happens later, I don't see it, lexically or dynamically. Maybe
>> is just how
>> Emacs usually handles these kinds of situations?
>
> Hmm... I must be missing something. Why can't
> `bookmark--jump-via`
> let-bind `bookmark-jump-display-function` around the call to
> `bookmark-handle-bookmark`?
Of course -- obvious, now that you point it out. Thank you for
reviewing, Stefan.
Drew, does that sound good to you?
> Regarding the patch, here are some comments:
>
>> + To display the destination, HANDLER can call the function
>> that's the
>> + value of variable `bookmark-jump-display-function', which is
>> set by
>> + `bookmark-jump' to automatically accommodate other-window
>> etc.
>> + displaying that depends on the jump command. For example:
>> +
>> + (funcall bookmark-jump-display-function (current-buffer))
>> +
>> + Or HANDLER can directly call another display function. For
>> example:
>> +
>> + (switch-to-buffer-other-tab BUFFER)
>
> I skipped most of the rest of the docstring's massaging, which
> I'm not
> sure is an improvement but with which I guess I can live. But
> the above
> goes significantly beyond what one usually expects from a
> docstring.
> It would fit much better in a Texinfo manual instead.
>
>> + Or HANDLER can invoke `bookmark-default-handler'. That
>> displays the
>> + destination. It then moves to the recorded buffer position,
>> POS,
>> + repositioning point, if necessary, to match the recorded
>> context
>> + strings STR-BEFORE-POS and STR-AFTER-POS. For instance, the
>> Info
>> + handler, `Info-bookmark-jump', does this at its end:
>
> And this is (or should be) redundant with the docstring of
> `bookmark-default-handler` so better keep the link and the the
> readers
> jump to it when they need/want to know what that function does.
Agreed.
>> +(defvar bookmark-jump-display-function nil
>> + "Function used currently to display a bookmark, or nil if no
>> function.")
>
> Please give it a function as default value (e.g. `ignore`).
I think I understand: by taking your advice, we don't have to
check the function's existence -- we can just call it
unconditionally, and if it happens to do nothing (i.e., is
`ignore'), that's fine. A specific package may still override the
default handler and do whatever display magic is called for;
otherwise, bookmark.el's default handler will Do The Right Thing
for displaying. But all this raises the question you raise
below...
>> @@ -1350,6 +1391,9 @@
>> ((and buf (get-buffer buf)))
>> (t ;; If not, raise error.
>> (signal 'bookmark-error-no-filename (list 'stringp
>> file)))))
>> + (when bookmark-jump-display-function
>> + (save-current-buffer (funcall
>> bookmark-jump-display-function
>> + (current-buffer))))
>
> Why `save-current-buffer`?
>
>> (if place (goto-char place))
>> ;; Go searching forward first. Then, if forward-str
>> exists and
>> ;; was found in the file, we can search backward for
>> behind-str.
>
> Hmm... `bookmark-default-handler` is also called via things like
> `bookmark-insert`, so I think `bookmark-insert` should
> explicitly bind
> `bookmark-jump-display-function` to `ignore`, and of course that
> begs
> the question of what to do for handlers which don't obey
> `bookmark-jump-display-function`.
>
> I think it's good to provide more control to the bookmark's
> handler, but
> there seems to be a need for the caller to control the display
> as well
> to some extent.
...which is that we now seem to have two possibly-redundant ways
to control displaying: write a custom handler, *or* bind
`bookmark-jump-display-function' to something?
Or perhaps I'm misunderstanding something. Drew, if you post the
next revision of the patch incorporating Stefan's points above, I
will review that in detail, when fully alert, and should be able
to distill any remaining questions -- I think we'd be pretty close
at that point.
> BTW, your generalization of bookmarks to "anything" makes it all
> the
> more obvious to me that these should be unified with "registers"
> (not
> necessarily at the UI level, but a register should be able to
> hold
> anything that can stored as a bookmark, and vice versa).
I agree that that makes sense as a long term goal.
Best regards,
-Karl
next prev parent reply other threads:[~2022-08-29 23:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-13 20:59 [PATCH] Let bookmark handlers do everything, including display the destination Drew Adams
2022-08-18 18:14 ` Karl Fogel
2022-08-29 15:28 ` Stefan Monnier
2022-08-29 23:45 ` Karl Fogel [this message]
2022-09-06 0:07 ` [External] : " Drew Adams
2022-09-26 19:47 ` Karl Fogel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilma397o.fsf@red-bean.com \
--to=kfogel@red-bean.com \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.