Fix: Accept plain queries in interactive org-ql-sparse-tree

This commit is contained in:
Akira Komamura 2022-03-22 17:59:01 +09:00 committed by Adam Porter
parent 7f68db962e
commit 2b7d4e0e79

View file

@ -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 ()