org-element-ast: New function `org-element-type-p'

This commit is contained in:
Ihor Radchenko 2023-05-16 12:41:39 +02:00
parent ae49451364
commit 6b20a23065
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 13 additions and 0 deletions

View File

@ -226,6 +226,19 @@ when NODE is an anonymous node."
'anonymous)
(t nil)))
(define-inline org-element-type-p (node types)
"Return non-nil when NODE type is one of TYPES.
TYPES can be a type symbol or a list of symbols."
(if (inline-const-p types)
(if (listp (inline-const-val types))
(inline-quote (memq (org-element-type ,node t) ,types))
(inline-quote (eq (org-element-type ,node t) ,types)))
(inline-letevals (node types)
(inline-quote
(if (listp ,types)
(memq (org-element-type ,node t) ,types)
(eq (org-element-type ,node t) ,types))))))
(defun org-element-secondary-p (node)
"Non-nil when NODE directly belongs to a secondary node.
Return value is the containing property name, as a keyword, or nil."