Add workaround for org-ql to find links with brackets in description
This will be tested now and then reported upstream.
This commit is contained in:
parent
16afbd038f
commit
949b49226d
51
init.el
51
init.el
|
@ -950,7 +950,56 @@
|
|||
:ensure org-ql
|
||||
:commands (org-ql-view
|
||||
org-ql-search
|
||||
org-dblock-write:org-ql))
|
||||
org-dblock-write:org-ql)
|
||||
|
||||
:config (progn
|
||||
|
||||
;; Redefine the regular expression for link searches to allow
|
||||
;; brackets in the description. This function comes straight from
|
||||
;; org-ql.el
|
||||
(cl-defun org-ql--link-regexp (&key description-or-target description target)
|
||||
"Return a regexp matching Org links according to arguments.
|
||||
Each argument is treated as a regexp (so non-regexp strings
|
||||
should be quoted before being passed to this function). If
|
||||
DESCRIPTION-OR-TARGET, match it in either description or target.
|
||||
If DESCRIPTION, match it in the description. If TARGET, match it
|
||||
in the target. If both DESCRIPTION and TARGET, match both,
|
||||
respectively."
|
||||
(cl-labels
|
||||
((no-desc
|
||||
(match) (rx-to-string `(seq (or bol (1+ blank))
|
||||
"[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]")))
|
||||
"]]")))
|
||||
(match-both
|
||||
(description target)
|
||||
(rx-to-string `(seq (or bol (1+ blank))
|
||||
"[[" (0+ (not (any "]"))) (regexp ,target) (0+ (not (any "]")))
|
||||
;; Added `anything'
|
||||
"][" (0+ anything) (regexp ,description) (0+ anything)
|
||||
"]]")))
|
||||
;; Note that these actually allow empty descriptions
|
||||
;; or targets, depending on what they are matching.
|
||||
(match-desc
|
||||
(match) (rx-to-string `(seq (or bol (1+ blank))
|
||||
"[[" (0+ (not (any "]")))
|
||||
;; Added `anything'
|
||||
"][" (0+ anything) (regexp ,match) (0+ anything)
|
||||
"]]")))
|
||||
(match-target
|
||||
(match) (rx-to-string `(seq (or bol (1+ blank))
|
||||
"[[" (0+ (not (any "]"))) (regexp ,match) (0+ (not (any "]")))
|
||||
;; Added `anything'
|
||||
"][" (0+ anything)
|
||||
"]]"))))
|
||||
(cond (description-or-target
|
||||
(rx-to-string `(or (regexp ,(no-desc description-or-target))
|
||||
(regexp ,(match-desc description-or-target))
|
||||
(regexp ,(match-target description-or-target)))))
|
||||
((and description target)
|
||||
(match-both description target))
|
||||
(description (match-desc description))
|
||||
(target (rx-to-string `(or (regexp ,(no-desc target))
|
||||
(regexp ,(match-target target))))))))))
|
||||
|
||||
(use-package ol
|
||||
:init (setq org-link-keep-stored-after-insertion t)
|
||||
|
|
Loading…
Reference in New Issue