Add: (org-ql-agenda--agenda) Optionally specify entries directly
Should probably refactor this a bit more, but this is useful now.
This commit is contained in:
parent
43545482a4
commit
7829238988
2 changed files with 16 additions and 13 deletions
|
|
@ -348,6 +348,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
|
||||||
+ Selector ~(regexp)~ accepts multiple regexps to test.
|
+ Selector ~(regexp)~ accepts multiple regexps to test.
|
||||||
+ Macro ~org-ql~ and functions ~org-ql-query~ and ~org-ql-select~ now also accept a comparator function in their ~:sort~ argument.
|
+ Macro ~org-ql~ and functions ~org-ql-query~ and ~org-ql-select~ now also accept a comparator function in their ~:sort~ argument.
|
||||||
+ Function ~org-ql-block~, which works as an Org Agenda series/composite/block command, usable in custom agenda commands defined in variable ~org-agenda-custom-commands~. (Inspired by [[https://github.com/pestctrl/emacs-config/blob/84c557982a860e86d6f67976a82ea776a7bd2c7a/config-org-new.org#my-own-agenda-renderer][Benson Chu's config]].)
|
+ Function ~org-ql-block~, which works as an Org Agenda series/composite/block command, usable in custom agenda commands defined in variable ~org-agenda-custom-commands~. (Inspired by [[https://github.com/pestctrl/emacs-config/blob/84c557982a860e86d6f67976a82ea776a7bd2c7a/config-org-new.org#my-own-agenda-renderer][Benson Chu's config]].)
|
||||||
|
+ Function ~org-ql-agenda--agenda~ optionally takes a list of entries as an argument.
|
||||||
|
|
||||||
*Changed*
|
*Changed*
|
||||||
+ Function ~org-ql-query~ renamed to ~org-ql-select~. ~org-ql-query~ now refers to a new function.
|
+ Function ~org-ql-query~ renamed to ~org-ql-select~. ~org-ql-query~ now refers to a new function.
|
||||||
|
|
|
||||||
|
|
@ -201,23 +201,25 @@ SORT: One or a list of `org-ql' sorting functions, like `date' or
|
||||||
;; 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.
|
||||||
|
|
||||||
(cl-defun org-ql-agenda--agenda (buffers-files query &key sort buffer narrow super-groups)
|
(cl-defun org-ql-agenda--agenda (buffers-files query &key entries sort buffer narrow super-groups)
|
||||||
"FIXME: Docstring"
|
"FIXME: Docstring"
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(when (and super-groups (not org-super-agenda-mode))
|
(when (and super-groups (not org-super-agenda-mode))
|
||||||
(user-error "`org-super-agenda-mode' must be activated to use grouping"))
|
(user-error "`org-super-agenda-mode' must be activated to use grouping"))
|
||||||
(let* ((org-super-agenda-groups super-groups)
|
(let* ((org-super-agenda-groups super-groups)
|
||||||
(entries (--> (org-ql-select buffers-files
|
(entries (or entries
|
||||||
query
|
(--> (org-ql-select buffers-files
|
||||||
:sort sort
|
query
|
||||||
:narrow narrow
|
:sort sort
|
||||||
:action (lambda ()
|
:narrow narrow
|
||||||
(->> (org-element-headline-parser (line-end-position))
|
:action (lambda ()
|
||||||
org-ql--add-markers)))
|
(->> (org-element-headline-parser (line-end-position))
|
||||||
(mapcar #'org-ql-agenda--format-element it)
|
org-ql--add-markers))))))
|
||||||
(cond ((bound-and-true-p org-super-agenda-mode) (org-super-agenda--group-items it))
|
(string (--> entries
|
||||||
(t it))
|
(mapcar #'org-ql-agenda--format-element it)
|
||||||
(s-join "\n" it)))
|
(cond ((bound-and-true-p org-super-agenda-mode) (org-super-agenda--group-items it))
|
||||||
|
(t it))
|
||||||
|
(s-join "\n" it)))
|
||||||
(buffer (cl-etypecase buffer
|
(buffer (cl-etypecase buffer
|
||||||
(string (org-ql-agenda--buffer buffer))
|
(string (org-ql-agenda--buffer buffer))
|
||||||
(null (org-ql-agenda--buffer buffer))
|
(null (org-ql-agenda--buffer buffer))
|
||||||
|
|
@ -236,7 +238,7 @@ SORT: One or a list of `org-ql' sorting functions, like `date' or
|
||||||
(setq-local header-line-format (org-ql-agenda--header-line-format buffers-files query))
|
(setq-local header-line-format (org-ql-agenda--header-line-format buffers-files query))
|
||||||
;; Clear buffer, insert entries, etc.
|
;; Clear buffer, insert entries, etc.
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert entries)
|
(insert string)
|
||||||
(pop-to-buffer (current-buffer))
|
(pop-to-buffer (current-buffer))
|
||||||
(org-agenda-finalize)
|
(org-agenda-finalize)
|
||||||
(goto-char (point-min)))))
|
(goto-char (point-min)))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue