Subject: Re: bug#16090: 24.3.50; [PATCH] error when jumping to a doc-view bookmark

From: Stefan Monnier <[email-masked]>
Date: Wed, 02 Apr 2014 10:43:34 -0400

> No, I haven't looked into the differences yet.  But I think I've come up
> with a quite good solution for the general problem right now.  The patch
> below allows bookmark handlers to return a function that accepts the
> window showing the buffer and then may act on it.  When the
> display-function has been run, that function is called and in the
> doc-view case sets the page for that window.

Sounds good.

> Until now, return values of handlers where simply ignored.  It shouldn't
> break existing handlers, except if there's some handler that does
> something like

If we're worried about such corner cases, we can do the same we do with
completion-boundaries and completion-metadata: require that the function
return (post-display-function . FUN) instead of just FUN.
The probability that some pre-existing bookmark handler returns
something of the form (post-display-function . FUN) is sufficiently
small.

Another option is to use a new bookmark property `post-display-function'.

> I've tested it with bookmarks to docs that had to be converted anew and
> bookmarks to docs that were already cached, and it seems to DTRT in all
> cases.

I think the current behavior in the "already cached" case demonstrates
that we have a bug in there and I'm not sure that your patch fixes that
bug (i.e. maybe it just works around it).
I don't have time to dig into it, sadly.

For emacs-24, your patch is too intrusive, so I think a patch along the
lines of Andreas's might be acceptable, but it should use
bookmark-after-jump-hook instead of using a timer.

As for trunk, your patch is mostly OK.  I think it should be pushed
a bit further, tho: make it so that `display-function' returns the
window (and fall back on calling get-buffer-window), and make it so
that win-fn *replaces* the set-window-point (and receives the bookmark
as additional argument, since it's likely that the function may like to
use data from the bookmark, such as the page).

After all, this get-buffer-window + set-window-point thingy in
bookmark--jump-via is a hack to try and solve the same problem
we're having (tho for "point in normal buffers", instead of for "current
page in doc-view buffers").

        Stefan