From 2b7d4e0e79260b5caa9cf978ee80edf03c7c981d Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Tue, 22 Mar 2022 17:59:01 +0900 Subject: [PATCH 1/4] Fix: Accept plain queries in interactive org-ql-sparse-tree --- org-ql-search.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index cedcadb..b442b38 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -102,7 +102,7 @@ matches, which allows stacking calls to this command. Runs `org-occur-hook' after making the sparse tree." ;; Code based on `org-occur'. - (interactive (list (read-minibuffer "Query: ") + (interactive (list (read-string "Query: ") :keep-previous current-prefix-arg)) (with-current-buffer buffer (unless keep-previous @@ -110,7 +110,15 @@ Runs `org-occur-hook' after making the sparse tree." ;; we remove existing `org-occur' highlights, just in case. (org-remove-occur-highlights nil nil t) (org-overview)) - (let ((num-results 0)) + (let ((num-results 0) + (query (cl-etypecase query + (string (if (or (string-prefix-p "(" query) + (string-prefix-p "\"" query)) + ;; Read sexp query. + (read query) + ;; Parse non-sexp query into sexp query. + (org-ql--query-string-to-sexp query))) + (list query)))) ;; FIXME: Accept plain queries as well. (org-ql-select buffer query :action (lambda () From 1ae2f0cd60974e85b204cd1bd255aa39b253473f Mon Sep 17 00:00:00 2001 From: Akira Komamura Date: Tue, 22 Mar 2022 18:08:13 +0900 Subject: [PATCH 2/4] Update the docstring --- org-ql-search.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index b442b38..efd9aa7 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -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 other context defined in `org-show-context-detail', which see. -QUERY is an `org-ql' query sexp (quoted, since this is a -function). BUFFER defaults to the current buffer. +QUERY: An `org-ql' query in either sexp or non-sexp form (see +Info node `(org-ql)Queries'). When KEEP-PREVIOUS is non-nil (interactively, with prefix), the outline is not reset to the overview state before finding From 99e580b53077ff1de26009de2c56dc5870dd3b19 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 04:44:05 -0600 Subject: [PATCH 3/4] Tidy: (org-ql-sparse-tree) Docstring; use pcase --- org-ql-search.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index efd9aa7..e0ab3ff 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -93,7 +93,7 @@ directories, etc, which would make it slow to list the The tree will show the lines where the query matches, and any other context defined in `org-show-context-detail', which see. -QUERY: An `org-ql' query in either sexp or non-sexp form (see +QUERY is an `org-ql' query in either sexp or string form (see Info node `(org-ql)Queries'). When KEEP-PREVIOUS is non-nil (interactively, with prefix), the @@ -111,14 +111,17 @@ Runs `org-occur-hook' after making the sparse tree." (org-remove-occur-highlights nil nil t) (org-overview)) (let ((num-results 0) - (query (cl-etypecase query - (string (if (or (string-prefix-p "(" query) - (string-prefix-p "\"" query)) - ;; Read sexp query. - (read query) - ;; Parse non-sexp query into sexp query. - (org-ql--query-string-to-sexp query))) - (list query)))) + (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. (org-ql-select buffer query :action (lambda () From d92afcda062b2953b148b0507f8137d6bfbad862 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 10 Mar 2023 04:46:32 -0600 Subject: [PATCH 4/4] Docs: Update changelog --- README.org | 1 + org-ql.info | 60 +++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/README.org b/README.org index e19b3d6..2845805 100644 --- a/README.org +++ b/README.org @@ -557,6 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Changed* + Give more useful error message for invalid queries. + 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* + 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.) diff --git a/org-ql.info b/org-ql.info index ec95d26..08900a2 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1051,6 +1051,8 @@ File: README.info, Node: 07-pre, Next: 063, Up: Changelog *Changed* • Give more useful error message for invalid queries. • 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* • Predicate ‘src’’s matching of begin/end block lines, normalization @@ -1733,35 +1735,35 @@ Node: Links37255 Node: Tips37942 Node: Changelog38266 Node: 07-pre39049 -Node: 06341645 -Node: 06242180 -Node: 06142485 -Node: 0643053 -Node: 05246107 -Node: 05146407 -Node: 0546830 -Node: 04948359 -Node: 04848639 -Node: 04748988 -Node: 04649397 -Node: 04549805 -Node: 04450166 -Node: 04350525 -Node: 04250728 -Node: 04150889 -Node: 0451136 -Node: 03255237 -Node: 03155640 -Node: 0355837 -Node: 02359137 -Node: 02259371 -Node: 02159651 -Node: 0259856 -Node: 0163934 -Node: Notes64035 -Node: Comparison with Org Agenda searches64197 -Node: org-sidebar65086 -Node: License65365 +Node: 06341784 +Node: 06242319 +Node: 06142624 +Node: 0643192 +Node: 05246246 +Node: 05146546 +Node: 0546969 +Node: 04948498 +Node: 04848778 +Node: 04749127 +Node: 04649536 +Node: 04549944 +Node: 04450305 +Node: 04350664 +Node: 04250867 +Node: 04151028 +Node: 0451275 +Node: 03255376 +Node: 03155779 +Node: 0355976 +Node: 02359276 +Node: 02259510 +Node: 02159790 +Node: 0259995 +Node: 0164073 +Node: Notes64174 +Node: Comparison with Org Agenda searches64336 +Node: org-sidebar65225 +Node: License65504  End Tag Table