Function: org-fold-core-get-region-at-point

org-fold-core-get-region-at-point is a byte-compiled function defined in org-fold-core.el.gz.

Signature

(org-fold-core-get-region-at-point &optional SPEC-OR-ALIAS POM)

Documentation

Return region folded using SPEC-OR-ALIAS at POM.

If SPEC is nil, return the largest possible folded region. The return value is a cons of beginning and the end of the region. Return nil when no fold is present at point of POM.

Aliases

org-fold-get-region-at-point

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-fold-core.el.gz
(defun org-fold-core-get-region-at-point (&optional spec-or-alias pom)
  "Return region folded using SPEC-OR-ALIAS at POM.
If SPEC is nil, return the largest possible folded region.
The return value is a cons of beginning and the end of the region.
Return nil when no fold is present at point of POM."
  (let ((spec (org-fold-core-get-folding-spec-from-alias spec-or-alias)))
    (org-with-point-at (or pom (point))
      (if spec
          (if (eq org-fold-core-style 'text-properties)
	      (org-find-text-property-region (point) (org-fold-core--property-symbol-get-create spec nil t))
            (let ((ov (cdr (get-char-property-and-overlay (point) (org-fold-core--property-symbol-get-create spec nil t)))))
              (when ov (cons (overlay-start ov) (overlay-end ov)))))
        (let ((region (cons (point) (point))))
	  (dolist (spec (org-fold-core-get-folding-spec 'all))
            (let ((local-region (org-fold-core-get-region-at-point spec)))
              (when (< (car local-region) (car region))
                (setcar region (car local-region)))
              (when (> (cdr local-region) (cdr region))
                (setcdr region (cdr local-region)))))
	  (unless (eq (car region) (cdr region)) region))))))