Does anybody use org-roam to take notes on books?

I’m wondering if anyone here is using org-roam to take notes on books or articles e sense that you want to track key pieces of bibliographical data like author, subjects, date of publication, etc. If so, how do you track this metadata? How do you access/search by the metadata?

1 Like

A helper package org-roam-bibtex was designed specifically for that task. It allows you to seamlessly populate your note file with BibTeX data stored in a .bib file. Bibliography management is meant to be done with standard BibTeX tools though. As org-roam currently does not provide any generic mechanism to work with metadata of any kind, even the built-in tags, one has to use other tools such as Org searching facilities or grep to search for a specific piece of information.

Yes, org-roam-bibtex combined with org-ref is great. You can search your reference materials with using “meta data” you maintain in .bib file (BibTeX data, synced with Zotero, for instance) – see the screen shot below for org-ref screen.

I am assuming this is what you mean by “track key pieces of bibliographical data” and “access/search by metadata”?

You might find useful the discussion we have had recently, and my humble diagram that illustrates how these different applications work together.

1 Like

@nobiot this does look like what I was getting at. I will read up on the discussion you linked! I’m grateful that you have a working example.

I have done a config guide here ; no need to follow it, just for your information. Chapter 6 is about the packages above.

Yeah… that’s a great tool !

@nobiot I’ve almost set up the various tools for citation. org-roam-bibtex is pretty exciting. One problem I am having when setting it up is that when I configure the capture template, the slug field that is used to define the title doesn’t seem to expand, and instead I’m prompted for the slug when I run the template.

My understanding is that orb-slug-source is supposed to define the source for the slug as either the (bibtex) citekey or title. But for me these values aren’t getting pulled.

Here’s my template:

(defun ezfm-org-layer/init-org-roam-bibtex ()
  (use-package org-roam-bibtex
    :after org-roam
    :hook (org-roam-mode . org-roam-bibtex-mode)
    (setq orb-slug-source 'title)
    (setq org-roam-bibtex-preformat-keywords
          '("=key=" "title" "url" "file" "author-or-editor" "keywords"))
    (setq orb-templates
          '(("r" "ref" plain (function org-roam-capture--get-point) ""
             :file-name "${slug}_%<%Y%m%d%H%M%S>

- tags ::
- keywords :: ${keywords}

\n* ${title}\n  :PROPERTIES:\n  :Custom_ID: ${=key=}\n  :URL: ${url}\n  :AUTHOR: ${author-or-editor}\n  :END:\n\n"
             :unnarrowed t)))))

I wonder if you’ve run into this problem, or perhaps my expectation about the correct behavior is off.

@ethan I cannot reproduce the issue. Be sure to have the recent version of org-roam-bibtex installed. Also, the entry’s field title in your BibTeX file should not be empty. I myself have run into situations, where the entry’s title was in the field booktitle rather than title. This of course will make prompts to happen – title is required by org-roam. I will make booktitle (and other alternative fields) a legit title source some time later.

Please also note, that the template you provided, although syntactically correct, will not do what you want. You probably want your template stuff, starting with “- tags::” onward, in the :head section.

It clearly used to work, and I think I noticed the same thing recently. I just tried it and I am asked the slug when creating the notes file.

(Later) I edebugged it and found an issue. I reported it here

@brab Thanks a lot! It’s been fixed now. This must have been introduced in one of the more recent commits. I personally do not use orb-templates, so this bug has eluded me.

@ethan FYI.

1 Like

@mshevchuk I don’t know if it is related or something else I’ve done wrong in my setup, but after pulling the new version of org-roam-bibtex, I’m no longer prompted for the slug but I am prompted for =key=. Any thoughts?

I’ve noticed it as well but I have not had time to debug it.

I started to look at the code, but I’m starting from 0 so might take me a while to get oriented.

@ethan, @brab. Just use citekey instead of =key= in your templates. Or add =key= to orb-preformat-keywords. By default, orb-preformat-keywords contains citekey instead of =key= for several months now. The latter still works though, provided it’s in orb-preformat-keywords. Sorry, guys, ORB is still alpha and sudden changes may occur without a notice. You’ve been warned in the README anyway.

@ethan There is no need to look at the code, unless you are explicitly interested in it of course. Consult the README and the docstrings of the functions and variables in question. When in doubt, post a question here or, better, on Slack. I check them regularly and respond promptly.

Thank you, it works. I was using org-roam-bibtex-preformat-keywords instead of orb-….

Right, since a week or so the org-roam-bibtex- prefix , except for orb-roam-bibtex-mode, was dropped altogether; it was marked deprecated long before.

That was my problem as well, the old prefix for that variable. Another question. What would be the ideal way to extract just the author/editor’s last name? I was just gonna write a function in the config file to parse it from one of the other fields.

I did write a function:

(defun parse-last-name (author-or-editor-abbrev)
  (downcase (first (split-string author-or-editor-abbrev ","))))

But I can’t seem to find a place to use it. I thought I might be able to use it with orb-preformat-keywords:

(setq orb-preformat-keywords
      '("=key=" "title" "url" "file" "author-or-editor" "keywords" ))

No cigar. Any tips on a good way to go about this?

There are remote plans to improve name field handling with native functions that will offer more options than bibtex-completion does, but these plans are really remote.

You can however use Org Capture Elisp wildcard to achieve what you want. For example:

(setq orb-templates
          '(("r" "ref" plain (function org-roam-capture--get-point) ""
             :file-name "${slug}_%<%Y%m%d%H%M%S>"
             :head "author: %(parse-last-name \"${citekey}\")\n"
             :unnarrowed t)))))

You must then adjust your function to retrieve the author field from a BibTeX entry:

(defun parse-last-name (citekey)
  (let ((entry (bibtex-completion-get-entry citekey))
        (author-or-editor-abbrev (bibtex-completion-apa-get-value "author-or-editor-abbrev" entry)))
    (downcase (first (split-string author-or-editor-abbrev ",")))))

The Elisp processing is done by Org Capture, not ORB. But since ORB pre-expands the template, this string in your original template

"author: %(parse-last-name \"${citekey}\")\n"

will appear as

"author: %(parse-last-name \"Doe2020\")\n"

to org-capture.

Check how the function orb-process-file-field retrieves filenames. This is exactly what you want for authors.

1 Like

@mshevchuk I get an error when I try to use that function parse-last-name as written. I don’t understand why, though, because it looks right to me. Here’s the error:

parse-last-name: `let’ bindings can have only one value-form: entry, (bibtex-completion-get-entry citekey), author-or-editor-abbrev, (bibtex-completion-apa-get-value “author-or-editor-abbrev” entry)