forked from mirrors/org-mode
org-in-commented-heading-p: Do not parse section unless already cached
* lisp/org.el (org-in-commented-heading-p): When element at point is not yet in cache, parse the parent headline instead of also parsing section up to point.
This commit is contained in:
parent
2f8e688516
commit
147ca39750
33
lisp/org.el
33
lisp/org.el
|
@ -19822,26 +19822,19 @@ unless optional argument NO-INHERITANCE is non-nil.
|
||||||
|
|
||||||
Optional argument ELEMENT contains element at point."
|
Optional argument ELEMENT contains element at point."
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(let ((el (or element (org-element-at-point nil 'cached))))
|
(let ((el (or element
|
||||||
(if el
|
(org-element-at-point nil 'cached)
|
||||||
(catch :found
|
(org-with-wide-buffer
|
||||||
(setq el (org-element-lineage el '(headline inlinetask) 'include-self))
|
(org-back-to-heading-or-point-min t)
|
||||||
(if no-inheritance
|
(org-element-at-point)))))
|
||||||
(org-element-property :commentedp el)
|
(catch :found
|
||||||
(while el
|
(setq el (org-element-lineage el '(headline inlinetask) 'include-self))
|
||||||
(when (org-element-property :commentedp el)
|
(if no-inheritance
|
||||||
(throw :found t))
|
(org-element-property :commentedp el)
|
||||||
(setq el (org-element-property :parent el)))))
|
(while el
|
||||||
(cond
|
(when (org-element-property :commentedp el)
|
||||||
((org-before-first-heading-p) nil)
|
(throw :found t))
|
||||||
((let ((headline (nth 4 (org-heading-components))))
|
(setq el (org-element-property :parent el))))))))
|
||||||
(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 element)
|
(defun org-in-archived-heading-p (&optional no-inheritance element)
|
||||||
"Non-nil if point is under an archived heading.
|
"Non-nil if point is under an archived heading.
|
||||||
|
|
Loading…
Reference in New Issue