Function: org-fold--reveal-outline-maybe
org-fold--reveal-outline-maybe is a byte-compiled function defined in
org-fold.el.gz.
Signature
(org-fold--reveal-outline-maybe REGION _)
Documentation
Reveal folded outline in REGION when needed.
This function is intended to be used as :fragile property of
org-fold-outline spec. See org-fold-core--specs for details.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-fold.el.gz
(defun org-fold--reveal-outline-maybe (region _)
"Reveal folded outline in REGION when needed.
This function is intended to be used as :fragile property of
`org-fold-outline' spec. See `org-fold-core--specs' for details."
(save-match-data
(org-with-wide-buffer
(goto-char (car region))
;; The line before beginning of the fold should be either a
;; headline or a list item.
(backward-char)
(beginning-of-line)
;; Make sure that headline is not partially hidden.
(unless (org-fold-folded-p nil 'headline)
(org-fold--reveal-headline-at-point))
;; Never hide level 1 headlines
(save-excursion
(goto-char (line-end-position))
(unless (>= (point) (cdr region))
(when (re-search-forward (rx bol "* ") (cdr region) t)
(org-fold--reveal-headline-at-point))))
;; Make sure that headline after is not partially hidden.
(goto-char (cdr region))
(beginning-of-line)
(unless (org-fold-folded-p nil 'headline)
(when (looking-at-p org-element-headline-re)
(org-fold--reveal-headline-at-point)))
;; Check the validity of headline
(goto-char (car region))
(backward-char)
(beginning-of-line)
(unless (let ((case-fold-search t))
(looking-at (rx-to-string
`(or (regex ,(org-item-re))
(regex ,org-outline-regexp-bol)))))
t))))