org-roam / org-roam-bibtex

Org Roam integration with bibliography management software
GNU General Public License v3.0
568 stars 47 forks source link

Support `bibtex-actions-file-parser-functions` from bibtex-actions for file entry parsing #213

Closed ghost closed 2 years ago

ghost commented 2 years ago

bibtex-actions uses bibtex-actions-file-parser-functions to hold a list of functions that can be used for parsing file entries in bib file, there are functions like bibtex-actions-file-parser-default, bibtex-actions-file-parser-zotero and bibtex-actions-file-parser-calibre for parsing different file entry styles.

I use org-noter and the same config in ORB's manual, bug it seems ORB can't get the value for {file} key when using bibtex-actions. To solve this issue I found that I have to convert the file entries to bibtex-completion's tyle , and define a correspoding parser function.

  (defun bibtex-actions-file-parser-bibtex-complition (dirs file-field)
    "Return a list of files from DIRS and a bibtex-completion formatted FILE-FIELD."
    (let ((parts (split-string file-field ";" 'omit-nulls)))
      (seq-mapcat
       (lambda (part)
         (let ((fn (car (split-string part ":PDF" t ":"))))
           (mapcar (apply-partially #'expand-file-name fn) dirs)))
       parts)))

  (setq bibtex-actions-file-parser-functions '(bibtex-actions-file-parser-bibtex-complition))

It would be nice to have ORB support bibtex-actions parser functions.

myshevchuk commented 2 years ago

Please describe the bug in more detail, what exactly is not working in ORB?

I'm not sure I understand why and how should ORB support Bibtex-actions.

Do you want ORB to use Bibtex-actions as a backend to fetch file names from a BibTeX entry instead of Bibtex-completion?

ghost commented 2 years ago

Sorry, my bad ,the title should really just be "orb-bibtex-actions-edit-note can't get ${file} key value".

After debugging for hours, I conclude its my config that caused this problem :weary:, I forget to config bibtex-completion , since bibtex-actions actually almost don't depend on bibtex-completion now, after I set (setq bibtex-actions-bibliography bibtex-completion-bibliography) the issue is gone.