From b259d1829e8cb64968ba6814c4b02c3063d079e6 Mon Sep 17 00:00:00 2001 From: Eric Zhuo Chen Date: Mon, 15 Apr 2024 18:06:50 +0800 Subject: [PATCH] Tweak Citar and TeX --- modules/zy-bib.el | 9 ++++++++- modules/zy-personal.el | 6 +++++- modules/zy-tex.el | 9 +++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/zy-bib.el b/modules/zy-bib.el index c08588d..0c5faa6 100644 --- a/modules/zy-bib.el +++ b/modules/zy-bib.el @@ -59,8 +59,12 @@ (after! '(+platform citar) (setq citar-file-open-functions '((t . +platform/open-externally)))) -;; Embark integration for Citar. +;; Load Citar early for relevant modes. +(after! '(tex-mode org markdown-mode) + (require 'citar)) + (after! 'citar + ;; Embark integration for Citar. (citar-embark-mode 1)) ;; Configure the built-in library `bibtex', which is used to edit BibTeX files @@ -72,6 +76,9 @@ ;; Using 5 words for title is too long. I prefer shorter keys. (setq bibtex-autokey-titlewords 2) + ;; Do not use more than 2 words. Short keys are prettier! + (setq bibtex-autokey-titlewords-stretch 0) + ;; Separate everything with underscores. (setq bibtex-autokey-name-year-separator "_" bibtex-autokey-year-title-separator "_") diff --git a/modules/zy-personal.el b/modules/zy-personal.el index 24835ec..e7bc37b 100644 --- a/modules/zy-personal.el +++ b/modules/zy-personal.el @@ -62,7 +62,11 @@ Org-journal, Org-roam, and many more." ebib-notes-directory (expand-file-name "ebib/notes" path) ebib-file-search-dirs - `(,(expand-file-name "ebib/files" path)))) + `(,(expand-file-name "ebib/files" path))) + ;; Citar paths (same as the Ebib ones). + (defvar citar-bibliography) + (setq citar-bibliography + `(,(expand-file-name "ebib/references.bib" path)))) ;; Otherwise, warn about it when necessary. (when +personal-enable (lwarn 'zyemacs :warning "Zybox path is not valid.")))) diff --git a/modules/zy-tex.el b/modules/zy-tex.el index 1a214df..92512f0 100644 --- a/modules/zy-tex.el +++ b/modules/zy-tex.el @@ -59,10 +59,15 @@ nil LaTeX-mode-map "" "a" (cons "Run All" #'TeX-command-run-all) "c" (cons "Run Command" #'TeX-command-master) - "e" (cons "Insert Env" #'LaTeX-environment) + "e" (cons "Ins. Env" #'LaTeX-environment) "f" (cons "Set Font" #'TeX-font) "v" (cons "View" #'TeX-view) - "_" (cons "Choose Master File" #'TeX-master-file-ask))) + "_" (cons "Choose Master File" #'TeX-master-file-ask)) + + ;; Use a key for inserting citations with Citar. + (after! '(+bib citar) + (keybind! nil +tex-map + "i" (cons "Ins. Citation" #'citar-insert-citation)))) (provide 'zy-tex)