Fix: (org-ql-completing-read) :query-prefix prevented selection

COMPLETING-READ, when used with its REQUIRE-MATCH argument, would not
allow a result to be selected when ORG-QL-FIND was called with its
QUERY-PREFIX argument.

This change moves where the query is modified to include the prefix,
putting it into the RUN-QUERY function instead of the COLLECTION
function.  It seems to solve the problem, and the function seems to
still work when used without QUERY-PREFIX.  However, due to the
complexity of all this (we really need a SELECTING-READ API), it
wouldn't surprise me if something is later found to have been broken
by it...

Fixes #351.

Reported-by: Daniel Fleischer <https://github.com/danielfleischer>
This commit is contained in:
Adam Porter 2023-09-14 08:10:49 -05:00
parent 131407814e
commit 95abce2340
3 changed files with 38 additions and 33 deletions

View file

@ -547,6 +547,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Fixes* *Fixes*
+ Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Timestamp predicates are more tolerant of partial input (e.g. preventing errors while the user is typing a query into ~org-ql-find~).
+ Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~). + Query parser ignores leading whitespace (e.g. preventing errors while the user is typing a query into ~org-ql-find~).
+ Use of ~org-ql-find~ with ~:query-prefix~ argument prevented selection of results. ([[https://github.com/alphapapa/org-ql/issues/351][#351]]. Thanks to [[https://github.com/danielfleischer][Daniel Fleischer]] for reporting.)
** 0.7.1 ** 0.7.1

View file

@ -172,8 +172,6 @@ single predicate)."
;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred)) ;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred))
(all-completions string table pred)) (all-completions string table pred))
(collection (input _pred flag) (collection (input _pred flag)
(when query-prefix
(setf input (concat query-prefix input)))
(pcase flag (pcase flag
('metadata (list 'metadata ('metadata (list 'metadata
(cons 'group-function #'group) (cons 'group-function #'group)
@ -224,6 +222,8 @@ single predicate)."
`(boundaries 0 . ,(length suffix))))) `(boundaries 0 . ,(length suffix)))))
(run-query (input) (run-query (input)
;; (debug-message "RUN-QUERY:%S" input) ;; (debug-message "RUN-QUERY:%S" input)
(when query-prefix
(setf input (concat query-prefix input)))
(unless (or (string-empty-p input) (unless (or (string-empty-p input)
(equal last-input input)) (equal last-input input))
;; (debug-message "RUN-QUERY:%S RUNNING" input) ;; (debug-message "RUN-QUERY:%S RUNNING" input)

View file

@ -1033,6 +1033,10 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog
org-ql-find). org-ql-find).
• Query parser ignores leading whitespace (e.g. preventing errors • Query parser ignores leading whitespace (e.g. preventing errors
while the user is typing a query into org-ql-find). while the user is typing a query into org-ql-find).
• Use of org-ql-find with :query-prefix argument prevented
selection of results. (#351
(https://github.com/alphapapa/org-ql/issues/351). Thanks to Daniel
Fleischer (https://github.com/danielfleischer) for reporting.)
 
File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog File: README.info, Node: 071, Next: 07, Prev: 072-pre, Up: Changelog
@ -1774,37 +1778,37 @@ Node: Links37257
Node: Tips37944 Node: Tips37944
Node: Changelog38268 Node: Changelog38268
Node: 072-pre39053 Node: 072-pre39053
Node: 07139446 Node: 07139697
Node: 0740259 Node: 0740510
Node: 06343183 Node: 06343434
Node: 06243714 Node: 06243965
Node: 06144019 Node: 06144270
Node: 0644587 Node: 0644838
Node: 05247641 Node: 05247892
Node: 05147941 Node: 05148192
Node: 0548364 Node: 0548615
Node: 04949895 Node: 04950146
Node: 04850177 Node: 04850428
Node: 04750526 Node: 04750777
Node: 04650935 Node: 04651186
Node: 04551343 Node: 04551594
Node: 04451704 Node: 04451955
Node: 04352063 Node: 04352314
Node: 04252266 Node: 04252517
Node: 04152427 Node: 04152678
Node: 0452674 Node: 0452925
Node: 03256775 Node: 03257026
Node: 03157178 Node: 03157429
Node: 0357375 Node: 0357626
Node: 02360675 Node: 02360926
Node: 02260909 Node: 02261160
Node: 02161189 Node: 02161440
Node: 0261394 Node: 0261645
Node: 0165472 Node: 0165723
Node: Notes65573 Node: Notes65824
Node: Comparison with Org Agenda searches65735 Node: Comparison with Org Agenda searches65986
Node: org-sidebar66624 Node: org-sidebar66875
Node: License66903 Node: License67154
 
End Tag Table End Tag Table