1

I've installed Bookmarks+ from quelpa recently, and everything was working fine until I made a minor tweak with my pdf-tools config. Now I cannot jump to bookmarks of .pdf files from any buffer, although I can see from the buffer list window that the corresponding files have been opened.

To be concrete, if I do C-x j j and select a .pdf bookmark, I get a message in the mini-buffer, which depends on what buffer I am currently viewing, although in all cases Emacs does not jump to the appropriate .pdf:

  • If I am in the *Bookmark List* (or *scratch*) buffer, the message is
pdf-info--normalize-file-or-buffer: Buffer is not associated with any file :*Bookmark List*
  • if I am in a buffer viewing the ~/Org/work.org file,
pdf-info-query: epdfinfo: Error opening /home/nonreligious/Org/work.org:PDF document is damaged

Again, the .pdf file appears in the list of buffers that are open. No other bookmark (to .org, .txt, dired buffers) has any issues.

I think these two issues raised on github are relevant:

The problem seems to be with pdf-view-bookmark-jump-handler. The second issue still being open suggests there isn't an official fix yet... but I hope someone else has come across this issue and has found a workaround.

I've tried restoring the original pdf-tools configuration and restarting emacs, but to no avail.

Using Emacs v27.2, pdf-tools-20220522.13.

3
  • Could you try this, to see how much Bookmark+ might be involved in the problem: Start Emacs with emacs -Q, don't load Bookmark+, load whatever else you minimally might need to use pdf-tools, and try to access the PDF using the bookmark. Grepping tells me that the only use of "pdf" in Bookmark+ is in the default value of bmkp-default-handlers-for-file-types. So another thing you could try, after the first test, is to remove or change that association for *.pdf files, and they try using Bookmark+ again.
    – Drew
    Jul 26 at 23:25
  • @Drew I went a little further and did a package-delete of Bookmark+ to see what would happen. Now things work fine - I just jump to bookmarks with C-x r b instead. I'd like to keep the functionality of Bookmark+ though, so it would be nice to get it back. Jul 27 at 7:52
  • Thanks for the FYI. Please follow up using M-x bmkp-send-bug-report. Let me know your Emacs version and anything else relevant. Thx.
    – Drew
    Jul 27 at 18:06

1 Answer 1

1

After discussing this off-site, @Drew provided a workaround to add to one's config file

    (defun my-bmk-pdf-handler-advice (bookmark)
      (bookmark-default-handler (bookmark-get-bookmark bookmark)))

    (advice-add 'pdf-view-bookmark-jump-handler
            :after 'my-bmk-pdf-handler-advice)

with the explanation that

· In vanilla Emacs, function `bookmark--jump-via' invokes the relevant display function on the current buffer (the buffer reached by the bookmark). This is hard-coded.

· In Bookmark+ `bookmark--jump-via' doesn't do that - there's no hard-coded display of the destination buffer (there may not even be a destination buffer; jumping to a bookmark can do anything).

Instead, in Bookmark+ it's up to the particular handler for a bookmark to display (or not) the destination buffer (or anything else).

In Bookmark+ the default bookmark handler, function `bookmark-default-handler', does display the destination buffer. So if some particular handler wants that done it need only invoke the default handler when it want the display done (typically after doing its particular handling).

The problem seems to be this: The pdf-tools bookmark handler just uses set-buffer, which does nothing with respect to the display of a buffer. That function just makes a given buffer current, whether or not it's displayed anywhere and, even if it is displayed, regardless of how or where it's displayed. IOW, the PDF handler doesn't do any displaying.

The pdf-tools bookmark handler apparently depends on the buffer already being displayed. If so, the handler should ensure that it is (IMO). The PDF handler code currently apparently just tries to use the buffer of the currently `selected-window' if the destination buffer is not displayed.

As the creator/maintainer of Bookmark+, @Drew is looking into a more permanent solution to this and making the bookmark-jump-handler more consistent in its behavior, but this fix suffices for my needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.