Merge: (org-ql-sparse-tree) Accept string queries

Thanks to Akira Komamura (@akirak).
This commit is contained in:
Adam Porter 2023-03-10 04:46:45 -06:00
commit 3c73888b98
3 changed files with 47 additions and 33 deletions

View file

@ -557,6 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Changed* *Changed*
+ Give more useful error message for invalid queries. + Give more useful error message for invalid queries.
+ Predicate ~src~ now matches case-insensitively. + Predicate ~src~ now matches case-insensitively.
+ Command ~org-ql-sparse-tree~ accepts both string and sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]].)
*Fixed* *Fixed*
+ Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.) + Predicate ~src~'s matching of begin/end block lines, normalization of arguments, and handling in non-sexp queries. (Thanks to [[https://github.com/akirak][Akira Komamura]] for reporting.)

View file

@ -93,8 +93,8 @@ directories, etc, which would make it slow to list the
The tree will show the lines where the query matches, and any The tree will show the lines where the query matches, and any
other context defined in `org-show-context-detail', which see. other context defined in `org-show-context-detail', which see.
QUERY is an `org-ql' query sexp (quoted, since this is a QUERY is an `org-ql' query in either sexp or string form (see
function). BUFFER defaults to the current buffer. Info node `(org-ql)Queries').
When KEEP-PREVIOUS is non-nil (interactively, with prefix), the When KEEP-PREVIOUS is non-nil (interactively, with prefix), the
outline is not reset to the overview state before finding outline is not reset to the overview state before finding
@ -102,7 +102,7 @@ matches, which allows stacking calls to this command.
Runs `org-occur-hook' after making the sparse tree." Runs `org-occur-hook' after making the sparse tree."
;; Code based on `org-occur'. ;; Code based on `org-occur'.
(interactive (list (read-minibuffer "Query: ") (interactive (list (read-string "Query: ")
:keep-previous current-prefix-arg)) :keep-previous current-prefix-arg))
(with-current-buffer buffer (with-current-buffer buffer
(unless keep-previous (unless keep-previous
@ -110,7 +110,18 @@ Runs `org-occur-hook' after making the sparse tree."
;; we remove existing `org-occur' highlights, just in case. ;; we remove existing `org-occur' highlights, just in case.
(org-remove-occur-highlights nil nil t) (org-remove-occur-highlights nil nil t)
(org-overview)) (org-overview))
(let ((num-results 0)) (let ((num-results 0)
(query (pcase-exhaustive query
((and (pred stringp)
(rx bos (0+ blank) (or "(" "\"")))
;; Read sexp query from string.
(read query))
((pred stringp)
;; Parse string query into sexp query.
(org-ql--query-string-to-sexp query))
((pred listp)
;; Sexp query.
query))))
;; FIXME: Accept plain queries as well. ;; FIXME: Accept plain queries as well.
(org-ql-select buffer query (org-ql-select buffer query
:action (lambda () :action (lambda ()

View file

@ -1051,6 +1051,8 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog
*Changed* *Changed*
• Give more useful error message for invalid queries. • Give more useful error message for invalid queries.
• Predicate src now matches case-insensitively. • Predicate src now matches case-insensitively.
• Command org-ql-sparse-tree accepts both string and sexp queries.
(Thanks to Akira Komamura (https://github.com/akirak).)
*Fixed* *Fixed*
• Predicate srcs matching of begin/end block lines, normalization • Predicate srcs matching of begin/end block lines, normalization
@ -1733,35 +1735,35 @@ Node: Links37255
Node: Tips37942 Node: Tips37942
Node: Changelog38266 Node: Changelog38266
Node: 07-pre39049 Node: 07-pre39049
Node: 06341645 Node: 06341784
Node: 06242180 Node: 06242319
Node: 06142485 Node: 06142624
Node: 0643053 Node: 0643192
Node: 05246107 Node: 05246246
Node: 05146407 Node: 05146546
Node: 0546830 Node: 0546969
Node: 04948359 Node: 04948498
Node: 04848639 Node: 04848778
Node: 04748988 Node: 04749127
Node: 04649397 Node: 04649536
Node: 04549805 Node: 04549944
Node: 04450166 Node: 04450305
Node: 04350525 Node: 04350664
Node: 04250728 Node: 04250867
Node: 04150889 Node: 04151028
Node: 0451136 Node: 0451275
Node: 03255237 Node: 03255376
Node: 03155640 Node: 03155779
Node: 0355837 Node: 0355976
Node: 02359137 Node: 02359276
Node: 02259371 Node: 02259510
Node: 02159651 Node: 02159790
Node: 0259856 Node: 0259995
Node: 0163934 Node: 0164073
Node: Notes64035 Node: Notes64174
Node: Comparison with Org Agenda searches64197 Node: Comparison with Org Agenda searches64336
Node: org-sidebar65086 Node: org-sidebar65225
Node: License65365 Node: License65504
 
End Tag Table End Tag Table