helm-bibtex
helm-bibtex copied to clipboard
Allow additional functions for format entry
This is a feature request, not a bug report.
We customize the completion display format using bibtex-completion-display-formats
. For example, these templates can take additional fields by supplying the same fields in bibtex-completion-additional-search-fields
and then use them.
Sometimes, we want to perform additional formatting on field values, but there is currently no hook to do this. The author
and year
field are exceptions, as their fallback fields, editor
and date
are defined, respectively, in case they are missing. In case of author
, additional preprocessing such as shortening author names is performed.:
https://github.com/tmalsburg/helm-bibtex/blob/78f5931e1cc82e7ae2bcf0508cf31d0d1629a8dd/bibtex-completion.el#L864-L898
I think that it would be nice to be able to write custom field formatters. For example, bibtex-completion-field-formatters
would take a list of (field . formatter-function)
such that the formatter-function taking entry
as an argument gets applied before rendering the value.
Would that be a possibility? This seems like relatively low-lift work that would make the template format vastly more flexible.
It would be relatively easy to add some ad-hoc solution, but the truth is that a lot of the relevant code has organically grown and is not super easy to maintain and extend. It would be best to refactor this part of bibtex-completion, perhaps with some sort of plugin infrastructure that allows users to choose between different formatting / display styles. Not sure what this would look like in detail. But feel free to propose something specific and we can discuss it.