#+title: Deref

Barebones reference manager using Denote and BibTeX.

Opinionated in places.

* Association

Deref works by adding specially formatted comments to the BibTeX bibliography.
It imagines a general /magic comment/ format like:

: %:<key>:[val]

and uses two magic comment keys.
Users need not manipulate magic comments themselves, but they may.

A magic comment is valid if and only if

1. It precedes another valid magic comment, or
2. It precedes a BibTeX entry

with no intervening empty lines.

** =denote-note=

Takes a value that's the filename of the primary note for this reference.

** =denote-media=

Takes a value that's the filename of a media file for this reference.
It can be specified multiple times.
For instance, a book might have both a PDF and an EPUB file.

* Usage

To manage references with Deref, manually maintain a BibTeX bibliography and point ~deref-bibliography~ to it.
Also populate ~deref-media-directory~.

** BibTeX mode commands

*** ~deref-note~

Create a Denote note corresponding to the BibTeX entry under point, and open it.
Associate the note with the entry.

With a prefix argument, associate an existing file and do not open it.

*** ~deref-media~

Associate an existing file with the BibTeX entry.
If the file lacks a Denote identifier, rename it as a Denote file and move it to ~deref-media-directory~.

*** ~deref-dired~

Open a Dired listing of all note and media files associated with the BibTeX entry under point.

** Global commands

*** ~deref-go-bib~

Jump to the first BibTeX entry in the bibliography associated with the current Denote file.
