org-capture-ref-jami-bot: Capturing bibliography entries while on the road
Published on Apr 16, 2023.
Let us get a little more fancy than the simple captures of the previous post: capturing bibliographic references (or simply interesting links).
I often find myself getting excited about projects, blogs and (scientific) articles I discover while surfing or scrolling through Mastodon on my mobile phone. So I keep the tab open in my browser, which usually already shows “∞” instead for the number of open tabs. But usually I want to come back to these pages in a different context: when I am at my computer. Firefox Sync helps, but requires additional steps or managing bookmarks in a tedious interface – I really just want to put the link with some tag where it belongs: in my Org mode notes!
So I use jami-bot
and org-capture-ref
to send myself the link with a list of
tags via the Jami messenger. org-capture-ref
collects meta data and stores it
to an inbox org file. If the link is to an article in a scientific journal or
similar citeable resource, the meta data will be quite extensive as long as the
publisher is supported by org-capture-ref
. In either case, the captured entry
will contain a source block with BibTeX information which can be tangled into a
bib file and used e.g. with citar
or org-ref
. For an extensive example on
how to configure org-capture-ref
, see the online documentation. And see
the previous post on org-jami-bot
for a more detailed run-down of the
configuration of jami-bot
.
To be able to trigger a capture via Jami, I define the following function:
(defun jami-bot--command-function-url (account conversation msg) "Capture a URL and tag it with any words immediately following the command. Captures a single URL in MSG using `org-capture-ref-capture-url'. The entry will be tagged with any words on the first line of the message immediately following the command string. Tags should be separated by spaces." (let* ((body (cadr (assoc-string "body" msg))) (lines (string-lines body)) (tags (split-string (car lines))) (url (string-clean-whitespace (string-join (cdr lines))))) (let ((org-capture-ref-headline-tags (append org-capture-ref-headline-tags tags))) (org-capture-ref-capture-url url)) "captured url!"))
Now add this function to the list of commands known by jami-bot
and map it to
trigger on messages starting with !url
:
(add-to-list 'jami-bot-command-function-alist '("!url" . jami-bot--command-function-url))
Now any message such as “!url https://hoowl.se” will be captured immediately via org-capture-ref
!
Note that the Jami app on Android (as of today) has the strange behavior of deleting any pre-existing text in the message composing field if one pastes anything into it – so be sure to paste first, then add command and tags! This seems to be fixed now!
Have fun 😺