Last active
December 29, 2024 11:10
-
-
Save jdtsmith/d49eaaae852c5496a80e2489014bc41c to your computer and use it in GitHub Desktop.
org cite "processor" example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(when-let ((basic (org-cite-get-processor 'basic)) | |
(activate (org-cite-processor-activate basic))) | |
(org-cite-register-processor | |
'activate-hide-@cite :activate | |
(lambda (citation) | |
"Activate CITATION, then make leadup to first ref invisible." | |
(funcall activate citation) | |
(when-let ((first-ref (car (org-cite-get-references citation))) | |
(beg (car (org-cite-boundaries citation)))) | |
(put-text-property (1+ beg) (car (org-cite-key-boundaries first-ref)) | |
'invisible t))))) |
Update: simplified to set only the activate
slot of the new processor, since that is all that is used from the org-cite-activate-processor
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This shows an example of working directly with
org-cite
processors, which control fontification, activation, export, etc. for org citations. The idea is to register a new citation "processor" that alters behavior.This example works by wrapping the
basic
processor'sactivate
function to make the text from the start of the citation to its first keyword invisible. The new processor is calledactivate-hide-@cite
.After running the above, you can use it in a hook like:
for a more toned-down org citation style in the buffer.
Idea from this blog post. The advantage over a regexp-search/overlay approach is it works with font-lock, is much faster for long documents, updates during live editing, etc.