From de4a8ff5434aa2fc0beaacf45577e292308bb7d1 Mon Sep 17 00:00:00 2001 From: Levi Date: Thu, 29 Aug 2024 16:52:05 +0200 Subject: [PATCH] capture denote todo items in org-agenda / todo --- emacs/init.el | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/emacs/init.el b/emacs/init.el index 2e67f47..47cb68c 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -137,6 +137,59 @@ (use-package org :ensure t :mode (("\\.org$" . org-mode))) +;; Set up org-agenda-files to include ~/notes and its subdirectories +(setq org-agenda-files + (directory-files-recursively "~/notes" "\\.org$")) + +;; Configure org-agenda-prefix-format to show minimal information +(setq org-agenda-prefix-format + '((agenda . " %i ") + (todo . " %i ") + (tags . " %i ") + (search . " %i "))) + +;; Hide the filename in the agenda view +(setq org-agenda-hide-tags-regexp ".") + +;; Remove the filename from agenda and TODO items, but keep the keyword +(defun my-org-agenda-format-item (item) + "Format an agenda or TODO item without the filename, but keep the keyword." + (let* ((marker (or (get-text-property 0 'org-marker item) + (get-text-property 0 'org-hd-marker item))) + (line (when marker + (org-with-point-at marker + (buffer-substring (line-beginning-position) (line-end-position))))) + (todo-keyword (when marker + (org-with-point-at marker + (org-get-todo-state)))) + (truncated-line (when line + (replace-regexp-in-string "^\\[#[A-Z]\\] " "" line)))) + (if truncated-line + (let ((clean-item (replace-regexp-in-string "^\\(\\*+ \\)" "" truncated-line))) + (if todo-keyword + (concat todo-keyword " " (replace-regexp-in-string (concat "^" todo-keyword " ?") "" clean-item)) + clean-item)) + item))) + +;; Apply our custom formatting to agenda items +(advice-add 'org-agenda-format-item-line :filter-return #'my-org-agenda-format-item) + +;; Apply our custom formatting to TODO items +(advice-add 'org-agenda-format-item :filter-return #'my-org-agenda-format-item) + +;; Keep the TODO keyword visible in the agenda +(setq org-agenda-todo-keyword-format "%s") + +;; Ensure org-agenda is refreshed when files are added or removed +(defun refresh-org-agenda-files () + (interactive) + (setq org-agenda-files + (directory-files-recursively "~/notes" "\\.org$"))) + +(run-with-idle-timer 300 t 'refresh-org-agenda-files) + + + (use-package ob-go :ensure t :defer t) (use-package ox-hugo :ensure t :defer t) ;; gitlab uses goldmark @@ -213,6 +266,7 @@ :jump-to-captured t))) ) + ;; projects ;; === (use-package projectile :ensure t :defer t