Jelajahi Sumber

org.el: Let `org-forward-heading-same-level' check for fully invisible lines

* lisp/org.el (org--line-fully-invisible-p): New function.
(org-forward-heading-same-level): Use it to check whether the line
is fully invisible.

TINYCHANGE

See <https://orgmode.org/list/51b41109-997c-db37-c0ed-44e8d0154cee@posteo.net/>
D 5 tahun lalu
induk
melakukan
a700fadd72
1 mengubah file dengan 11 tambahan dan 2 penghapusan
  1. 11 2
      lisp/org.el

+ 11 - 2
lisp/org.el

@@ -20514,6 +20514,16 @@ entry."
 		((looking-at-p re) (forward-line))
 		((looking-at-p re) (forward-line))
 		(t (throw 'exit t))))))))
 		(t (throw 'exit t))))))))
 
 
+(defun org--line-fully-invisible-p ()
+  "Return non-nil if the current line is fully invisible."
+  (let ((line-beg (line-beginning-position))
+	(line-pos (1- (line-end-position)))
+	(is-invisible t))
+    (while (and (< line-beg line-pos) is-invisible)
+      (setq is-invisible (org-invisible-p line-pos))
+      (setq line-pos (1- line-pos)))
+    is-invisible))
+
 (defun org-forward-heading-same-level (arg &optional invisible-ok)
 (defun org-forward-heading-same-level (arg &optional invisible-ok)
   "Move forward to the ARG'th subheading at same level as this one.
   "Move forward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading.
 Stop at the first and last subheadings of a superior heading.
@@ -20535,8 +20545,7 @@ non-nil it will also look at invisible ones."
 	    (cond ((< l level) (setq count 0))
 	    (cond ((< l level) (setq count 0))
 		  ((and (= l level)
 		  ((and (= l level)
 			(or invisible-ok
 			(or invisible-ok
-			    (not (org-invisible-p
-				  (line-beginning-position)))))
+			    (not (org--line-fully-invisible-p))))
 		   (cl-decf count)
 		   (cl-decf count)
 		   (when (= l level) (setq result (point)))))))
 		   (when (= l level) (setq result (point)))))))
 	(goto-char result))
 	(goto-char result))