org-roam / org-roam-bibtex

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

fix: (wrong-type-argument stringp nil) when adding a non-bibtex note #194

Closed rasendubi closed 3 years ago

rasendubi commented 3 years ago

When creating a non-bibtex note, it throws with the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("[\\\"]\\| " nil)
  #f(compiled-function (str) #<bytecode 0x334e725>)(nil)
  mapconcat(#f(compiled-function (str) #<bytecode 0x334e725>) (nil) " ")
  combine-and-quote-strings((nil))
  org-roam-add-property(nil "ROAM_REFS")
  (save-excursion (org-roam-add-property orb--current-citekey "ROAM_REFS"))
  orb--add-ref()
  run-hooks(org-roam-capture-new-node-hook)
  org-roam-capture--goto-location()
  org-roam-capture--get-point()
  org-capture-set-target-location(nil)
  org-capture(nil nil)
  org-roam-capture-(:node #s(org-roam-node :file nil :file-hash nil :file-atime nil :file-mtime nil :id nil :level nil :point nil :todo nil :priority nil :scheduled nil :deadline nil :title "hello" :properties nil :olp nil :tags nil :aliases nil :refs nil) :props (:finalize find-file :call-location #<marker at 129689 in README.org>))
  org-roam-node-find()
  funcall-interactively(org-roam-node-find)
  call-interactively(org-roam-node-find nil nil)
  command-execute(org-roam-node-find)

This happens because orb--current-citekey is nil but orb still tries to set it to ROAM_REFS.

Add a conditional check, so orb does not interfere with non-bibtex notes.

rasendubi commented 3 years ago

See also: https://github.com/org-roam/org-roam-bibtex/issues/193#issuecomment-882096317 — another possible fix is reverting https://github.com/org-roam/org-roam-bibtex/commit/c7f7cb0dc24d11b00ab5ce4de9705461fb1c5581

myshevchuk commented 3 years ago

Thank you, see #193.