Function: org-end-of-subtree
org-end-of-subtree is a byte-compiled function defined in org.el.gz.
Signature
(org-end-of-subtree &optional INVISIBLE-OK TO-HEADING ELEMENT)
Documentation
Goto to the end of a visible subtree at point or ELEMENT and return point.
The subtree is considered at first heading parent containing point or ELEMENT.
When end of the subtree has blank lines, move point before these blank lines.
When INVISIBLE-OK is non-nil, ignore visibility.
When before first heading, goto point-max minus blank lines.
When TO-HEADING is non-nil, go to the next heading or point-max.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-end-of-subtree (&optional invisible-ok to-heading element)
"Goto to the end of a visible subtree at point or ELEMENT and return point.
The subtree is considered at first heading parent containing point or
ELEMENT.
When end of the subtree has blank lines, move point before these blank
lines.
When INVISIBLE-OK is non-nil, ignore visibility.
When before first heading, goto `point-max' minus blank lines.
When TO-HEADING is non-nil, go to the next heading or `point-max'."
(when element
(setq element (org-element-lineage
element
'(headline)
'include-self))
(goto-char (org-element-begin element)))
(unless (and invisible-ok element)
(org-back-to-heading-or-point-min invisible-ok)
(setq element
(org-element-lineage
(org-element-at-point)
'(headline)
'include-self)))
(if (org-element-type-p element 'headline)
(goto-char (org-element-end element))
(goto-char (point-max)))
(unless to-heading
(when (memq (preceding-char) '(?\n ?\^M))
;; Go to end of line before heading
(forward-char -1)
;; Skip blank lines
(skip-chars-backward "\n\r\t ")))
(point))