Add: org-ql-block

Usable as an Org Agenda custom command block type.  Inspired by
@pestctrl's custom config:

84c557982a/config-org-new.org (my-own-agenda-renderer)
This commit is contained in:
Adam Porter 2019-08-08 09:34:05 -05:00
parent d37f7c3eea
commit bd56652c66
2 changed files with 54 additions and 2 deletions

View file

@ -59,11 +59,11 @@ More examples are available in [[examples.org]].
The functionality provided may be grouped by:
+ Interactive commands :: ~org-ql-search~
+ Non-interactive functions and macros :: ~org-ql~ (macro), ~org-ql-select~ (function), ~org-ql-query~ (function), and ~org-ql-agenda~ (macro)
+ Non-interactive functions and macros :: ~org-ql~ (macro), ~org-ql-select~ (function), ~org-ql-query~ (function), ~org-ql-block~ (agenda function), and ~org-ql-agenda~ (macro)
Alternatively, they may be grouped by:
+ Showing an agenda-like view :: ~org-ql-search~ (command), and ~org-ql-agenda~ (macro)
+ Showing an agenda-like view :: ~org-ql-search~ (command), ~org-ql-block~ (agenda function), and ~org-ql-agenda~ (macro)
+ Returning a list of matches or acting on them :: ~org-ql~ (macro), ~org-ql-select~ (function), and ~org-ql-query~ (function)
Feedback on these APIs is welcome. Eventually, after being tested and polished, they will be considered stable.
@ -141,6 +141,30 @@ Arguments are listed next to predicate names, where applicable.
*** Agenda-like views
**** Function: ~org-ql-block~
For use as a custom agenda block type in ~org-agenda-custom-commands~. For example, you could define a custom series command like this, which would list all priority A items tagged =Emacs= with to-do keyword =SOMEDAY=, followed by the standard agenda view, in a single buffer:
#+BEGIN_SRC elisp
(setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((org-ql-block '(and (todo "SOMEDAY")
(tags "Emacs")
(priority "A")))
(agenda)))))
#+END_SRC
Which would be equivalent to a ~tags-todo~ search like this:
#+BEGIN_SRC elisp
(setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((tags-todo "PRIORITY=\"A\"+Emacs/!SOMEDAY")
(agenda)))))
#+END_SRC
However, the ~org-ql-block~ version runs in about 1/5th the time.
**** Macro: ~org-ql-agenda~
This macro is like ~org-ql~, but it presents matching entries in an Agenda-like view. It's compatible with [[https://github.com/alphapapa/org-super-agenda][org-super-agenda]], which provides grouping. For example:
@ -314,6 +338,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
+ Bare strings like ~"string"~ can be used in queries, which are converted to ~(regexp "string")~ automatically.
+ 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.
+ 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]].)
*Changed*
+ Function ~org-ql-query~ renamed to ~org-ql-select~. ~org-ql-query~ now refers to a new function.