From 80970856d60424a46cc8468d7702612c3746b487 Mon Sep 17 00:00:00 2001 From: Jianye Ye Date: Mon, 28 Dec 2020 09:11:32 +0800 Subject: [PATCH 1/3] Add: Sort by (closed) for org-ql-select --- README.org | 2 +- org-ql.el | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index 1ebfead..5d3cf93 100644 --- a/README.org +++ b/README.org @@ -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). -~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: diff --git a/org-ql.el b/org-ql.el index 25ac675..fab2818 100644 --- a/org-ql.el +++ b/org-ql.el @@ -349,7 +349,7 @@ 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', `reverse', or `random'); or a +`scheduled', `closed', `todo', `priority', `reverse', or `random'); or a user-defined comparator function that accepts two items as arguments and returns nil or non-nil. Sorting methods are 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 (pcase sort (`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 (org-ql--sort-by items (-list sort))) ;; 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) "Return ITEMS sorted by PREDICATES. 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. (cl-flet* ((sorter (symbol) (pcase symbol - ((or 'deadline 'scheduled) + ((or 'deadline 'scheduled 'closed) (apply-partially #'org-ql--date-type< (intern (concat ":" (symbol-name symbol))))) ;; TODO: Rename `date' to `planning'. `date' should be something else. ('date #'org-ql--date<) From 4646d6d3078244dc681aaf6b17f0a15ffa241a2f Mon Sep 17 00:00:00 2001 From: Jianye Ye Date: Mon, 28 Dec 2020 09:13:39 +0800 Subject: [PATCH 2/3] Add: (closed) column for dynamic block --- README.org | 2 +- org-ql-search.el | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 5d3cf93..c125447 100644 --- a/README.org +++ b/README.org @@ -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: + ~: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")~. - 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~). diff --git a/org-ql-search.el b/org-ql-search.el index c7c979f..6c32cdd 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -246,7 +246,7 @@ Valid parameters include: form. :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 element being a header string. For example, 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) (--when-let (org-element-property :scheduled element) (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) (org-element-property (intern (concat ":" (upcase property))) element))))) (elements (org-ql-query :from (current-buffer) From 1c9b99ace9b2a61aae5b1c13835417324f6a8e93 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 22 Sep 2021 00:56:45 -0500 Subject: [PATCH 3/3] Docs: Update changelog --- README.org | 5 +++- org-ql.info | 76 ++++++++++++++++++++++++++++------------------------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/README.org b/README.org index c125447..ff83520 100644 --- a/README.org +++ b/README.org @@ -529,7 +529,10 @@ Simple links may also be written manually in either sexp or non-sexp form, like: + Predicate ~effort~. + 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). -+ 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* + 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. diff --git a/org-ql.info b/org-ql.info index 851f6f0..93069ea 100644 --- a/org-ql.info +++ b/org-ql.info @@ -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 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. + ‘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: @@ -875,7 +875,7 @@ supported: • ‘: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’. + ‘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")’. @@ -995,7 +995,11 @@ File: README.info, Node: 06-pre, Next: 052, Up: Changelog • 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 Ryan Ye (https://github.com/yejianye).) + • Dynamic block column ‘closed’. (Thanks to Ryan Ye + (https://github.com/yejianye).) *Changed* • The order in which sorting functions is applied has been reversed. @@ -1569,37 +1573,37 @@ Node: Date/time predicates18558 Node: Functions / Macros21646 Node: Agenda-like views21944 Node: Listing / acting-on results23349 -Node: Custom predicates28971 -Node: Dynamic block32630 -Node: Links35328 -Node: Tips36015 -Node: Changelog36333 -Node: 06-pre37059 -Node: 05239636 -Node: 05139940 -Node: 0540357 -Node: 04941831 -Node: 04842105 -Node: 04742452 -Node: 04642847 -Node: 04543247 -Node: 04443606 -Node: 04343965 -Node: 04244162 -Node: 04144323 -Node: 0444564 -Node: 03248497 -Node: 03148876 -Node: 0349073 -Node: 02352048 -Node: 02252276 -Node: 02152544 -Node: 0252743 -Node: 0156778 -Node: Notes56879 -Node: Comparison with Org Agenda searches57041 -Node: org-sidebar57913 -Node: License58192 +Node: Custom predicates28985 +Node: Dynamic block32644 +Node: Links35356 +Node: Tips36043 +Node: Changelog36361 +Node: 06-pre37087 +Node: 05239852 +Node: 05140156 +Node: 0540573 +Node: 04942047 +Node: 04842321 +Node: 04742668 +Node: 04643063 +Node: 04543463 +Node: 04443822 +Node: 04344181 +Node: 04244378 +Node: 04144539 +Node: 0444780 +Node: 03248713 +Node: 03149092 +Node: 0349289 +Node: 02352264 +Node: 02252492 +Node: 02152760 +Node: 0252959 +Node: 0156994 +Node: Notes57095 +Node: Comparison with Org Agenda searches57257 +Node: org-sidebar58129 +Node: License58408  End Tag Table