notes from /dev/null

by Charles Choi 최민수


Storing a Link from your Web Browser to BibTeX using Org protocol

25 Sep 2025  Charles Choi

If you’re familiar with this blog, you’ll know that I’m a fan of Org protocol, a means of sending data such as web links and content to an Org file from outside of Emacs. Following up on my last post on Casual BibTeX, this post will show how to re-purpose Org protocol to send a link from your preferred web browser to a BibTeX file.

This is achieved by adding the following template (named “bib”) to the variable org-capture-templates as shown below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
(add-to-list org-capture-templates
             '("bib"
               "BibTex Online Entry"
               plain
               (file "~/org/bib/references.bib")
               (function (lambda ()
                           (string-join
                            (list "@Online {,"
                                  "author = {%^{Author(s)}},"
                                  "organization = {%^{Organization}},"
                                  "title = {%:description},"
                                  "url = {%:link},"
                                  "date = {%<%Y-%m-%d>%?},"
                                  "notes = {"
                                  "%i"
                                  "}"
                                  "}")
                            "\n")))
               :prepend t
               :empty-lines-after 1))

The web link is treated as an BibTeX Online entry type whose fields are populated as follows:

  • url field holds the web page link.
  • title field holds the web page title.
  • date is populated with the current day (this should be edited to the actual date).
  • notes is populated with the body value according to the capture protocol.
  • author is populated with the value entered via mini-buffer prompt.
  • organization is populated with the value entered via mini-buffer prompt, typically the name of the website.

The template is configured to prepend (via the :prepend property) the captured Online entry to the file “~/org/bib/references.bib”. These values can be adjusted to taste.

When invoking this template via Org protocol, a temporary capture window holding the populated template is created. This entry will not have a citation key, so it is recommended to run M-x bibtex-clean-entry to generate it before committing the capture via C-c C-c. If you have Casual BibTeX installed, you can invoke the Transient menu casual-bibtex-tmenu with the binding M-m and invoke the clean command from there.

Closing Thoughts

Arguably, Org protocol was not designed to support files other than those using Org markup, so the above practice skirts its design intent by sending the capture to a BibTeX file. But as of Emacs 30.2 and Org 9.7.34, this works fine, so YOLO. Users intent on customizing the above “bib” template should be advised that many template properties are not supported, so be advised.

That all said, it’s a nice win to automate the task of writing a BibTeX Online entry.

emacs   org mode

 

AboutMastodonBlueskyGitHub

Feeds & Tags
Get Scrim for macOSGet Captee for macOS

Powered by Pelican