Skip to content

Commit

Permalink
Fix: (org-ql-completing-read) :query-prefix prevented selection
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
alphapapa committed Sep 14, 2023
1 parent 1314078 commit 95abce2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Fixes*
+ 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~).
+ 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

Expand Down
4 changes: 2 additions & 2 deletions org-ql-completing-read.el
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ single predicate)."
;; (debug-message "all-completions RETURNS: %S" (all-completions string table pred))
(all-completions string table pred))
(collection (input _pred flag)
(when query-prefix
(setf input (concat query-prefix input)))
(pcase flag
('metadata (list 'metadata
(cons 'group-function #'group)
Expand Down Expand Up @@ -224,6 +222,8 @@ single predicate)."
`(boundaries 0 . ,(length suffix)))))
(run-query (input)
;; (debug-message "RUN-QUERY:%S" input)
(when query-prefix
(setf input (concat query-prefix input)))
(unless (or (string-empty-p input)
(equal last-input input))
;; (debug-message "RUN-QUERY:%S RUNNING" input)
Expand Down
66 changes: 35 additions & 31 deletions org-ql.info
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,10 @@ File: README.info, Node: 072-pre, Next: 071, Up: Changelog
‘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. (#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
Expand Down Expand Up @@ -1774,37 +1778,37 @@ Node: Links37257
Node: Tips37944
Node: Changelog38268
Node: 072-pre39053
Node: 07139446
Node: 0740259
Node: 06343183
Node: 06243714
Node: 06144019
Node: 0644587
Node: 05247641
Node: 05147941
Node: 0548364
Node: 04949895
Node: 04850177
Node: 04750526
Node: 04650935
Node: 04551343
Node: 04451704
Node: 04352063
Node: 04252266
Node: 04152427
Node: 0452674
Node: 03256775
Node: 03157178
Node: 0357375
Node: 02360675
Node: 02260909
Node: 02161189
Node: 0261394
Node: 0165472
Node: Notes65573
Node: Comparison with Org Agenda searches65735
Node: org-sidebar66624
Node: License66903
Node: 07139697
Node: 0740510
Node: 06343434
Node: 06243965
Node: 06144270
Node: 0644838
Node: 05247892
Node: 05148192
Node: 0548615
Node: 04950146
Node: 04850428
Node: 04750777
Node: 04651186
Node: 04551594
Node: 04451955
Node: 04352314
Node: 04252517
Node: 04152678
Node: 0452925
Node: 03257026
Node: 03157429
Node: 0357626
Node: 02360926
Node: 02261160
Node: 02161440
Node: 0261645
Node: 0165723
Node: Notes65824
Node: Comparison with Org Agenda searches65986
Node: org-sidebar66875
Node: License67154

End Tag Table

Expand Down

0 comments on commit 95abce2

Please sign in to comment.