Function: allout-next-sibling

allout-next-sibling is a byte-compiled function defined in allout.el.gz.

Signature

(allout-next-sibling &optional DEPTH BACKWARD)

Documentation

Like allout-forward-current-level, but respects invisible topics.

Traverse at optional DEPTH, or current depth if none specified.

Go backward if optional arg BACKWARD is non-nil.

Return the start point of the new topic if successful, nil otherwise.

Source Code

;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_  - Linear
;;;_   > allout-next-sibling (&optional depth backward)
(defun allout-next-sibling (&optional depth backward)
  "Like `allout-forward-current-level', but respects invisible topics.

Traverse at optional DEPTH, or current depth if none specified.

Go backward if optional arg BACKWARD is non-nil.

Return the start point of the new topic if successful, nil otherwise."

  (if (if backward (bobp) (eobp))
      nil
    (let ((target-depth (or depth (allout-depth)))
          (start-point (point))
          (start-prefix-beginning allout-recent-prefix-beginning)
          (count 0)
          leaping
	  last-depth)
      (while (and
              ;; done too few single steps to resort to the leap routine:
              (not leaping)
              ;; not at limit:
              (not (if backward (bobp) (eobp)))
              ;; still traversable:
              (if backward (allout-previous-heading) (allout-next-heading))
              ;; we're below the target depth
              (> (setq last-depth allout-recent-depth) target-depth))
        (setq count (1+ count))
        (if (> count 7)                 ; lists are commonly 7 +- 2, right?-)
            (setq leaping t)))
      (cond (leaping
             (or (allout-next-sibling-leap target-depth backward)
                 (progn
                   (goto-char start-point)
                   (if depth (allout-depth) target-depth)
                   nil)))
            ((and (not (eobp))
                  (and (> (or last-depth (allout-depth)) 0)
                       (= allout-recent-depth target-depth))
                  (not (= start-prefix-beginning
                          allout-recent-prefix-beginning)))
             allout-recent-prefix-beginning)
            (t
             (goto-char start-point)
             (if depth (allout-depth) target-depth)
             nil)))))