Skip to content

Commit

Permalink
Fix: (level) Check number argument for preamble
Browse files Browse the repository at this point in the history
This allows a query like this:

  (level <= (string-to-number (property PROPERTY)))

to proceed without signaling an error from ORG-QL--QUERY-PREAMBLE.

See #460.

Reported-by: Stewmath <https://github.com/Stewmath>
  • Loading branch information
alphapapa committed Sep 5, 2024
1 parent 3e7f48a commit 513107e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 45 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:

*Fixes*
+ Predicate ~property~ when called with argument form ~(property "PROPERTY-NAME" :inherit t)~. ([[https://github.com/alphapapa/org-ql/issues/460][#460]]. Thanks to [[https://github.com/Stewmath][Stewmath]] for reporting.)
+ Predicate ~level~'s preamble optimizer allows expressions in place of the numeric argument (see [[https://github.com/alphapapa/org-ql/issues/460][#460]]. Thanks to [[https://github.com/Stewmath][Stewmath]] for reporting.)
+ Reading of view settings from Org links in upcoming Emacs version. ([[https://github.com/alphapapa/org-ql/issues/461][#461]]. Thanks to [[https://github.com/snogge][Ola Nilsson]] for help debugging, and for maintaining [[https://github.com/jorgenschaefer/emacs-buttercup][Buttercup]].)

** 0.8.8
Expand Down
6 changes: 4 additions & 2 deletions org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
;; is "h:" while the user is typing.
(list :regexp (rx bol (1+ "*") " ")
:case-fold t))
(`(,predicate-names ,comparator-or-num ,num)
((and `(,predicate-names ,comparator-or-num ,num)
(guard (numberp num)))
(let ((repeat (pcase comparator-or-num
('< `(repeat 1 ,(1- num) "*"))
('<= `(repeat 1 ,num "*"))
Expand All @@ -1543,7 +1544,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
((pred integerp) `(repeat ,comparator-or-num ,num "*")))))
(list :regexp (rx-to-string `(seq bol ,repeat " ") t)
:case-fold t)))
(`(,predicate-names ,num)
((and `(,predicate-names ,num)
(guard (numberp num)))
(list :regexp (rx-to-string `(seq bol (repeat ,num "*") " ") t)
:case-fold t)))
;; NOTE: It might be necessary to take into account `org-odd-levels'; see docstring for
Expand Down
90 changes: 47 additions & 43 deletions org-ql.info
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,10 @@ File: README.info, Node: 089-pre, Next: 088, Up: Changelog
"PROPERTY-NAME" :inherit t)’. (#460
(https://github.com/alphapapa/org-ql/issues/460). Thanks to
Stewmath (https://github.com/Stewmath) for reporting.)
• Predicate ‘level’’s preamble optimizer allows expressions in place
of the numeric argument (see #460
(https://github.com/alphapapa/org-ql/issues/460). Thanks to
Stewmath (https://github.com/Stewmath) for reporting.)
• Reading of view settings from Org links in upcoming Emacs version.
(#461 (https://github.com/alphapapa/org-ql/issues/461). Thanks to
Ola Nilsson (https://github.com/snogge) for help debugging, and for
Expand Down Expand Up @@ -2073,49 +2077,49 @@ Node: Links38939
Node: Tips39626
Node: Changelog39950
Node: 089-pre40900
Node: 08841554
Node: 08742634
Node: 08643862
Node: 08544096
Node: 08444752
Node: 08345204
Node: 08245545
Node: 08145938
Node: 0846359
Node: 07449085
Node: 07349310
Node: 07250044
Node: 07150965
Node: 0751776
Node: 06354642
Node: 06255175
Node: 06155482
Node: 0656052
Node: 05259108
Node: 05159410
Node: 0559835
Node: 04961366
Node: 04861648
Node: 04761997
Node: 04662406
Node: 04562814
Node: 04463175
Node: 04363534
Node: 04263737
Node: 04163898
Node: 0464145
Node: 03268246
Node: 03168649
Node: 0368846
Node: 02372146
Node: 02272380
Node: 02172660
Node: 0272865
Node: 0176943
Node: Notes77044
Node: Comparison with Org Agenda searches77206
Node: org-sidebar78095
Node: License78374
Node: 08841799
Node: 08742879
Node: 08644107
Node: 08544341
Node: 08444997
Node: 08345449
Node: 08245790
Node: 08146183
Node: 0846604
Node: 07449330
Node: 07349555
Node: 07250289
Node: 07151210
Node: 0752021
Node: 06354887
Node: 06255420
Node: 06155727
Node: 0656297
Node: 05259353
Node: 05159655
Node: 0560080
Node: 04961611
Node: 04861893
Node: 04762242
Node: 04662651
Node: 04563059
Node: 04463420
Node: 04363779
Node: 04263982
Node: 04164143
Node: 0464390
Node: 03268491
Node: 03168894
Node: 0369091
Node: 02372391
Node: 02272625
Node: 02172905
Node: 0273110
Node: 0177188
Node: Notes77289
Node: Comparison with Org Agenda searches77451
Node: org-sidebar78340
Node: License78619

End Tag Table

Expand Down

0 comments on commit 513107e

Please sign in to comment.