wip doom emacs agenda cache
This commit is contained in:
@@ -397,7 +397,8 @@ same format as 'insert-todays-date' without a prefix.
|
||||
=NOTE= Made by DT
|
||||
|
||||
#+begin_src emacs-lisp :tangle ./config.el
|
||||
(defun func/insert-todays-date (prefix)
|
||||
(defun my/insert-todays-date (prefix)
|
||||
"Insert any DATE using the current locale."
|
||||
(interactive "P")
|
||||
(let ((format (cond
|
||||
((not prefix) "%Y-%m-%d")
|
||||
@@ -405,7 +406,7 @@ same format as 'insert-todays-date' without a prefix.
|
||||
(insert (format-time-string format))))
|
||||
|
||||
(require 'calendar)
|
||||
(defun func/insert-any-date (date)
|
||||
(defun my/insert-any-date (date)
|
||||
"Insert DATE using the current locale."
|
||||
(interactive (list (calendar-read-date)))
|
||||
(insert (calendar-date-string date)))
|
||||
@@ -427,7 +428,8 @@ later.
|
||||
=NOTE= made by SystemCrafters
|
||||
|
||||
#+begin_src emacs-lisp :tangle ./config.el
|
||||
(defun func/org-roam-capture-task ()
|
||||
(defun my/org-roam-capture-task ()
|
||||
"Captures an org-roam task."
|
||||
(interactive)
|
||||
;; Capture the new task, creating the project file if necessary
|
||||
(org-roam-capture-
|
||||
@@ -436,7 +438,6 @@ later.
|
||||
:if-new (file+head+olp "%<%Y%m%d%H%M%S>-${slug}.org"
|
||||
"#+title: ${title}\n#+category: ${title}\n#+filetags: Project"
|
||||
("Tasks"))))))
|
||||
|
||||
(global-set-key (kbd "C-c n t") #'my/org-roam-capture-task)
|
||||
#+end_src
|
||||
|
||||
@@ -661,9 +662,6 @@ Doom Emacs.
|
||||
#+begin_src emacs-lisp :tangle ./config.el
|
||||
(after! org
|
||||
(setq org-directory "~/Documents/Notes/"
|
||||
org-agenda-files (directory-files-recursively
|
||||
"~/Documents/Notes" "\\.org$")
|
||||
;; org-default-notes-file (expand-file-name "Notes.org" org-directory)
|
||||
org-id-locations-file "~/Documents/Notes/.orgids"
|
||||
org-attach-id-dir "~/Documents/Notes/images"
|
||||
org-ellipsis " ▼ "
|
||||
@@ -699,6 +697,50 @@ Doom Emacs.
|
||||
(require 'org-habit))
|
||||
#+end_src
|
||||
|
||||
** Org Agenda Cache
|
||||
Reads the `.cache` file in `~/Documents/Notes/`, which contains only Org files
|
||||
with active TODOs, and sets `org-agenda-files` accordingly. Falls back to an
|
||||
empty list if the cache doesn’t exist.
|
||||
|
||||
#+begin_src emacs-lisp :tangle ./config.el
|
||||
(defvar my/org-agenda-cache-file "~/Documents/Notes/.cache"
|
||||
"Path to the org-agenda cache file.")
|
||||
(defun my/update-org-agenda-cache ()
|
||||
"Scan Org files and cache only those that contain TODOs or checkboxes."
|
||||
(interactive)
|
||||
(let* ((org-dir "~/Documents/Notes/")
|
||||
(files (directory-files-recursively org-dir "\\.org$"))
|
||||
(todo-files '())
|
||||
(regex "\\*+[ \t]+\\(TODO\\|PROJ\\|ART\\|IDEA\\|HOLD\\|\\[ \\]\\|\\[-\\]\\|\\[\\?\\]\\)"))
|
||||
(dolist (file files)
|
||||
(message "Scanning: %s" file)
|
||||
(condition-case err
|
||||
(with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward regex nil t)
|
||||
(message " -> TODO found in: %s" file)
|
||||
(push file todo-files)))
|
||||
(error (message "Error reading %s: %s" file err))))
|
||||
(setq todo-files (delete-dups todo-files))
|
||||
(if todo-files
|
||||
(progn
|
||||
(message "Writing %d TODO files to cache" (length todo-files))
|
||||
(with-temp-file my/org-agenda-cache-file
|
||||
(prin1 todo-files (current-buffer))))
|
||||
(message "No TODOs found — not writing cache."))))
|
||||
;; (defun my/load-org-agenda-from-cache ()
|
||||
;; "Load org-agenda-files from .cache, or fallback to an empty list."
|
||||
;; (if (file-exists-p my/org-agenda-cache-file)
|
||||
;; (with-temp-buffer
|
||||
;; (insert-file-contents my/org-agenda-cache-file)
|
||||
;; (read (current-buffer)))
|
||||
;; (message "Agenda cache not found — using empty org-agenda-files.")
|
||||
;; nil))
|
||||
;; (after! org
|
||||
;; (setq org-agenda-files (my/load-org-agenda-from-cache)))
|
||||
#+end_src
|
||||
|
||||
** Set font sizes for each header level in Org
|
||||
You can set the Org heading levels to be different font sizes. So I choose to
|
||||
have level 1 headings to be 140% in height, level 2 to be 130%, etc. Other
|
||||
|
||||
Reference in New Issue
Block a user