Closed benthamite closed 12 months ago
That's weird; testing just now, I don't see that. This is what I get when inserting without affix and with respectively.
# Testing ...
[@burwell2014]
[see @kohn2008, p12]
Okay, I now realize that this is not an intended behavior: looking at citar-markdown-insert-citation
more carefully, I see that when the value of prenote
and postnote
is an empty string, it should not insert any extra characters. When I run edebug on citar-markdown-insert-citation
, I see that prenote
and postnote
are evaluated to nil, so (string= "" prenote)
and (string= "" postnote)
evaluate to nil, and as a consequence prenote
and postnote
are assigned the values (concat prenote " ")
and (concat ", " postnote)
, respectively.
Presumably in your case the value of prenote
and postnote
is an empty string rather than nil, which would explain why the citations are inserted without any extra characters. Do you have a sense of what might be causing the difference in the values of those two variables between us?
No; I tried in both my default doom setup, and a minimal custom one.
Seems regardless it would be better for it to check for a non-empty string?
Care to submit a PR for that?
Sure. To confirm, this would just involve replacing (string= "" prenote)
with (= (length prenote) 0)
, and (string= "" postnote)
with (= (length postnote) 0)
, in citar-markdown-insert-citation
, right?
I believe so.
By the way, in case this is helpful to others, the reason we were getting different values for prenote
and postnote
(as I just realized) is that I have citar-markdown-prompt-for-extra-arguments
set to nil
. Because I am not prompted for a prefix or a suffix, the value of those variables ends up being nil
rather than an empty string.
When I run
citar-insert-citation
in a Markdown buffer and select the work I want to cite, the identifier is inserted preceded by a space and followed by a comma and a space, e.g.[ @Ord2020PrecipiceExistentialRisk, ]
. The function responsible for this behavior iscitar-markdown-insert-citation
(specifically, the lines(prenote (if (string= "" prenote) "" (concat prenote " ")))
and(postnote (if (string= "" postnote) "" (concat ", " postnote)))
. ) I would prefer not to have these extra characters inserted when no prefix or suffix is provided, which would also be consistent with how citations are inserted in org-mode buffers. Would it make sense to add a user option to control this behavior?