Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes and PDF symbols not appearing in helm-bibtex #451

Open
Phil2740 opened this issue Nov 2, 2024 · 4 comments
Open

Notes and PDF symbols not appearing in helm-bibtex #451

Phil2740 opened this issue Nov 2, 2024 · 4 comments

Comments

@Phil2740
Copy link

Phil2740 commented Nov 2, 2024

Hi,
I use a Mac Mini computer with Mac OS 14.7 and Emacs 29.3.

I assigned values for bibtex-completion-bibliography, bibtex-completion-notes-path, and bibtex-completion-library-path with a .dir-locals.el file, which looks like this:

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((nil . ((bibtex-completion-library-path . "/Users/user1/Library/CloudStorage/Dropbox/reading/book-pdfs")
           (bibtex-completion-notes-path . "/Users/user1/Library/CloudStorage/Dropbox/reading/book-notes")
         (bibtex-completion-bibliography . "/Users/user1/Library/CloudStorage/Dropbox/reading/books-read.bib"))))

If I now call up helm-bibtex the bibliography appears, but the notes and PDF symbols do not.

I looked at what was in the bibtex-completion-cache for a typical Bibtex entry, that I know has a note and a PDF, here is what it looks like:

 ("gioia 2003 The Last Days of Socrates Plato book plato2003  "
   ("keywords" . "gioia")
   ("date" . "2003")
   ("title" . "The Last Days of Socrates")
   ("author" . "Plato")
   ("=type=" . "book")
   ("=key=" . "plato2003"))

If I now assign these variables in my init.el file the same BibTeX entry looks like this:

 ("✎ ⌘ gioia 2003 The Last Days of Socrates Plato book plato2003 =has-pdf= =has-note="
   ("=has-note=" . #1#)
   ("=has-pdf=" . #2#)
   ("keywords" . "gioia")
   ("date" . "2003")
   ("title" . "The Last Days of Socrates")
   ("author" . "Plato")
   ("=type=" . "book")
   ("=key=" . "plato2003"))

The commentary for the function bibtex-completion-prepare-entry notes that "ENTRY is an alist representing an entry as returned by parsebib-read-entry", but as far as I can tell, parsebib.el doesn't know about notes and PDFs. I can't tell from reading through the code for bibtex-completion.el how =has-note=, =has-pdf= and symbols get into the cache.

Something is missing from .dir-locals.el file but I don't know what. Are you able to suggest a solution to this problem?

Thanks in advance for your help.

@tmalsburg
Copy link
Owner

How do you link entries to PDFs? One way is to reference the PDF in the BibTeX entry using the file field. Another is to store the PDF under the name key.pdf, so in your example plato2003.pdf. Similar for notes which need to be named key.org so e.g. plato2003.org. See here for details.

@Phil2740
Copy link
Author

Phil2740 commented Nov 5, 2024

Thanks for taking time to answer my query. I understand what you are saying about linking to a PDF using the file field.
But my query is this: I want to set up helm-bibtex to operate by setting variables bibtex-completion-bibliography, bibtex-completion-notes-path, and bibtex-completion-library-path in a .dir-locals.el file. I want to do this because I have several projects, each with its own directory and one or more bibtex files. When I want to change projects I have been editing my init.el for the new project. This is the step that I want to eliminate.
What I do not understand is if I set these variables in a .dir-locals.el file, note and PDF symbols do not appear in the helm-bibtex buffer. In the Plato example, I know that there is a plato2003.org file in the note path, and that there is a plato2003.pdf in the library path. Why don't note and PDF symbols appear against the plato2003 entry in the helm-bibtex buffer?
The problem seems to be with the creation of the bibtex-completion-cache. If I set variables with a .dir-locals.el file symbols, =has-note= and has-pdf= do not appear in the cache. If I set these variables from my init.el file symbols, =has-note= and has-pdf= appear in the cache. I don't understand enough about Emacs Lisp to figure out how bibtex-completion.el assigns values to =has-note=, =had-pdf= and adds these variables, with symbols, to the cache.
What am I missing?
On there other hand, if you can suggest a method by which I could set up helm-bibtex to run in different directories that does not involve editing an init.el file I would be delighted to hear it.

@tmalsburg
Copy link
Owner

tmalsburg commented Nov 5, 2024

Ah, got it. I'm not familiar with dir-locals but your approach looks reasonable. It should not be necessary to set other variables. You can force a reload (by-passing the cache) with a prefix argument to helm-bibtex C-u M-x helm-bibtex RET. Could you please try that?

@Phil2740
Copy link
Author

I've tried C-u M-x helm-bibtex many times. Symbols still don't show up.
If I check the value of bibtex-completion-library-path with C-h v its value is correct, and I am told that it is local in the buffer but that its global value is nil.
I wondered whether a nil global value was important, turns out that it could be.
If I set the value of bibtex-completion-bibliography in a .dir-locals.el file, and the value of bibtex-completion-library-path in my init.elfile, thereby rendering it global, PDF symbols appear ion the helm-bibtex buffers.
This would seem to imply that somewhere there is a directory (or maybe a buffer?) that is not the reading directory, or any of its sub-directories. I can't, for the life of me, see any other directories in the code for helm-bibtex.el, bibtex-completion.el or parsebib.el.
Are you able to say what is happening here?
I suppose that, if I set the value of bibtex-completion-notes-path in a similar way, I'd get a similar result, but I haven't tried that yet. One step at a time.
This finding would also imply that I could store my PDFs for all projects in one massive directory, and notes similarly. But this is something I'd rather not do.
I apologise for labouring this issue, but I'd really like to crack it.
Thanks once more for your assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants