Simplify org-today
This commit is contained in:
parent
1d9a2cfc53
commit
41b1e0e837
2 changed files with 23 additions and 12 deletions
28
README.org
28
README.org
|
|
@ -6,9 +6,9 @@ Here's an example of generating a kind of agenda view for today (note that the g
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
(org-agenda-ng "~/src/emacs/org-super-agenda/test/test.org"
|
(org-agenda-ng "~/src/emacs/org-super-agenda/test/test.org"
|
||||||
(and (or (date '= (org-today))
|
(and (or (date '= today)
|
||||||
(deadline '<=)
|
(deadline '<=)
|
||||||
(scheduled '<= (org-today)))
|
(scheduled '<= today))
|
||||||
(not (done))))
|
(not (done))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
@ -28,27 +28,35 @@ Here are some other examples:
|
||||||
(org-agenda-ng "~/org/main.org"
|
(org-agenda-ng "~/org/main.org"
|
||||||
(or (habit)
|
(or (habit)
|
||||||
(deadline '<=)
|
(deadline '<=)
|
||||||
(scheduled '<= (org-today))
|
(scheduled '<= today)
|
||||||
(and (todo "DONE" "CANCELLED")
|
(and (todo "DONE" "CANCELLED")
|
||||||
(closed '= (org-today)))))
|
(closed '= today))))
|
||||||
|
|
||||||
(org-agenda-ng "~/org/main.org"
|
(org-agenda-ng "~/org/main.org"
|
||||||
(or (habit)
|
(or (habit)
|
||||||
(and (or (date '= (org-today))
|
(and (or (date '= today)
|
||||||
(deadline '<=)
|
(deadline '<=)
|
||||||
(scheduled '<= (org-today)))
|
(scheduled '<= today))
|
||||||
(not (done)))
|
(not (done)))
|
||||||
(and (todo "DONE" "CANCELLED")
|
(and (todo "DONE" "CANCELLED")
|
||||||
(closed '= (org-today)))))
|
(closed '= today))))
|
||||||
|
|
||||||
(org-agenda-ng "~/org/main.org"
|
(org-agenda-ng "~/org/main.org"
|
||||||
(or (habit)
|
(or (habit)
|
||||||
(and (or (date '= (org-today))
|
(and (or (date '= today)
|
||||||
(deadline '<=)
|
(deadline '<=)
|
||||||
(scheduled '<= (org-today)))
|
(scheduled '<= today))
|
||||||
(not (done)))
|
(not (done)))
|
||||||
(and (todo "DONE" "CANCELLED")
|
(and (todo "DONE" "CANCELLED")
|
||||||
(closed '= (org-today)))))
|
(closed '= today))))
|
||||||
|
(org-agenda-ng "~/org/main.org"
|
||||||
|
(or (habit)
|
||||||
|
(and (or (date '= today)
|
||||||
|
(deadline '<=)
|
||||||
|
(scheduled '<= today))
|
||||||
|
(not (done)))
|
||||||
|
(and (todo "DONE" "CANCELLED")
|
||||||
|
(closed '= today))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** org-ql
|
** org-ql
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ of calling `org-element-headline-parser' at each matching entry."
|
||||||
;; TODO: Move the action-fn down into --filter-buffer, so users can avoid calling the
|
;; TODO: Move the action-fn down into --filter-buffer, so users can avoid calling the
|
||||||
;; headline-parser when they don't need it.
|
;; headline-parser when they don't need it.
|
||||||
|
|
||||||
|
(defvar org-ql--today nil)
|
||||||
|
|
||||||
(cl-defun org-ql--query (files pred action-fn)
|
(cl-defun org-ql--query (files pred action-fn)
|
||||||
(setq files (cl-typecase files
|
(setq files (cl-typecase files
|
||||||
(null (list (buffer-file-name (current-buffer))))
|
(null (list (buffer-file-name (current-buffer))))
|
||||||
|
|
@ -80,7 +82,8 @@ of calling `org-element-headline-parser' at each matching entry."
|
||||||
(mapc 'find-file-noselect files)
|
(mapc 'find-file-noselect files)
|
||||||
(let* ((org-use-tag-inheritance t)
|
(let* ((org-use-tag-inheritance t)
|
||||||
(org-scanner-tags nil)
|
(org-scanner-tags nil)
|
||||||
(org-trust-scanner-tags t))
|
(org-trust-scanner-tags t)
|
||||||
|
(org-ql--today (org-today)))
|
||||||
(-flatten-n 1 (--map (with-current-buffer (find-buffer-visiting it)
|
(-flatten-n 1 (--map (with-current-buffer (find-buffer-visiting it)
|
||||||
(mapcar action-fn
|
(mapcar action-fn
|
||||||
(org-agenda-ng--filter-buffer :pred pred)))
|
(org-agenda-ng--filter-buffer :pred pred)))
|
||||||
|
|
@ -105,7 +108,7 @@ of calling `org-element-headline-parser' at each matching entry."
|
||||||
Headings should return non-nil for any ANY-PREDS and nil for all
|
Headings should return non-nil for any ANY-PREDS and nil for all
|
||||||
NONE-PREDS."
|
NONE-PREDS."
|
||||||
;; Cache `org-today' so we don't have to run it repeatedly.
|
;; Cache `org-today' so we don't have to run it repeatedly.
|
||||||
(cl-flet ((org-today nil `(progn ,(org-today))))
|
(cl-letf ((today org-ql--today))
|
||||||
(org-agenda-ng--fmap ((category #'org-agenda-ng--category-p)
|
(org-agenda-ng--fmap ((category #'org-agenda-ng--category-p)
|
||||||
(date #'org-agenda-ng--date-plain-p)
|
(date #'org-agenda-ng--date-plain-p)
|
||||||
(deadline #'org-agenda-ng--deadline-p)
|
(deadline #'org-agenda-ng--deadline-p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue