-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
embark-related parsing problems when multiple citekeys #835
Comments
EDIT: Confirmed. Now that I look, As I say in the preface above, it's just surprising to me to see this, what appears to be silly, bug at this point :-) But I also know we sometimes struggled with Are we missing something @roshanshariff? Assuming no, I'm unsure of how to fix those interactive commands ATM. In particular, where would one do:
Lines 1527 to 1536 in 07d2a63
|
I think this is indeed a vestige of when Embark removed the I don't have all the details in mind right now, but maybe we can deal with this in |
My point was simply that adding (defun citar-open (citekeys)
"Open related resources (links, files, or notes) for CITEKEYS."
(interactive (list (citar-select-refs)))
;; The following line can be added to unstringify citar-citation targets
(setq citekeys (mapcan #'citar--unstringify-keys citekeys))
(pcase (let ((embark-default-action-overrides
... (This is just a way to test the source of the issue, and I didn't mean to suggest that inserting such preprocessing calls into all multitarget actions is a good idea from the architectural standpoint.) |
Thanks @kslutsky - yes, I was effectively meaning how to modify |
A different possibility would be to advise functions in the (defun citar-embark--unstringify-args (citekeys)
(list (mapcan #'citar--unstringify-keys (car citekeys)))) then ...
;; Unstringify arguments of all multitarget actions
(dolist (function citar-embark--multitarget-actions)
(advice-add function :filter-args #'citar-embark--unstringify-args))
(cl-callf cl-union embark-multitarget-actions citar-embark--multitarget-actions)
... whereas (dolist (function citar-embark--multitarget-actions)
(advice-remove function #'citar-embark--unstringify-args)) (Since |
Related to #837 also. |
Why would we advise internal functions, @kslutsky? |
Multitarget actions receive as their argument either a list of keys or a string of keys produced by the I have a feeling, however, that I am missing the crux of your question, @bdarcus. |
Really it was just my understanding that one only should ever need to advise external functions, since we have control over our own code. Does that clarify? |
Well, when we deal with an individual internal function, I would agree that it is typically better either to modify its code or to introduce a wrapper function. In the issue at hand, however, we want to apply the same modification to a whole list of functions. Advising seems to be perfectly suited for this job. Among other things, it plays well with the Having said all that, elisp is not my forte, so I might well be unaware of some pitfalls with function advising. |
Just to clarify, Embark actions can be either invoked on a single target or multiple targets. If they're invoked on a single target and they have an
Ideally we would come up with a nice unified way of handling all these different Embark calling conventions. I haven't looked into it deeply, but installing a special Embark hook might be the way to go. (Maybe |
@roshanshariff - should we ask Omar to weigh in? |
@bdarcus Absolutely! Omar might also be able to propose an alternative we haven't considered, or add some facility in Embark to make it easier. I think ideally Embark would be able to treat a "single target string representing multiple things" conceptually as a "multi target action". |
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 withcitar-citation
targets andcitar-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 fromcitar--select-multiple
or via an embark action on acitar-key
target, all works well. But if the argument is from acitar-citation
target with multiple keys, thencitar-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 thecitar--stringify-keys
function. Thuscitar-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 thecitar-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:
The same issue, in fact, applies to functions
citar-open
,citar-open-links
,citar-open-files
, andcitar-open-notes
, each of which fails, in my case at least, to act on acitar-citation
target with multiple keys.Originally posted by @kslutsky in #834 (comment)
The text was updated successfully, but these errors were encountered: