feat: Improve Org agenda filtering
Use ripgrip to only include files that actually have active todos in the agenda. This vastly decreases the number of files that need to be loaded.
This commit is contained in:
parent
8769246b8b
commit
3375db2ea6
16
config.org
16
config.org
|
@ -276,17 +276,21 @@ Setup org-superstar-mode, to make lists and bullets pretty
|
||||||
(setq org-agenda-files
|
(setq org-agenda-files
|
||||||
(seq-filter (lambda (item)
|
(seq-filter (lambda (item)
|
||||||
(and
|
(and
|
||||||
;; Only accept things that are a directory, or an org file
|
|
||||||
(or (file-directory-p item)
|
|
||||||
(string-match-p ".*org$" item))
|
|
||||||
;; Exclude the syncthing folder
|
;; Exclude the syncthing folder
|
||||||
(not (string-match-p ".*stfolder$" item))
|
(not (string-match-p ".*stfolder$" item))
|
||||||
;; Exclude the elfeed data folder
|
;; Exclude the elfeed data folder
|
||||||
(not (string-match-p (concat "^" (regexp-quote org-directory) "elfeed/.*") item))))
|
(not (string-match-p (concat "^" (regexp-quote org-directory) "elfeed/.*") item))
|
||||||
(directory-files-recursively org-directory directory-files-no-dot-files-regexp)))))
|
;; Only accept org files
|
||||||
|
(string-match-p ".*org$" item)
|
||||||
|
;; Make sure the file actually has in-progress todo markers in it
|
||||||
|
(let ((regex "^\\*+\\s*(TODO|PROJ|LOOP|STRT|WAIT|HOLD|IDEA|\\[ \\]|\\[-\\]|\\[?\\])")
|
||||||
|
(item (expand-file-name item)))
|
||||||
|
;; Use ripgrep to test for active todos in the file
|
||||||
|
(eq 0 (call-process "rg" nil nil nil "-q" regex item)))))
|
||||||
|
(directory-files-recursively org-directory directory-files-no-dot-files-regexp))))
|
||||||
;; Update the timer, first canceling the old one
|
;; Update the timer, first canceling the old one
|
||||||
(when nm/org-agenda-files-timer
|
(when nm/org-agenda-files-timer
|
||||||
(cancel-timer nm/org-agenda-files-timer)
|
(cancel-timer nm/org-agenda-files-timer))
|
||||||
(setq nm/org-agenda-files-timer (run-with-timer 60 nil 'nm/update-org-agenda-files))))
|
(setq nm/org-agenda-files-timer (run-with-timer 60 nil 'nm/update-org-agenda-files))))
|
||||||
|
|
||||||
(after! org
|
(after! org
|
||||||
|
|
Loading…
Reference in New Issue