> Probably, it is easier if you just use seq-every-p instead of > mapcar on (number-sequence max-pos min-pos -1). The result of > seq-every-p will be inverse of the currently used expression.
Oh yeah, that's much nicer. I also made the predicate check right-to-left, which just causes it to check the text bit of a heading first, which is useful for the cases where the predicate returns t and makes no difference otherwise. I again ran the tests and it seems ready to go. Cheers, D.
>From 9ae3dd4b73b2b9b41244bb7f9c610ed3f4777398 Mon Sep 17 00:00:00 2001 From: "D. Williams" <d.willi...@posteo.net> Date: Sun, 30 Aug 2020 23:58:55 +0200 Subject: [PATCH] org.el: let heading navigation check the entire heading for visibility * org.el (org-forward-heading-same-level): check complete heading instead of the first char TINYCHANGE --- lisp/org.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 71dbc611e..f44f94ec4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20478,6 +20478,14 @@ entry." ((looking-at-p re) (forward-line)) (t (throw 'exit t)))))))) +(defun org--line-visible-p () + "Return t if the current line is partially visible." + (not + (seq-every-p #'org-invisible-p + (number-sequence (1- (line-end-position)) + (line-beginning-position) + -1)))) + (defun org-forward-heading-same-level (arg &optional invisible-ok) "Move forward to the ARG'th subheading at same level as this one. Stop at the first and last subheadings of a superior heading. @@ -20499,8 +20507,7 @@ non-nil it will also look at invisible ones." (cond ((< l level) (setq count 0)) ((and (= l level) (or invisible-ok - (not (org-invisible-p - (line-beginning-position))))) + (org--line-visible-p))) (cl-decf count) (when (= l level) (setq result (point))))))) (goto-char result)) -- 2.26.2