From b8f4773bfe19ba1db269bf6d647d59be461ce2c6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 11 Jan 2020 20:04:19 +0100 Subject: [PATCH] Fix "find-visible" functions * lisp/org.el (org-find-visible): (org-find-invisible): Return appropriate position. Add a docstring. --- lisp/org.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 4e0335291..2b3721f58 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17623,15 +17623,16 @@ this numeric value." (t (call-interactively 'org-insert-heading)))) (defun org-find-visible () - (let ((s (point))) - (while (and (not (= (point-max) (setq s (next-overlay-change s)))) - (get-char-property s 'invisible))) - s)) + "Return closest visible buffer position, or `point-max'" + (if (org-invisible-p) + (next-single-char-property-change (point) 'invisible) + (point))) + (defun org-find-invisible () - (let ((s (point))) - (while (and (not (= (point-max) (setq s (next-overlay-change s)))) - (not (get-char-property s 'invisible)))) - s)) + "Return closest invisible buffer position, or `point-max'" + (if (org-invisible-p) + (point) + (next-single-char-property-change (point) 'invisible))) (defun org-copy-visible (beg end) "Copy the visible parts of the region."