Docs: Improve examples

This commit is contained in:
Adam Porter 2019-08-10 10:18:29 -05:00
parent ab0df68aae
commit 6abb2ae8c0

View file

@ -25,36 +25,48 @@
More examples are available in [[examples.org]]. More examples are available in [[examples.org]].
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
;; Return a list of Org entry elements in the file "~/org/main.org" which have the SOMEDAY ;; Return a list of Org entry elements in the file "~/org/main.org"
;; to-do keyword, are tagged "Emacs", and have priority B or higher. ;; which have the SOMEDAY to-do keyword, are tagged "Emacs", and have
;; priority B or higher.
(org-ql "~/org/main.org" (org-ql "~/org/main.org"
(and (todo "SOMEDAY") (and (todo "SOMEDAY")
(tags "Emacs") (tags "Emacs")
(priority >= "B"))) ;=> ((headline (:raw-value "org-board" :begin 1220270 :end 1220403 ...)) ...) (priority >= "B")))
;;=> ((headline (:raw-value "org-board" :begin 1220270 :end 1220403 ...)) ...)
;; Return a list of bills coming due, searching all Org Agenda files, sorted by deadline. Deadlines ;; Set the tag "Emacs" on every entry in the inbox file that mentions
;; are compared with configured Org warning days, which is implied by the plain `<=' in the ;; "Emacs". `org-ql-select' works like `org-ql' but is a function
;; `deadline' matcher. ;; rather than a macro. The bare-string query "Emacs" is equivalent
(org-ql (org-agenda-files) ;; to (regexp "Emacs").
(and (not (done)) (org-ql-select "~/org/inbox.org"
"Emacs"
:action '(org-toggle-tag "Emacs" 'on))
;; Return a list of bills coming due, searching all Org Agenda files,
;; sorted by deadline. Deadlines are compared with
;; `org-deadline-warning-days', which is implied by the plain `<=' in
;; the `deadline' predicate. `org-ql-query' works like `org-ql-select'
;; but offers arguments named like SQL queries.
(org-ql-query
:select #'org-get-heading
:from (org-agenda-files)
:where '(and (not (done))
(tags "bills") (tags "bills")
(deadline <=)) (deadline <=))
:sort deadline) :order-by 'deadline)
;;=> ("TODO Electric bill" "TODO Water bill")
;; Set the tag "Emacs" on every entry in the inbox file that mentions "Emacs". ;; If you kept a database of music in an Org file, you could run a
(org-ql "~/org/inbox.org" ;; query like this to find tracks composed by Chopin that do not have
(regexp "Emacs") ;; their key recorded in the database. `org-ql-search' works like
:action (org-toggle-tag "Emacs" 'on)) ;; `org-ql-select' and displays results in an agenda-like buffer:
(org-ql-search "~/org/music.org"
;; If you kept a database of music in an Org file, you might run a query like this to find tracks '(and (property "genre" "classical")
;; composed by Chopin that do not have their key recorded in the database:
(org-ql "~/org/music.org"
(and (property "genre" "classical")
(property "composer" "Chopin") (property "composer" "Chopin")
(not (property "key")))) (not (property "key"))))
;; Define a custom Org Agenda command which inserts an `org-ql-block' ;; Integrate `org-ql' into a custom Org Agenda command which inserts
;; block before the regular agenda: ;; an `org-ql' block before the regular agenda:
(setq org-agenda-custom-commands (setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items" '(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
((org-ql-block '(and (todo "SOMEDAY") ((org-ql-block '(and (todo "SOMEDAY")