org.el/org-in-commented-heading-p: Support cache and passing element arg
This commit is contained in:
parent
399a29c4f4
commit
86345df9ab
36
lisp/org.el
36
lisp/org.el
|
@ -20612,20 +20612,32 @@ instead of back to heading."
|
|||
"Non-nil when on a headline."
|
||||
(outline-on-heading-p t))
|
||||
|
||||
(defun org-in-commented-heading-p (&optional no-inheritance)
|
||||
(defun org-in-commented-heading-p (&optional no-inheritance element)
|
||||
"Non-nil if point is under a commented heading.
|
||||
This function also checks ancestors of the current headline,
|
||||
unless optional argument NO-INHERITANCE is non-nil."
|
||||
(cond
|
||||
((org-before-first-heading-p) nil)
|
||||
((let ((headline (nth 4 (org-heading-components))))
|
||||
(and headline
|
||||
(let ((case-fold-search nil))
|
||||
(string-match-p (concat "^" org-comment-string "\\(?: \\|$\\)")
|
||||
headline)))))
|
||||
(no-inheritance nil)
|
||||
(t
|
||||
(save-excursion (and (org-up-heading-safe) (org-in-commented-heading-p))))))
|
||||
unless optional argument NO-INHERITANCE is non-nil.
|
||||
|
||||
Optional argument ELEMENT contains element at point."
|
||||
(save-match-data
|
||||
(if-let ((el (or element (org-element-at-point nil 'cached))))
|
||||
(catch :found
|
||||
(setq el (org-element-lineage el '(headline) 'include-self))
|
||||
(if no-inheritance
|
||||
(org-element-property :commentedp el)
|
||||
(while el
|
||||
(when (org-element-property :commentedp el)
|
||||
(throw :found t))
|
||||
(setq el (org-element-property :parent el)))))
|
||||
(cond
|
||||
((org-before-first-heading-p) nil)
|
||||
((let ((headline (nth 4 (org-heading-components))))
|
||||
(and headline
|
||||
(let ((case-fold-search nil))
|
||||
(string-match-p (concat "^" org-comment-string "\\(?: \\|$\\)")
|
||||
headline)))))
|
||||
(no-inheritance nil)
|
||||
(t
|
||||
(save-excursion (and (org-up-heading-safe) (org-in-commented-heading-p))))))))
|
||||
|
||||
(defun org-in-archived-heading-p (&optional no-inheritance)
|
||||
"Non-nil if point is under an archived heading.
|
||||
|
|
Loading…
Reference in New Issue