Merge: branch 'dynamic-block-closed'

This commit is contained in:
Adam Porter 2021-09-22 00:57:00 -05:00
commit 9dfa534e60
4 changed files with 54 additions and 44 deletions

View file

@ -348,7 +348,7 @@ Return items matching ~QUERY~ in ~BUFFERS-OR-FILES~.
If ~NARROW~ is non-nil, buffers are not widened (the default is to widen and search the entire buffer). If ~NARROW~ is non-nil, buffers are not widened (the default is to widen and search the entire buffer).
~SORT~ is either nil, in which case items are not sorted; or one or a list of defined ~org-ql~ sorting methods (~date~, ~deadline~, ~scheduled~, ~todo~, ~priority~, or ~random~); or a user-defined comparator function that accepts two items as arguments and returns nil or non-nil. ~SORT~ is either nil, in which case items are not sorted; or one or a list of defined ~org-ql~ sorting methods (~date~, ~deadline~, ~scheduled~, ~closed~, ~todo~, ~priority~, or ~random~); or a user-defined comparator function that accepts two items as arguments and returns nil or non-nil.
Examples: Examples:
@ -471,7 +471,7 @@ It would be expanded to:
Org QL provides a dynamic block that lists entries in the current document matching a query. In the header, these parameters are supported: Org QL provides a dynamic block that lists entries in the current document matching a query. In the header, these parameters are supported:
+ ~:query~: An Org QL query expression in either sexp or non-sexp form. + ~:query~: An Org QL query expression in either sexp or non-sexp form.
+ ~:columns~ A list of columns, including ~heading~, ~todo~, ~property~, ~priority~, ~deadline~, ~scheduled~. + ~:columns~ A list of columns, including ~heading~, ~todo~, ~property~, ~priority~, ~deadline~, ~scheduled~, ~closed~.
- Each column may also be specified as a list with the second element being a header string. For example, to abbreviate the priority column: ~(priority "P")~. - Each column may also be specified as a list with the second element being a header string. For example, to abbreviate the priority column: ~(priority "P")~.
- For certain columns, like =property=, arguments may be passed by specifying the column type itself as a list. For example, to display a column showing the values of a ~property~ named ~milestone~, with the header being abbreviated to ~M~: ~((property "milestone") "M")~. - For certain columns, like =property=, arguments may be passed by specifying the column type itself as a list. For example, to display a column showing the values of a ~property~ named ~milestone~, with the header being abbreviated to ~M~: ~((property "milestone") "M")~.
+ ~:sort~ One or a list of Org QL sorting methods (see ~org-ql-select~). + ~:sort~ One or a list of Org QL sorting methods (see ~org-ql-select~).
@ -529,7 +529,10 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
+ Predicate ~effort~. + Predicate ~effort~.
+ Predicate ~heading-regexp~, which matches regular expressions against heading text (alias: ~h*~). + Predicate ~heading-regexp~, which matches regular expressions against heading text (alias: ~h*~).
+ Timestamp-related predicates now accept an optional ~:with-time~ argument, which allows matching timestamps with or without times (i.e. HH:MM). + Timestamp-related predicates now accept an optional ~:with-time~ argument, which allows matching timestamps with or without times (i.e. HH:MM).
+ Sorting method ~reverse~. + Sorting methods:
- ~reverse~
- ~closed~ (Thanks to [[https://github.com/yejianye][Ryan Ye]].)
+ Dynamic block column ~closed~. (Thanks to [[https://github.com/yejianye][Ryan Ye]].)
*Changed* *Changed*
+ The order in which sorting functions is applied has been reversed. For example, ~:sort '(todo priority date)~ now does what ~:sort '(date priority todo)~ did in earlier versions. (This change is made to enable the new ~reverse~ sorting method.) Users who have customized =org-ql-views= will need to update the stored views' sorting methods to preserve the desired sort order. + The order in which sorting functions is applied has been reversed. For example, ~:sort '(todo priority date)~ now does what ~:sort '(date priority todo)~ did in earlier versions. (This change is made to enable the new ~reverse~ sorting method.) Users who have customized =org-ql-views= will need to update the stored views' sorting methods to preserve the desired sort order.

View file

@ -246,7 +246,7 @@ Valid parameters include:
form. form.
:columns A list of columns, including `heading', `todo', :columns A list of columns, including `heading', `todo',
`property', `priority', `deadline', `scheduled'. `property',`priority',`deadline',`scheduled',`closed'.
Each column may also be specified as a list with the Each column may also be specified as a list with the
second element being a header string. For example, second element being a header string. For example,
to abbreviate the priority column: (priority \"P\"). to abbreviate the priority column: (priority \"P\").
@ -297,6 +297,9 @@ For example, an org-ql dynamic block header could look like:
(cons 'scheduled (lambda (element) (cons 'scheduled (lambda (element)
(--when-let (org-element-property :scheduled element) (--when-let (org-element-property :scheduled element)
(ts-format ts-format (ts-parse-org-element it))))) (ts-format ts-format (ts-parse-org-element it)))))
(cons 'closed (lambda (element)
(--when-let (org-element-property :closed element)
(ts-format ts-format (ts-parse-org-element it)))))
(cons 'property (lambda (element property) (cons 'property (lambda (element property)
(org-element-property (intern (concat ":" (upcase property))) element))))) (org-element-property (intern (concat ":" (upcase property))) element)))))
(elements (org-ql-query :from (current-buffer) (elements (org-ql-query :from (current-buffer)

View file

@ -349,7 +349,7 @@ widen and search the entire buffer).
SORT is either nil, in which case items are not sorted; or one or SORT is either nil, in which case items are not sorted; or one or
a list of defined `org-ql' sorting methods (`date', `deadline', a list of defined `org-ql' sorting methods (`date', `deadline',
`scheduled', `todo', `priority', `reverse', or `random'); or a `scheduled', `closed', `todo', `priority', `reverse', or `random'); or a
user-defined comparator function that accepts two items as user-defined comparator function that accepts two items as
arguments and returns nil or non-nil. Sorting methods are arguments and returns nil or non-nil. Sorting methods are
applied in the order given (i.e. later methods override earlier applied in the order given (i.e. later methods override earlier
@ -426,7 +426,7 @@ each priority the newest items would appear first."
;; Sort items ;; Sort items
(pcase sort (pcase sort
(`nil items) (`nil items)
((guard (cl-subsetp (-list sort) '(date deadline scheduled todo priority random reverse))) ((guard (cl-subsetp (-list sort) '(date deadline scheduled closed todo priority random reverse)))
;; Default sorting functions ;; Default sorting functions
(org-ql--sort-by items (-list sort))) (org-ql--sort-by items (-list sort)))
;; Sort by user-given comparator. ;; Sort by user-given comparator.
@ -2164,11 +2164,11 @@ any planning prefix); it defaults to 0 (i.e. the whole regexp)."
(defun org-ql--sort-by (items predicates) (defun org-ql--sort-by (items predicates)
"Return ITEMS sorted by PREDICATES. "Return ITEMS sorted by PREDICATES.
PREDICATES is a list of one or more sorting methods, including: PREDICATES is a list of one or more sorting methods, including:
`deadline', `scheduled', and `priority'." `deadline', `scheduled', `closed' and `priority'."
;; MAYBE: Use macrolet instead of flet. ;; MAYBE: Use macrolet instead of flet.
(cl-flet* ((sorter (symbol) (cl-flet* ((sorter (symbol)
(pcase symbol (pcase symbol
((or 'deadline 'scheduled) ((or 'deadline 'scheduled 'closed)
(apply-partially #'org-ql--date-type< (intern (concat ":" (symbol-name symbol))))) (apply-partially #'org-ql--date-type< (intern (concat ":" (symbol-name symbol)))))
;; TODO: Rename `date' to `planning'. `date' should be something else. ;; TODO: Rename `date' to `planning'. `date' should be something else.
('date #'org-ql--date<) ('date #'org-ql--date<)

View file

@ -698,9 +698,9 @@ File: README.info, Node: Listing / acting-on results, Next: Custom predicates,
SORT is either nil, in which case items are not sorted; or one or SORT is either nil, in which case items are not sorted; or one or
a list of defined org-ql sorting methods (date, deadline, a list of defined org-ql sorting methods (date, deadline,
scheduled, todo, priority, or random); or a user-defined scheduled, closed, todo, priority, or random); or a
comparator function that accepts two items as arguments and returns user-defined comparator function that accepts two items as
nil or non-nil. arguments and returns nil or non-nil.
Examples: Examples:
@ -875,7 +875,7 @@ supported:
:query: An Org QL query expression in either sexp or non-sexp :query: An Org QL query expression in either sexp or non-sexp
form. form.
:columns A list of columns, including heading, todo, :columns A list of columns, including heading, todo,
property, priority, deadline, scheduled. property, priority, deadline, scheduled, closed.
• Each column may also be specified as a list with the second • Each column may also be specified as a list with the second
element being a header string. For example, to abbreviate the element being a header string. For example, to abbreviate the
priority column: (priority "P"). priority column: (priority "P").
@ -995,7 +995,11 @@ File: README.info, Node: 06-pre, Next: 052, Up: Changelog
• Timestamp-related predicates now accept an optional :with-time • Timestamp-related predicates now accept an optional :with-time
argument, which allows matching timestamps with or without times argument, which allows matching timestamps with or without times
(i.e. HH:MM). (i.e. HH:MM).
• Sorting method reverse. • Sorting methods:
reverse
closed (Thanks to Ryan Ye (https://github.com/yejianye).)
• Dynamic block column closed. (Thanks to Ryan Ye
(https://github.com/yejianye).)
*Changed* *Changed*
• The order in which sorting functions is applied has been reversed. • The order in which sorting functions is applied has been reversed.
@ -1569,37 +1573,37 @@ Node: Date/time predicates18558
Node: Functions / Macros21646 Node: Functions / Macros21646
Node: Agenda-like views21944 Node: Agenda-like views21944
Node: Listing / acting-on results23349 Node: Listing / acting-on results23349
Node: Custom predicates28971 Node: Custom predicates28985
Node: Dynamic block32630 Node: Dynamic block32644
Node: Links35328 Node: Links35356
Node: Tips36015 Node: Tips36043
Node: Changelog36333 Node: Changelog36361
Node: 06-pre37059 Node: 06-pre37087
Node: 05239636 Node: 05239852
Node: 05139940 Node: 05140156
Node: 0540357 Node: 0540573
Node: 04941831 Node: 04942047
Node: 04842105 Node: 04842321
Node: 04742452 Node: 04742668
Node: 04642847 Node: 04643063
Node: 04543247 Node: 04543463
Node: 04443606 Node: 04443822
Node: 04343965 Node: 04344181
Node: 04244162 Node: 04244378
Node: 04144323 Node: 04144539
Node: 0444564 Node: 0444780
Node: 03248497 Node: 03248713
Node: 03148876 Node: 03149092
Node: 0349073 Node: 0349289
Node: 02352048 Node: 02352264
Node: 02252276 Node: 02252492
Node: 02152544 Node: 02152760
Node: 0252743 Node: 0252959
Node: 0156778 Node: 0156994
Node: Notes56879 Node: Notes57095
Node: Comparison with Org Agenda searches57041 Node: Comparison with Org Agenda searches57257
Node: org-sidebar57913 Node: org-sidebar58129
Node: License58192 Node: License58408
 
End Tag Table End Tag Table