This commit is contained in:
Adam Porter 2020-11-21 16:37:03 -06:00
parent 5f1dc17e68
commit 64e4f8de89

View file

@ -1388,11 +1388,7 @@ COMPARATOR may be `<', `<=', `>', or `>='."
((pred symbolp) ;; Compare with function ((pred symbolp) ;; Compare with function
(funcall level-or-comparator outline-level level))))) (funcall level-or-comparator outline-level level)))))
;;;;;; Old definitions (org-ql-define-predicate link (&rest args)
;; MAYBE: Preambles for outline-path predicates. Not sure if possible without complicated logic.
(org-ql--defpred link (&rest args)
;; User-facing argument form: (&optional description-or-target &key description target regexp-p). ;; User-facing argument form: (&optional description-or-target &key description target regexp-p).
"Return non-nil if current heading contains a link matching arguments. "Return non-nil if current heading contains a link matching arguments.
DESCRIPTION-OR-TARGET is matched against the link's description DESCRIPTION-OR-TARGET is matched against the link's description
@ -1405,7 +1401,27 @@ any link is found."
;; "FOO")" in the view header, which would be ugly. So, since preambles are expected to be ;; "FOO")" in the view header, which would be ugly. So, since preambles are expected to be
;; enabled nearly all of the time, in which case this function won't be called anyway, it's ;; enabled nearly all of the time, in which case this function won't be called anyway, it's
;; probably not worth rewriting code all over the place to fix this. ;; probably not worth rewriting code all over the place to fix this.
(let* (plist description-or-target description target regexp-p) :preambles ((`(,predicate-names)
(list :regexp ;; Match a link with a target and optionally a description.
(rx (or bol (1+ blank))
"[[" (1+ (not (any "]"))) "]"
(optional (seq "[" (0+ (not (any "]"))) "]"))
"]"
(or eol blank))))
(`(,predicate-names ,(and description-or-target
(guard (not (keywordp description-or-target)))))
(list :regexp (org-ql--link-regexp :description-or-target
(regexp-quote description-or-target)))
nil)
(`(,predicate-names . ,plist)
(list :regexp (org-ql--link-regexp
:description
(when (plist-get plist :description)
(regexp-quote (plist-get plist :description)))
:target (when (plist-get plist :target)
(regexp-quote (plist-get plist :target)))))
nil))
:predicate (let* (plist description-or-target description target regexp-p)
(if (not (keywordp (car args))) (if (not (keywordp (car args)))
(setf description-or-target (car args) (setf description-or-target (car args)
plist (cdr args)) plist (cdr args))
@ -1437,6 +1453,10 @@ any link is found."
(string-match-p description-or-target (string-match-p description-or-target
(match-string org-ql-link-description-group))))))))) (match-string org-ql-link-description-group)))))))))
;;;;;; Old definitions
;; MAYBE: Preambles for outline-path predicates. Not sure if possible without complicated logic.
(org-ql--defpred priority (&rest args) (org-ql--defpred priority (&rest args)
"Return non-nil if current heading has a certain priority. "Return non-nil if current heading has a certain priority.
ARGS may be either a list of one or more priority letters as ARGS may be either a list of one or more priority letters as