Function: org-fold-core-next-visibility-change

org-fold-core-next-visibility-change is a byte-compiled function defined in org-fold-core.el.gz.

Signature

(org-fold-core-next-visibility-change &optional POS LIMIT IGNORE-HIDDEN-P PREVIOUS-P)

Documentation

Return next point from POS up to LIMIT where text becomes visible/invisible.

By default, text hidden by any means (i.e. not only by folding, but also via fontification) will be considered. If IGNORE-HIDDEN-P is non-nil, consider only folded text. If PREVIOUS-P is non-nil, search backwards.

Aliases

org-fold-next-visibility-change

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-fold-core.el.gz
(defun org-fold-core-next-visibility-change (&optional pos limit ignore-hidden-p previous-p)
  "Return next point from POS up to LIMIT where text becomes visible/invisible.
By default, text hidden by any means (i.e. not only by folding, but
also via fontification) will be considered.
If IGNORE-HIDDEN-P is non-nil, consider only folded text.
If PREVIOUS-P is non-nil, search backwards."
  (let* ((pos (or pos (point)))
	 (invisible-p (if ignore-hidden-p
			  #'org-fold-core-folded-p
			#'invisible-p))
         (invisible-initially? (funcall invisible-p pos))
	 (limit (or limit (if previous-p
			      (point-min)
			    (point-max))))
         (cmp (if previous-p #'> #'<))
	 (next-change (if previous-p
			  (if ignore-hidden-p
                              (lambda (p) (org-fold-core-previous-folding-state-change (org-fold-core-get-folding-spec nil p) p limit))
			    (lambda (p) (max limit (1- (previous-single-char-property-change p 'invisible nil limit)))))
                        (if ignore-hidden-p
                            (lambda (p) (org-fold-core-next-folding-state-change (org-fold-core-get-folding-spec nil p) p limit))
			  (lambda (p) (next-single-char-property-change p 'invisible nil limit)))))
	 (next pos))
    (while (and (funcall cmp next limit)
		(not (org-xor invisible-initially? (funcall invisible-p next))))
      (setq next (funcall next-change next)))
    next))