Another try to the fix org-ql link regexp generator

The previous version caused stack overflows in the regexp matcher, supposedly
because of matching newlines in the description.  This should not happend
anymore, but description won't be matched anymore of they contain a line break.
This commit is contained in:
Daniel Borchmann 2022-06-09 21:20:55 +02:00
parent 949b49226d
commit 72c67796c2
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625

13
init.el
View File

@ -974,23 +974,22 @@ respectively."
(description target) (description target)
(rx-to-string `(seq (or bol (1+ blank)) (rx-to-string `(seq (or bol (1+ blank))
"[[" (0+ (not (any "]"))) (regexp ,target) (0+ (not (any "]"))) "[[" (0+ (not (any "]"))) (regexp ,target) (0+ (not (any "]")))
;; Added `anything' ;; Added .* wildcards
"][" (0+ anything) (regexp ,description) (0+ anything) "][" (regexp ".*") (regexp ,description) (regexp ".*")
"]]"))) "]]")))
;; Note that these actually allow empty descriptions ;; Note that these actually allow empty descriptions
;; or targets, depending on what they are matching. ;; or targets, depending on what they are matching.
(match-desc (match-desc
(match) (rx-to-string `(seq (or bol (1+ blank)) (match) (rx-to-string `(seq (or bol (1+ blank))
"[[" (0+ (not (any "]"))) "[[" (0+ (not (any "]")))
;; Added `anything' ;; Added .* wildcards
"][" (0+ anything) (regexp ,match) (0+ anything) "][" (regexp ".*") (regexp ,match) (regexp ".*")
"]]"))) "]]")))
(match-target (match-target
(match) (rx-to-string `(seq (or bol (1+ blank)) (match) (rx-to-string `(seq (or bol (1+ blank))
"[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]"))) "[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]")))
;; Added `anything' ;; Removed pattern for description
"][" (0+ anything) "][" ))))
"]]"))))
(cond (description-or-target (cond (description-or-target
(rx-to-string `(or (regexp ,(no-desc description-or-target)) (rx-to-string `(or (regexp ,(no-desc description-or-target))
(regexp ,(match-desc description-or-target)) (regexp ,(match-desc description-or-target))