From: Don Armstrong Date: Thu, 6 Mar 2025 05:01:16 +0000 (-0800) Subject: call org-mode reftex setup after org mode loads X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=54ca59a59573e05cc28d17fcc25b45b308efc5fe;p=lib.git call org-mode reftex setup after org mode loads --- diff --git a/emacs_el/configuration/don-configuration.org b/emacs_el/configuration/don-configuration.org index 745ebbb..e5661fc 100644 --- a/emacs_el/configuration/don-configuration.org +++ b/emacs_el/configuration/don-configuration.org @@ -1041,10 +1041,31 @@ _d_: subtree #+BEGIN_SRC emacs-lisp (use-package reftex :hook ((LaTeX-mode latex-mode) . reftex-mode) + :hook (org-mode . my-org-mode-setup) + :after org :config (setq-default reftex-default-bibliography - '("~/projects/research/references.bib")) + '("~/projects/research/references.bib")) (setq-default reftex-plug-into-AUCTeX t) + (defun org-mode-reftex-search () + (interactive) + (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t))))) + (defun my-org-mode-setup () + (and (buffer-file-name) + (file-exists-p (buffer-file-name)) + (progn + ;; (reftex-parse-all) + (reftex-set-cite-format + '((?b . "[[bib:%l][%l-bib]]") + (?n . "[[notes:%l][%l-notes]]") + (?c . "\\cite{%l}") + (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]"))) + )) + (define-key org-mode-map (kbd "C-c )") 'reftex-citation) + (define-key org-mode-map (kbd "C-c [") 'reftex-citation) + (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search) + (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref) + ) ) #+END_SRC ** BibTex @@ -2028,28 +2049,6 @@ Maildir, or by Message-ID." ;; add support for "mutt:ID" links (org-add-link-type "mutt" 'open-mail-in-mutt) -(defun my-org-mode-setup () - ; (load-library "reftex") - (and (buffer-file-name) - (file-exists-p (buffer-file-name)) - (progn - ; (reftex-parse-all) - (reftex-set-cite-format - '((?b . "[[bib:%l][%l-bib]]") - (?n . "[[notes:%l][%l-notes]]") - (?c . "\\cite{%l}") - (?h . "*** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l xoj]] [[papers-pdf:%l][pdf]]"))) - )) - (define-key org-mode-map (kbd "C-c )") 'reftex-citation) - (define-key org-mode-map (kbd "C-c [") 'reftex-citation) - (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search) - (define-key org-mode-map (kbd "C-c 0") 'reftex-view-crossref) - ) -(add-hook 'org-mode-hook 'my-org-mode-setup) - -(defun org-mode-reftex-search () - (interactive) - (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t))))) (defun open-research-paper (bibtexkey) "Open a paper by bibtex key"