Function: org-fold-core-get-regions
org-fold-core-get-regions is a byte-compiled function defined in
org-fold-core.el.gz.
Signature
(org-fold-core-get-regions &key SPECS FROM TO WITH-MARKERS RELATIVE)
Documentation
Find all the folded regions in current buffer.
Each element of the returned list represent folded region boundaries and the folding spec: (BEG END SPEC).
Search folds intersecting with (FROM TO) buffer region if FROM and TO are provided.
If FROM is non-nil and TO is nil, search the folded regions at FROM.
When both FROM and TO are nil, search folded regions in the whole buffer.
When SPECS is non-nil it should be a list of folding specs or a symbol. Only return the matching fold types.
When WITH-MARKERS is non-nil, use markers to represent region boundaries.
When RELATIVE is a buffer position, regions boundaries are given relative to that position. When RELATIVE is t, use FROM as the position. WITH-MARKERS must be nil when RELATIVE is non-nil.
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-fold-core.el.gz
(cl-defun org-fold-core-get-regions (&key specs from to with-markers relative)
"Find all the folded regions in current buffer.
Each element of the returned list represent folded region boundaries
and the folding spec: (BEG END SPEC).
Search folds intersecting with (FROM TO) buffer region if FROM and TO
are provided.
If FROM is non-nil and TO is nil, search the folded regions at FROM.
When both FROM and TO are nil, search folded regions in the whole buffer.
When SPECS is non-nil it should be a list of folding specs or a symbol.
Only return the matching fold types.
When WITH-MARKERS is non-nil, use markers to represent region
boundaries.
When RELATIVE is a buffer position, regions boundaries are given
relative to that position.
When RELATIVE is t, use FROM as the position.
WITH-MARKERS must be nil when RELATIVE is non-nil."
(when (and relative with-markers)
(error "Cannot use markers in non-absolute region boundaries"))
(when (eq relative t) (setq relative from))
(unless (listp specs) (setq specs (list specs)))
(let (regions region mk-region)
(org-with-wide-buffer
(when (and (not from) (not to))
(setq from (point-min)
to (point-max)))
(when (and from (not to)) (setq to (point-max)))
(when (and from (< from (point-min))) (setq from (point-min)))
(when (and to (> to (point-max))) (setq to (point-max)))
(unless from (setq from (point-min)))
(dolist (spec (or specs (org-fold-core-folding-spec-list)) regions)
(goto-char from)
(catch :exit
(while (or (not to) (< (point) to))
(when (org-fold-core-get-folding-spec spec)
(setq region (org-fold-core-get-region-at-point spec))
(when relative
(cl-decf (car region) relative)
(cl-decf (cdr region) relative))
(if (not with-markers)
(setq mk-region `(,(car region) ,(cdr region) ,spec))
(setq mk-region `(,(make-marker) ,(make-marker) ,spec))
(move-marker (nth 0 mk-region) (car region))
(move-marker (nth 1 mk-region) (cdr region)))
(push mk-region regions))
(unless to (throw :exit nil))
(goto-char (org-fold-core-next-folding-state-change spec nil to))))))))