1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-02 08:22:16 +00:00

org-next-visible-heading: Fix when moving over non-descriptive link

* lisp/org.el (org-next-visible-heading): Really test for visibility;
not folding.  Some folds may not be invisible - when
`org-link-descriptive' is nil, links are folded yet visible.
* testing/lisp/test-org.el (test-org/next-visible-heading): Add new
test case.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://orgmode.org/list/m2bk9q7adw.fsf@me.com
This commit is contained in:
Ihor Radchenko 2024-01-13 13:35:52 +01:00
parent 1aa4552e5c
commit c41a89676e
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 9 additions and 3 deletions

View File

@ -21389,13 +21389,13 @@ With ARG, repeats or can move backward if negative."
(end-of-line))
(while (and (< arg 0) (re-search-backward regexp nil :move))
(unless (bobp)
(when (org-fold-folded-p)
(when (org-invisible-p nil t)
(goto-char (org-fold-previous-visibility-change))
(unless (looking-at-p regexp)
(re-search-backward regexp nil :mode))))
(cl-incf arg))
(while (and (> arg 0) (re-search-forward regexp nil :move))
(when (org-fold-folded-p)
(when (org-invisible-p nil t)
(goto-char (org-fold-next-visibility-change))
(skip-chars-forward " \t\n")
(end-of-line))

View File

@ -4069,7 +4069,13 @@ text"
(should
(org-test-with-temp-text "* H1\n* H2\n<point>* H3"
(org-next-visible-heading -2)
(looking-at "\\* H1"))))
(looking-at "\\* H1")))
;; Edge case: visible links.
(should
(let ((org-link-descriptive nil))
(org-test-with-temp-text "* <point>H1\n* [[https://orgmode.org][Org mode]]\n* H3"
(org-next-visible-heading 1)
(looking-at "\\* \\[\\[https:")))))
(ert-deftest test-org/previous-visible-heading ()
"Test `org-previous-visible-heading' specifications."