org-roam-bibtex
org-roam-bibtex copied to clipboard
File Field in ORB
Describe the bug
The {file}
keyword is not able to generate the filename of the pdf in the capture template. It shows up for some "notes" but not for other.
To Reproduce
EDIT Notes
in helm BibTeX
Expected behavior The file name shows up in the capture template, which can then be used for org-noter
ORB configuration
;; ORG-ROAM
;;
(use-package org-roam
;:ensure t
:hook
(after-init . org-roam-mode)
:custom
(org-roam-directory "/home/cantos/Dropbox/Org/references/notes/")
:bind (:map org-roam-mode-map
(("C-c n l" . org-roam)
("C-c n f" . org-roam-find-file)
("C-c n g" . org-roam-graph))
:map org-mode-map
(("C-c n i" . org-roam-insert))
(("C-c n I" . org-roam-insert-immediate))))
(after! org-roam
(setq org-roam-ref-capture-templates
'(("r" "ref" plain (function org-roam-capture--get-point)
"%?"
:file-name "websites/${slug}"
:head "#+TITLE: ${title}
#+ROAM_KEY: ${ref}
- source :: ${ref}"
:unnarrowed t)))) ; capture template to grab websites. Requires org-roam protocol.
(use-package! org-ref
:after org
:init
; code to run before loading org-ref
:config
; code to run after loading org-ref
)
(setq org-ref-notes-directory "/home/cantos/Dropbox/Org/references/notes"
org-ref-default-bibliography '("/home/cantos/Dropbox/Org/references/library.bib")
org-ref-pdf-directory "/home/cantos/Dropbox/Zotero")
(use-package! helm-bibtex
:after org
:init
; blah blah
:config
;blah blah
)
(setq bibtex-format-citation-functions
'((org-mode . (lambda (x) (insert (concat
"\\cite{"
(mapconcat 'identity x ",")
"}")) ""))))
(use-package! org-roam-bibtex
:hook (org-roam-mode . org-roam-bibtex-mode)
:bind (:map org-mode-map
(("C-c n a" . orb-note-actions))))
(setq
bibtex-completion-pdf-field "file"
bibtex-completion-bibliography
'("~/Dropbox/Org/references/library.bib")
bibtex-completion-library-path '("~/Dropbox/Zotero")
)
(setq orb-preformat-keywords
'("citekey" "title" "url" "author-or-editor" "keywords" "file")
orb-process-file-field t
orb-process-file-keyword t
orb-file-field-extensions '("pdf"))
(setq orb-templates
'(("n" "ref+noter" plain (function org-roam-capture--get-point)
""
:file-name "${citekey}"
:head "#+TITLE: ${citekey} \n#+SUBTITLE: ${title}\n#+ROAM_KEY: ${ref} \n #+ROAM_TAGS:
- tags ::
- keywords :: ${keywords}
\* ${title}
:PROPERTIES:
:Custom_ID: ${citekey}
:URL: ${url}
:AUTHOR: ${author-or-editor}
:NOTER_DOCUMENT: ${file}
:NOTER_PAGE:
:END:")))
Environment (please complete the following information):
- ORB commit or MELPA package version
- Org Roam commit or MELPA package version
- Org Mode version
- Emacs framework Doom
- Emacs version 27.1
- OS: Fedora 33
Hi, the following assumes you are using the most recent version of ORB. If not, please upgrade.
-
Could you please check if there is a
*Warnings*
buffer and if there are any warnings/errors produced by ORB. -
Are you actually able to open these attachments in
helm-bibtex
, e.g.,F2 Open PDF, URL or DOI
?
- it is the latest version of ORB. EDIT: Also no warnings buffer.
- Emacs went unresponsive when I tried to open the PDF via
helm-bibtex
.
2. Emacs went unresponsive when I tried to open the PDF via
helm-bibtex
.
You should investigate what's wrong with this BibTeX entry, why helm-bibtex
cannot open the file. When processing the file field, ORB uses bibtex-completion
to retrieve the filename. This is useful when you have several files associated with an entry, or when you don't have the file field in your BibTeX entries but rather rely on naming conventions and bibtex-completion-library-path
. I suggest you to read helm-bibtex
docs for more details. In short, it doesn't seem to be ORB's issue. If helm-bibtex
fails, ORB will do exactly what it has been told to do - fail.
If you don't want this special file field handling, you can set orb-process-file-keyword
to nil
. The ${file}
keyword will then behave as any other ordinary keyword - the wildcard will be expanded with whatever the value in the entry's file field.
Also note that there is no such variable orb-process-file-field
anymore. It was renamed to orb-process-file-keyword
, so you can safely remove it from your config.
I have something related here. I use zotero's betterbibtex export. Upon capturing with template include ^%{file}, if the file field has snapshot and in that format
file = {filename.pdf:home/filename.pdf:application/pdf;Snapshot:/home/user/Zotero/storage/2123-2323-42323.html:text/html}
It will work fine. However for entries without snapshots, it will not work!
file = {filename.pdf:home/filename.pdf:application/pdf}
@OAshkar ORB uses an external library, bibtex-completion
, to get the filename. I've encountered myself peculiar issues with filename retrieval but since I use plain filenames like file = {/path/to/file.pdf}
and this works just fine, I didn't investigate it in detail.
You can check whether opening such files works in helm-bibtex
or ivy-bibtex
(it likely doesn't) and submit a bug report here: https://github.com/tmalsburg/helm-bibtex
@myshevchuk I found the problem using your syntax of file name. That solves my issue.