emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
479 stars 53 forks source link

Upgrade citar-org-update-pre-suffix to iterate through all references in citation #788

Closed krisbalintona closed 11 months ago

krisbalintona commented 11 months ago

To resolve #607 and #606. The following pull request does the following:

  1. Renames citar-org-update-pre-suffix to citar-org-update-prefix-suffix. I found the initial naming potentially misleading. This rename may increase the discoverability of the command.
  2. Adds a helper function, citar-org--update-prefix-suffix.
  3. (Unchanged) When on a reference, will prompt for a new prefix and suffix, with default values being their current values.
  4. (New) When on a citation (but not a reference), will prompt for a new prefix and suffix for every reference in the citation at point from left to right.
  5. (New) When on a reference and called with prefix arg, does the same as (4).
  6. (New) There will always be only one space between citekey and citation suffix, unless there is no non-whitespace character in the suffix, in which case the suffix will be empty.

This new functionality uses purely the org-element API, meaning this should be a robust solution.

Additionally, I have manually tested the pull request through several edge cases, and have detected no bugs.

Finally, if this pull request goes through, I think it would be a good idea to (i) have citar-org-update-prefix-suffix be run after inserting a citation and (ii) have a customizable option to have toggle this behavior, potentially having it enabled by default.

bdarcus commented 11 months ago

Finally, if this pull request goes through, I think it would be a good idea to (i) have citar-org-update-prefix-suffix be run after inserting a citation and (ii) have a customizable option to have toggle this behavior, potentially having it enabled by default.

Yeah; I was wondering about that after testing it. ;-)

Perhaps on that you could also update the documentation?

https://github.com/emacs-citar/citar#org-cite-1

Thanks!