diff options
Diffstat (limited to 'modules/org-roam-config.el')
| -rw-r--r-- | modules/org-roam-config.el | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/modules/org-roam-config.el b/modules/org-roam-config.el index fdd9e1fc5..eca867df8 100644 --- a/modules/org-roam-config.el +++ b/modules/org-roam-config.el @@ -27,8 +27,37 @@ (require 'user-constants) +;; Declared special so the `let'-binding in `cj/org-roam-copy-todo-to-today' +;; compiles as a dynamic bind, not a dead lexical local -- otherwise the custom +;; capture template never reaches org-roam-dailies (the foreign-special-var trap). +(defvar org-roam-dailies-capture-templates) + +;; External variables, declared special so byte-compilation doesn't treat them +;; as free references/assignments. Owned by org and org-roam-dailies. +(defvar org-agenda-timegrid-use-ampm) +(defvar org-roam-dailies-map) +(defvar org-last-state) + +;; External functions, declared so the byte-compiler knows they're defined at +;; runtime by their respective packages. +(declare-function org-roam-node-tags "org-roam") +(declare-function org-roam-node-file "org-roam") +(declare-function org-roam-node-list "org-roam") +(declare-function org-roam-dailies--capture "org-roam-dailies") +(declare-function org-capture-get "org-capture") +(declare-function org-at-heading-p "org") +(declare-function org-heading-components "org") +(declare-function org-copy-subtree "org") +(declare-function org-cut-subtree "org") + ;; ---------------------------------- Org Roam --------------------------------- +(defconst cj/--org-roam-dailies-head + "#+FILETAGS: Journal\n#+TITLE: %<%Y-%m-%d>\n" + "Head inserted into a new org-roam daily file. +FILETAGS and TITLE must sit on separate lines so Org parses the +#+TITLE keyword (see `org-roam-dailies-capture-templates').") + (use-package org-roam :defer 1 :commands (org-roam-node-find org-roam-node-insert org-roam-db-autosync-mode) @@ -37,9 +66,9 @@ (org-roam-dailies-directory journals-dir) (org-roam-completion-everywhere t) (org-roam-dailies-capture-templates - '(("d" "default" entry "* %<%I:%M:%S %p %Z> %?" + `(("d" "default" entry "* %<%I:%M:%S %p %Z> %?" :if-new (file+head "%<%Y-%m-%d>.org" - "#+FILETAGS: Journal #+TITLE: %<%Y-%m-%d>")))) + ,cj/--org-roam-dailies-head)))) (org-roam-capture-templates `(("d" "default" plain "%?" @@ -65,8 +94,6 @@ :bind (("C-c n l" . org-roam-buffer-toggle) ("C-c n f" . org-roam-node-find) ("C-c n p" . cj/org-roam-find-node-project) - ("C-c n r" . cj/org-roam-find-node-recipe) - ("C-c n t" . cj/org-roam-find-node-topic) ("C-c n i" . org-roam-node-insert) ("C-c n w" . cj/org-roam-find-node-webclip) :map org-mode-map @@ -75,8 +102,10 @@ ;; org-log-done is set once in org-config.el (cj/org-todo-settings). (setq org-agenda-timegrid-use-ampm t) - (when (fboundp 'cj/build-org-refile-targets) - (cj/build-org-refile-targets)) + ;; Don't build the org-refile targets cache here. org-refile-config.el + ;; already schedules it on a 5s idle timer; doing it in org-roam's :config + ;; (which fires at the 1s :defer) ran the same multi-file scan synchronously + ;; at first idle and froze Emacs on a cold cache. The 5s timer covers it. ;; remove/disable if performance slows ;; (setq org-element-use-cache nil) ;; disables caching org files @@ -180,6 +209,11 @@ created in that subdirectory of `org-roam-directory'." (interactive) (cj/org-roam-find-node "Recipe" "r" (concat roam-dir "templates/recipe.org") "recipes/")) +;; Bound after their defuns (not in the use-package :bind) so the byte-compiler +;; doesn't see both a :bind autoload and the real defun as two definitions. +(keymap-global-set "C-c n r" #'cj/org-roam-find-node-recipe) +(keymap-global-set "C-c n t" #'cj/org-roam-find-node-topic) + ;; ---------------------- Org Capture After Finalize Hook ---------------------- (defun cj/org-roam-add-node-to-agenda-files-finalize-hook () |
