org-roam / org-roam-bibtex

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

Creating a new note fails on "edit notes" in helm-bibtex #152

Closed sunnyhasija closed 3 years ago

sunnyhasija commented 3 years ago

Describe the bug When using helm-bibtex to find an article, and then edit-notes no new buffer is created to take notes on the file. To Reproduce Steps to reproduce the behavior:

  1. Run command helm-bibtex
  2. find the paper
  3. hit TAB to get actions available for paper
  4. hit f9 or edit-notes

Expected behavior A new buffer with the predefined capture template opens up. ORB configuration

  1. How the package is loaded
    (use-package! org-roam-bibtex
    :load-path "/media/sf_Dropbox/Org/references/library.bib" ;Modify with your own path
    :hook (org-roam-mode . org-roam-bibtex-mode)
    :bind (:map org-mode-map
         (("C-c n a" . orb-note-actions)))) 
  2. ORB options set to non-default values (e.g. orb-templates)

(setq orb-templates '(("n" "ref+noter" plain (function org-roam-capture--get-point) "" :file-name "${slug}" :head "#+TITLE: ${citekey}: ${title}\n#+ROAM_KEY: ${ref}\n#+ROAM_TAGS:

Environment (please complete the following information):

myshevchuk commented 3 years ago

(use-package! org-roam-bibtex :load-path "/media/sf_Dropbox/Org/references/library.bib" ;Modify with your own path :hook (org-roam-mode . org-roam-bibtex-mode) :bind (:map org-mode-map (("C-c n a" . orb-note-actions))))

Use-package's :load-path has nothing to do with your BibTeX library. It is used to specify the path to a package that was installed manually rather than through a package manager. Since you are using Doom, the package is installed with Straight package manager from MELPA (assuming you have properly declared org-roam-bibtex in your packages.el as per README), so the :load-path directive is absolutely redundant, and in your particular example may even be harmful leading to ORB not being initialized properly.

To be able to use your BibTeX library with ORB, you must configure bibtex-completion-bibliography:

(setq bibtex-completion-bibliography "/media/sf_Dropbox/Org/references/library.bib")

Then also make sure that other relevant packages (Org-mode, Org-roam, Bibtex-completion) are properly installed and loaded. For how to install and configure ORB, consult the README. It is pretty explicit that for Doom your minimum config should be:


;; If you installed via MELPA
(use-package! org-roam-bibtex
  ;; minimum config
  :after org-roam
  :hook (org-roam-mode . org-roam-bibtex-mode)
  ;; your private config
  :bind (:map org-mode-map
         (("C-c n a" . orb-note-actions))))
sunnyhasija commented 3 years ago

Thank you for your guidance @myshevchuk

Unfortuately I am still running into issues, and I cannot get it to work.

Here is the relevant parts of my config :

Org Roam
Fantastic package, the heart of my note taking. This is an implementation of the zettlekasten method inspired by Roam Research. Used in conjunction with `org-roam-bibtex` and `org-roam-server` is central to my workflow.
#+BEGIN_SRC elisp
; org-roam settings
(setq org-roam-directory "/media/sf_Dropbox/Org/references/notes")
(after! org-roam
        (map! :leader
            :prefix "n"
            :desc "org-roam" "l" #'org-roam
            :desc "org-roam-insert" "i" #'org-roam-insert
            :desc "org-roam-switch-to-buffer" "b" #'org-roam-switch-to-buffer
            :desc "org-roam-find-file" "f" #'org-roam-find-file
            :desc "org-roam-show-graph" "g" #'org-roam-show-graph
            :desc "org-roam-insert" "i" #'org-roam-insert
            :desc "org-roam-capture" "c" #'org-roam-capture))
(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.
#+END_SRC

** ORB : Org-Roam-Bibtex
This fantastic package allows me to use my bibtex file to create and take notes and store them in a zettlekasten.
#+BEGIN_SRC elisp
(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-bibliography "/media/sf_Dropbox/Org/references/library.bib")
(setq orb-templates
      '(("r" "ref" plain (function org-roam-capture--get-point) ""
         :file-name "${citekey}"
         :head "#+TITLE: ${citekey}: ${title}\n#+ROAM_KEY: ${ref}\n" ; <--
         :unnarrowed t)))
(setq orb-preformat-keywords   '(("citekey" . "=key=") "title" "url" "file" "author-or-editor" "keywords"))

(setq orb-templates
      '(("n" "ref+noter" plain (function org-roam-capture--get-point)
         ""
         :file-name "${slug}"
         :head "#+TITLE: ${citekey}: ${title}\n#+ROAM_KEY: ${ref}\n#+ROAM_TAGS:

- tags ::
- keywords :: ${keywords}
\* ${title}
:PROPERTIES:
:Custom_ID: ${citekey}
:URL: ${url}
:AUTHOR: ${author-or-editor}
:NOTER_DOCUMENT: %(orb-process-file-field \"${citekey}\")
:NOTER_PAGE:
:END:")))
#+END_SRC
** Helm-Bibtex
This is the jumping off point in my workflow inside emacs. The config gives the directory of where the PDFs are stored, where I want my notes to be stored, and where the Bibtex file is.
#+BEGIN_SRC elisp
(use-package! helm-bibtex
  :after org)

(setq
 bibtex-completion-pdf-field "File"
 bibtex-completion-bibliography '("/media/sf_Dropbox/Org/references/library.bib")
 bibtex-completion-library-path '("/media/sf_Dropbox/Zotero/")

 )
#+END_SRC

I have sequentially disabled and enabled all the three packages, and I cannot seem to get it to work. Any help would be really appreciated.

EDIT: Following is the relevant part of my packages.el

(package! org-roam-bibtex
  :recipe (:host github :repo "org-roam/org-roam-bibtex"))

;; When using org-roam via the `+roam` flag
(unpin! org-roam company-org-roam)

;; When using bibtex-completion via the `biblio` module
(unpin! bibtex-completion helm-bibtex)
(package! org-roam-server :recipe (:host github :repo "org-roam/org-roam-server" :files ("*")))
myshevchuk commented 3 years ago

You should change (setq orb-preformat-keywords '(("citekey" . "=key=") "title" "url" "file" "author-or-editor" "keywords")) to (setq orb-preformat-keywords '("citekey" "title" "url" "file" "author-or-editor" "keywords")).

Cons pairs are no longer supported within orb-preformat-keywords. That was a recent breaking change. Sorry for that, but ORB is still alpha. Field aliases can be set in orb-bibtex-field-aliases instead, the relation =key= - citekey is set by default.

myshevchuk commented 3 years ago

@sunnyhasija is your issue resolved?

sunnyhasija commented 3 years ago

Indeed is is solved, it took a while to figure it out, and I had to rebuild my config. The issue was arising from a multitude of differences, included but not limited to incorrect preformat-keywords and issues with upstream pdf-tools. Thanks for your helps @myshevchuk .

I am closing the issue, I wish you a happy new year!

myshevchuk commented 3 years ago

Thank you, happy new year!