Skip to content
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

prefixes and suffixes in citar-markdown-insert-citation #786

Closed
benthamite opened this issue Jul 13, 2023 · 6 comments · Fixed by #787
Closed

prefixes and suffixes in citar-markdown-insert-citation #786

benthamite opened this issue Jul 13, 2023 · 6 comments · Fixed by #787

Comments

@benthamite
Copy link
Contributor

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 is citar-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?

@benthamite benthamite changed the title prefixes and suffixes incitar-markdown-insert-citation prefixes and suffixes in citar-markdown-insert-citation Jul 13, 2023
@bdarcus
Copy link
Contributor

bdarcus commented Jul 13, 2023

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]

@benthamite
Copy link
Contributor Author

benthamite commented Jul 13, 2023

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?

@bdarcus
Copy link
Contributor

bdarcus commented Jul 13, 2023

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?

@benthamite
Copy link
Contributor Author

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?

@bdarcus
Copy link
Contributor

bdarcus commented Jul 13, 2023 via email

@benthamite
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants