diff --git a/lisp/org.el b/lisp/org.el index 71dbc611e..b8e6d47c2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20482,7 +20482,12 @@ entry." "Move forward to the ARG'th subheading at same level as this one. Stop at the first and last subheadings of a superior heading. Normally this only looks at visible headings, but when INVISIBLE-OK is -non-nil it will also look at invisible ones." +non-nil it will also look at invisible ones. + +If INVISIBLE-OK is set to the symbol `except-folding', continue +ignoring all parts that are invisible due to folding of a +headline, a block or a drawer, i.e., not because of +fontification." (interactive "p") (let ((backward? (and arg (< arg 0)))) (if (org-before-first-heading-p) @@ -20495,12 +20500,14 @@ non-nil it will also look at invisible ones." (result (point))) (while (and (> count 0) (funcall f org-outline-regexp-bol nil 'move)) - (let ((l (- (match-end 0) (match-beginning 0) 1))) + (let ((l (- (match-end 0) (match-beginning 0) 1)) + (folding-only (eq 'except-folding invisible-ok))) (cond ((< l level) (setq count 0)) ((and (= l level) - (or invisible-ok + (or (and invisible-ok (not folding-only)) (not (org-invisible-p - (line-beginning-position))))) + (line-beginning-position) + folding-only)))) (cl-decf count) (when (= l level) (setq result (point))))))) (goto-char result))