citar
citar copied to clipboard
embark-related parsing problems when multiple citekeys
Am unsure why this would turn up as a bug at this point, given how many people use this package, and how long that code has been stable.
I ran into one more issue, which I thought I would like to report here. It affects multiple functions in the citar-citation-map
, and has to do with the way they interact with citar-citation
targets and citar-embark
package.
Let me explain the problem by taking citar-copy-reference
function as a specific example. This function accepts a list of citekeys, whose formatted references are to be inserted in the current buffer. When it receives its argument from citar--select-multiple
or via an embark action on a citar-key
target, all works well. But if the argument is from a citar-citation
target with multiple keys, then citar-copy-reference
fails to find the relevant bibliography entries.
I believe, the reason is that a citar-citation
target produces a string obtained by concatenating individual keys with the " & "
separator as done by the citar--stringify-keys
function. Thus citar-copy-reference
needs to unstringify the keys first, but its current implementation does not do this.
To give a concrete example, if citar-copy-reference
is applied to the citar-citation
target that corresponds to the LaTeX citation \cite{key1,key2}
, then its argument becomes ("key1 & key2")
instead of ("key1" "key2")
.
The problem can be fixed by unstringifying the argument first, e.g., by pre-processing it as follows:
(setq citekeys (mapcan #'citar--unstringify-keys citekeys))
The same issue, in fact, applies to functions citar-open
, citar-open-links
, citar-open-files
, and citar-open-notes
, each of which fails, in my case at least, to act on a citar-citation
target with multiple keys.
Originally posted by @kslutsky in https://github.com/emacs-citar/citar/issues/834#issuecomment-2196233740