Overhaul org citation system

This commit is contained in:
Kiana Sheibani 2024-04-23 15:10:07 -04:00
parent ac903bc266
commit 5d14990960
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -3742,17 +3742,18 @@ Since Org-roam is currently my primary method of using Org, I only use its templ
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun org-roam-node-file-maybe (node &optional dir) (defun org-roam-node-file-maybe (node &optional dir)
"Get file name from NODE, or return a default filename in directory DIR." "Get file name from NODE, or return a default filename in directory DIR."
(unless dir (setq dir org-roam-directory)) (setq dir (expand-file-name (or dir "") org-roam-directory))
(or (org-roam-node-file node) (or (org-roam-node-file node)
(expand-file-name (expand-file-name "%<%Y-%m-%d_%H-%M-%S>.org" dir)))
(concat "%<%Y-%m-%d_%H-%M-%S>.org")
dir))) (defun org-roam-node-file-maybe-cite (node)
(org-roam-node-file-maybe node "cite"))
(defun org-roam-node-file-maybe-dir (node) (defun org-roam-node-file-maybe-dir (node)
"Get file name from NODE, or ask for directory and return a default filename." "Get file name from NODE, or ask for directory and return a default filename."
(or (org-roam-node-file node) (or (org-roam-node-file node)
(expand-file-name (expand-file-name
(concat "%<%Y-%m-%d_%H-%M-%S>.org") "%<%Y-%m-%d_%H-%M-%S>.org"
(read-directory-name "Directory: " org-roam-directory)))) (read-directory-name "Directory: " org-roam-directory))))
#+end_src #+end_src
@ -3790,6 +3791,11 @@ With those variables created, we can define our templates.
:target (file+head "${file-maybe-dir}" :target (file+head "${file-maybe-dir}"
"#+title: ${title}") "#+title: ${title}")
:unnarrowed t) :unnarrowed t)
("n" "Citation Note" plain ""
:target (file+head "${file-maybe-cite}"
"#+title: ${note-title}")
:immediate-finish t
:unnarrowed t)
("h" "Heading" entry ("h" "Heading" entry
"`(make-string (org-outline-level) ?*)`* ${title} "`(make-string (org-outline-level) ?*)`* ${title}
:RELATED: :RELATED:
@ -3973,19 +3979,44 @@ Let's start with some configuration. I use [[https://www.zotero.org/][Zotero]] t
#+begin_src emacs-lisp #+begin_src emacs-lisp
(after! org (after! org
(setq org-cite-csl-styles-dir "~/Zotero/styles" (setq org-cite-csl-styles-dir "~/Zotero/styles"
org-cite-csl--fallback-style-file "/home/kiana/Zotero/styles/modern-language-styles.csl" ;; MLA style by default
org-cite-global-bibliography (list (expand-file-name "library.json" org-directory)) org-cite-csl--fallback-style-file
"/home/kiana/Zotero/styles/modern-language-association.csl"
org-cite-global-bibliography
(list (expand-file-name "library.json" org-directory))
citar-bibliography org-cite-global-bibliography)) citar-bibliography org-cite-global-bibliography))
#+end_src #+end_src
And we should also make it look a little prettier: *** Citation Settings
I primarily use the CSL export processor to create MLA-style citation, so let's configure that to make its citations more standard.
#+begin_src emacs-lisp
(after! org
(setq org-cite-csl-link-cites nil ; This is not recommended by MLA
))
#+end_src
*** Roam Citation Notes
We can use the package =citar-org-roam= (bundled with Doom module =:tools biblio=) to create citation notes in Roam.
#+begin_src emacs-lisp
(after! citar-org-roam
(setq citar-org-roam-subdir "cite"
citar-org-roam-capture-template-key "n"))
#+end_src
*** Aesthetics
We should also make Org citations look a little prettier:
#+begin_src emacs-lisp #+begin_src emacs-lisp
;; Make faces conform to theme ;; Make faces conform to theme
(after! org (after! org
(custom-set-faces! (custom-set-faces!
`(org-cite :foreground ,(doom-color 'green)) `(org-cite :foreground ,(doom-color 'green))
`(org-cite-key :slant italic :foreground ,(doom-color 'green)))) '(org-cite-key :foreground nil :slant italic :underline t :inherit org-cite)))
;; Citar icons ;; Citar icons
(after! citar (after! citar