Function: org-goto-sibling

org-goto-sibling is a byte-compiled function defined in org.el.gz.

Signature

(org-goto-sibling &optional PREVIOUS)

Documentation

Goto the next sibling heading, even if it is invisible.

When PREVIOUS is set, go to the previous sibling instead. Returns t when a sibling was found. When none is found, return nil and don't move point.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-goto-sibling (&optional previous)
  "Goto the next sibling heading, even if it is invisible.
When PREVIOUS is set, go to the previous sibling instead.  Returns t
when a sibling was found.  When none is found, return nil and don't
move point."
  (let ((fun (if previous 're-search-backward 're-search-forward))
	(pos (point))
	(re org-outline-regexp-bol)
	level l)
    (when (ignore-errors (org-back-to-heading t))
      (when (org-element-type-p (org-element-at-point) 'inlinetask)
        (org-up-heading-safe))
      (setq level (funcall outline-level))
      (catch 'exit
	(or previous (forward-char 1))
	(while (funcall fun re nil t)
	  (setq l (funcall outline-level))
	  (when (< l level) (goto-char pos) (throw 'exit nil))
	  (when (= l level) (goto-char (match-beginning 0)) (throw 'exit t)))
	(goto-char pos)
	nil))))