From 7ce0237fd19639fd34f55b5c3ffb5bdf5ea7686e Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Tue, 8 Jul 2025 09:39:32 -0500 Subject: [PATCH] View org agenda files, for pruning --- lisp/org-config/org-roam-update-agenda.el | 28 +++++++++++++++++++++++ lisp/ti-config/work-org-stuff.el | 14 ++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lisp/org-config/org-roam-update-agenda.el b/lisp/org-config/org-roam-update-agenda.el index 8b492a8..0bed2e5 100644 --- a/lisp/org-config/org-roam-update-agenda.el +++ b/lisp/org-config/org-roam-update-agenda.el @@ -38,5 +38,33 @@ :before #'my/update-org-agenda-files) +(defun my/view-org-agenda-files () + (interactive) + (find-file + (consult--read + org-agenda-files + :prompt "org-agenda-files: " + :sort nil ;; cands are already sorted + :require-match t + :state (consult--preview-org-agenda-files) + :category 'org-roam-node))) + +(defun consult--preview-org-agenda-files () + "Create preview function for nodes." + (let ((open (consult--temporary-files)) + (preview (consult--buffer-preview)) + (state (window-state-get))) + (lambda (action cand) + (when (eq action 'exit) + (progn + ;; Restore saved window state + ;; To move point to the original position + (window-state-put state) + (funcall open))) + (funcall preview action + (and cand + (eq action 'preview) + (funcall open cand)))))) + (provide 'org-roam-update-agenda) ;;; org-roam-update-agenda.el ends here diff --git a/lisp/ti-config/work-org-stuff.el b/lisp/ti-config/work-org-stuff.el index e33295d..6a02580 100644 --- a/lisp/ti-config/work-org-stuff.el +++ b/lisp/ti-config/work-org-stuff.el @@ -261,6 +261,10 @@ (setq org-refile-targets `((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9))) +(global-set-key (kbd "C-c n a") #'my/view-org-agenda-files) + +(setq org-agenda-sticky t) + (require 'org-protocol) ;; (defun wait-mark-blocking-tasks (change-plist) @@ -513,10 +517,12 @@ (defun my/org-roam-find-active-projects () (interactive) - ;; Select a project file to open, creating it if necessary - (org-roam-node-find nil nil - (my/org-roam-filter-by-tag '("Project" "active")) - nil :templates my/project-templates)) + (cl-letf (((symbol-function 'org-roam-node-read) + (symbol-function 'consult-org-roam-node-read))) + ;; Select a project file to open, creating it if necessary + (org-roam-node-find nil nil + (my/org-roam-filter-by-tag '("Project" "active")) + nil :templates my/project-templates))) (defun org-agenda-insert-breaks-between (str1 str2) (let ((r (rx line-start