tmalsburg/helm-bibtex

`bibtex-completion-open-pdf` undefined

Closed this issue · 10 comments

I am trying opening the pdf file associated with a bibtex entry within a .bib file but bibtex-completion-open-pdf is undefined. Following the relevant comment, the version of Emacs are GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) of 2020-08-22 and GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.15.10) of 2021-01-29. Emacs is started by running emacs.exe -Q for the Windows version or emacs -Q for the Linux version. MELPA is added by running the relevant elisp statements in *scratch*. Then helm-bibtex is installed by M-x package-refresh-contents and M-x package-install helm-bibtex, and is configured by running the two following elisp statements in *scratch* via C-x C-e after the parentheses, respectively.

(setq bibtex-completion-bibliography         '("~/dropbox/ref/references.bib")
      bibtex-completion-library-path         '("~/dropbox/ref/exp" "~/dropbox/ref/theor")
      bibtex-completion-pdf-field            "File"
      bibtex-completion-find-additional-pdfs t
      bibtex-completion-notes-path             "~/dropbox/ref/references.org"
)
(require 'helm-bibtex)

Within a .bib file, if I type M-x bibtex-completion and press tab twice, the completion only shows the following

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
bibtex-completion-exit-notes-buffer
bibtex-completion-notes-global-mode
bibtex-completion-notes-mode

If I type M-x helm-bibtex and press tab twice only the following is shown

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
helm-bibtex
helm-bibtex-with-local-bibliography
helm-bibtex-with-notes

If I type M-x helm-bibtex and press RET the list of references are shown.

Could you suggest why bibtex-completion-open-pdf is undefined ?

This issue is wrong, because the reason why 'M-x' does not suggest bibtex-completion-open-pdf is the function is not for interactive usage. Sorry for the trouble...

To open the .pdf file associated with a bibtex entry within a .bib file

  1. Place the cursor within the entry,
  2. Type M-x helm-bibtex,
  3. Press TAB to show the action menu (the shortcut in the square brackets can be used instead of 3 and 4)
  4. Choose Open PDF, URL or DOI, and the .pdf file will be opened if there is only one of them.
  5. If there are multiple .pdf files, the mini-buffer will wait for the full name. Press TAB to auto-complete the most part of the name and type to fill in the rest of the name, and press RET to open the .pdf file.

To open the .pdf file associated with a bibtex entry within a .bib file with a key binding

   ; [[https://github.com/tmalsburg/helm-bibtex/issues/121][Open PDF for bib entry containing point]] and 
   ; [[https://github.com/tmalsburg/helm-bibtex/issues/169][wrap bibtex-key-in-head with the list function]]
   (defun bibtex-completion-open-pdf-of-entry-at-point ()
      (interactive)
      (save-excursion
         (bibtex-beginning-of-entry)
         (when (looking-at bibtex-entry-maybe-empty-head)
            (bibtex-completion-open-pdf (list (bibtex-key-in-head)) ) ) ) )
   ; [[https://github.com/plantarum/bibtex-utils][bind the function to a key]]
   (eval-after-load 'bibtex
      '(define-key bibtex-mode-map (kbd "H-p") 'bibtex-completion-open-pdf-of-entry-at-point))

I am trying to follow these instructions, but it does not work for me. When I follow this, I get a notification saying that a pdf files will be open, and then some images related to Mac are opened.
I am running on a Mac, with emacs doom distribution.
(This used to work, but I did not use it for some time, and I am not sure why it does not work anymore).

I'm not sure what the problem is. Could you please provice a reprodicuble example, i.e. the precise steps for reproducing the problem? Thank you.

Sure.
I am trying to open the pdf from within on org document.
I am retracing this steps exactly:

  1. Place the cursor within the entry,
  2. Type M-x helm-bibtex,
  3. Press TAB to show the action menu (the shortcut in the square brackets can be used instead of 3 and 4)
  4. Choose Open PDF, URL or DOI, and the .pdf file will be opened if there is only one of them.
  5. If there are multiple .pdf files, the mini-buffer will wait for the full name. Press TAB to auto-complete the most part of the name and type to fill in the rest of the name, and press RET to open the .pdf file.

At this point I get the following message:
Screen Shot 2021-07-13 at 12 09 51
If I click "continue" then I get some system pdfs opening (these are some apple system images). When I click "cancel" I get a pop-up for opening a pdf file. But this pop up does not point to the right location of the refrence I chose.
The bib file I have is generated and updated using zotero betterbibtex.
Perhaps the problem is there?

(I am sorry if this is still not clear - please tell me in case, and I will try to explain better).

That's much clearer. Could you please also show the BibTeX entry in question?

Sure. Oh! now I see the problem.
The file is pointing to a hard coded location that is true for my desktop at work. This is why it can't find it!
I would need to somehow change /Users/roiho/Zotero/ to ~/Zotero/ so it will work on both computers.
So I need to figure out how to do that.

@article{cuberoMultiscaleRelevanceInformative2019,
  title = {Multiscale Relevance and Informative Encoding in Neuronal Spike Trains},
  author = {Cubero, Ryan John and Marsili, Matteo and Roudi, Yasser},
  year = {2019},
  month = dec,
  abstract = {Neuronal responses to complex stimuli and tasks can encompass a wide range of time scales. Understanding these responses requires measures that characterize how the information on these response patterns are represented across multiple temporal resolutions. In this paper we propose a metric \textendash{} which we call multiscale relevance (MSR) \textendash{} to capture the dynamical variability of the activity of single neurons across different time scales. The MSR is a non-parametric, fully featureless indicator in that it uses only the time stamps of the firing activity without resorting to any a priori covariate or invoking any specific structure in the tuning curve for neural activity. When applied to neural data from the mEC and from the ADn and PoS regions of freely-behaving rodents, we found that neurons having low MSR tend to have low mutual information and low firing sparsity across the correlates that are believed to be encoded by the region of the brain where the recordings were made. In addition, neurons with high MSR contain significant information on spatial navigation and allow to decode spatial position or head direction as efficiently as those neurons whose firing activity has high mutual information with the covariate to be decoded and significantly better than the set of neurons with high local variations in their interspike intervals. Given these results, we propose that the MSR can be used as a measure to rank and select neurons for their information content without the need to appeal to any a priori covariate.},
  archiveprefix = {arXiv},
  eprint = {1802.10354},
  eprinttype = {arxiv},
  file = {/Users/roiho/Zotero/storage/MR4IFKPR/Cubero et al. - 2019 - Multiscale relevance and informative encoding in n.pdf},
  journal = {arXiv:1802.10354 [q-bio]},
  keywords = {Quantitative Biology - Neurons and Cognition,Quantitative Biology - Quantitative Methods},
  language = {en},
  primaryclass = {q-bio}
}

I fixed that issue by simply having my bib file not in my dropbox folder. Thus I have a different file on each computer.

However, after I do helm-bibtex I simply get a list of all of my references, sorted alphabetically. Then I need to search for the reference I am interested in. Isn't there a way to automatically point on the reference from which I entered helm-bibtex?

If you cursor is on a BibTeX entry (in a .bib file), the entry should be automatically pre-selected (if that .bib file is in bibtex-completion-bibliography).

oh, now I see my confusion. I am in an org file, and the cursor is on a link of the form cite:the-name-of-the-ref. I thought that there is a way to open the pdf straight from there. (At least I recall that this was possible in the past).

Helm-bibtex doesn't support this but I think org-ref adds that feature. So I recommend checking there.