emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
479 stars 53 forks source link

Allow citeproc to handle note title formatting #740

Closed bdarcus closed 1 year ago

bdarcus commented 1 year ago

We already allow this for copying formatted references; maybe we should extend this to elsewhere, most obviously note title formatting.

If yes, how to configure it?


Background

Currently, we have these relevant defcustoms:

  1. citar-format-reference-function: this specifies which function to use for citar-copy-reference and citar-insert-reference
  2. citar-templates is an alist of a symbol and a citar template string, which includes note and (for 1) preview templates.

So if you use citar-citeproc-format-reference for 1, you bypass 2.

Possible solutions

I'm not very fond of any of these, though lean towards 3, since it's the most flexible, and also fits with the new structure of citar-display-transform-functions:

  1. add a parallel citar-format-note-title-function to 1 above.
  2. add a :title property to the citar notes sources plist spec?
  3. modify citar-templates so that the cdr of the cons cells can either be a string (as now), or a function symbol; could maybe delete 1 above then? Something like:
  '((main . "${author editor:30%sn}     ${date year issued:4}     ${title:48}")
    (suffix . "          ${=key= id:15}    ${=type=:12}    ${tags keywords keywords:*}")
    (preview . (citar-citeproc-format-reference))
    (note . (citar-citeproc-format-reference "chicago.csl")))

Two had just occurred to me, but not sure it's ideal, as notes titles are more user-scoped, notes sources are more about clusters of functionality and packages.

Here's another possiblity, which may be cleaner?

(defcustom citar-format-functions
  "The default formatter is `citar-format--entry', which formats entries based on citar templates.

To use an alternate formatting function, include the symbol here, with the value being, in order:

* the symbol for the function
* any arguments (beyond the citekey)"
  `((note . (citar-citeproc-format-reference "apa.csl"))
    (preview . (citar-citeproc-format-reference "apa.csl"))))

Or maybe this should just be out-of-scope for this package, and room for other note packages that make use of citar?

bdarcus commented 1 year ago

Or maybe this should just be out-of-scope for this package, and room for other note packages that make use of citar?

This; I think everything is here for it to be easy for third-party packages to do this.

Trying to figure this out for citar-org-roam here:

https://github.com/emacs-citar/citar-org-roam/pull/25