org-roam / org-roam-bibtex

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

New note creation fails when calling `org-roam-ref-add` (v2) #193

Closed benide closed 3 years ago

benide commented 3 years ago

Describe the bug While creating a new note, org-roam-ref-add fails by attempting to call (goto-char nil). The nil is returned from (org-roam-node-point node). The buffer for the new note does exist, with the only thing missing being the :ROAM_REFS: cite:... line. Attempting to manually call org-roam-ref-add in this buffer fails as well, but works after saving the buffer to a file.

This only happens after the behavior of org-roam-node-at-point was changed in the org-roam commit 409a147. I'm not sure if this is an org-roam bug, or if it's just something ORB needs to change to keep up with the new v2 stuff.

To Reproduce With org-roam-bibtex-mode enabled, create a new note with org-ref.

It can also be reproduced by running (orb--new-note "some_valid_key").

Expected behavior Creating a new note should successfully add a roam ref to the properties of the new node.

ORB configuration

(use-package org-roam-bibtex
  :straight (:host github :repo "org-roam/org-roam-bibtex" :branch "org-roam-v2")
  :demand t
  :after org-roam
  :custom
  (orb-insert-interface 'helm-bibtex)
  (orb-note-actions-interface 'helm)
  :config
  (add-to-list 'orb-preformat-keywords "year")
  (add-to-list 'org-roam-capture-templates
           '("r" "bibliography reference" plain
         "%?"
         :if-new (file+head "refs/${citekey}.org"
                    "#+title: ${title} (${year})\n")
         :immediate-finish t
         :unnarrowed t))
  (org-roam-bibtex-mode))

Environment (please complete the following information):

myshevchuk commented 3 years ago

Hi,

thank you very much for the detailed info and for actually pinpointing the commit that has introduced this behaviour. Indeed, Org-roam commit 409a147 has made some changes, which break inserting a reference in a newly created note that has not been cached in the database yet.

I've provided and independent fix for that, so the things should work now.

benide commented 3 years ago

I guess Jethro fixed it on the org-roam end as well. In any case, everything is working as expected. Thanks!

myshevchuk commented 3 years ago

Good!

benide commented 3 years ago

I guess I spoke too soon, I am getting weird behavior when doing a roam-ref capture with both org-roam/org-roam#1401 being merged and ORB commit c7f7cb0. 5344331 works just fine, so I guess reverting c7f7cb0 like you mentioned in the commit message is all that needs done.

Thanks for keeping this up to date with v2!

benide commented 3 years ago

@rasendubi, is #194 still needed if you use 5344331?

rasendubi commented 3 years ago

Yeah, the bug only exists on org-roam-v2 branch

On Sun, Jul 18, 2021, 21:14 Ben Ide @.***> wrote:

@rasendubi https://github.com/rasendubi, is #194 https://github.com/org-roam/org-roam-bibtex/pull/194 still needed if you use 5344331 https://github.com/org-roam/org-roam-bibtex/commit/5344331ff828729a815e8bb36bd46bcbd444ee9e ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/org-roam/org-roam-bibtex/issues/193#issuecomment-882097273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKNTE25W3MTPMUD346SRXDTYMKZTANCNFSM5AKE3V6Q .

rasendubi commented 3 years ago

Sorry. Didn’t get the full context from the mail. I was using org-roam-bibtex at c7f7cb0dc24d11b00ab5ce4de9705461fb1c5581 and org-roam-20210717.1454. So yeah, I suppose 5344331 should work fine without #194 because the patched function did not exist before c7f7cb0.

Edit: Tested 5344331 with org-roam-v2 and it works fine for me.

myshevchuk commented 3 years ago

Thanks guys, I reverted that buggy temporal fix. The org-roam-v2 has been merged into master.