mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-24 13:02:52 +00:00
org-goto-sibling: Fix when called from inlinetask
* lisp/org.el (org-goto-sibling): Do not try to find inlinetask siblings. Clarify the docstring. * testing/lisp/test-org.el (test-org/goto-sibling): New test.
This commit is contained in:
parent
345d4e09b5
commit
63e8cac2ca
|
@ -20637,7 +20637,7 @@ point before the first headline or at point-min."
|
|||
(< l level)))))
|
||||
|
||||
(defun org-goto-sibling (&optional previous)
|
||||
"Goto the next sibling, even if it is invisible.
|
||||
"Goto the next sibling heading, even if it is invisible.
|
||||
When PREVIOUS is set, go to the previous sibling instead. Returns t
|
||||
when a sibling was found. When none is found, return nil and don't
|
||||
move point."
|
||||
|
@ -20646,6 +20646,8 @@ move point."
|
|||
(re org-outline-regexp-bol)
|
||||
level l)
|
||||
(when (ignore-errors (org-back-to-heading t))
|
||||
(when (org-element-type-p (org-element-at-point) 'inlinetask)
|
||||
(org-up-heading-safe))
|
||||
(setq level (funcall outline-level))
|
||||
(catch 'exit
|
||||
(or previous (forward-char 1))
|
||||
|
|
|
@ -2449,6 +2449,65 @@ Text.
|
|||
(should-not (org-up-heading-safe))
|
||||
(should (looking-at-p "^\\*\\* H2"))))
|
||||
|
||||
(ert-deftest test-org/goto-sibling ()
|
||||
"Test `org-goto-sibling' specifications."
|
||||
(org-test-with-temp-text
|
||||
"* Parent
|
||||
** Heading 1
|
||||
** Heading 2 <point>
|
||||
** Heading 3"
|
||||
(should (org-goto-sibling))
|
||||
(should (looking-at-p "^\\*\\* Heading 3"))
|
||||
(should-not (org-goto-sibling))
|
||||
(should (org-goto-sibling 'previous))
|
||||
(should (looking-at-p "^\\*\\* Heading 2"))
|
||||
(should (org-goto-sibling 'previous))
|
||||
(should (looking-at-p "^\\*\\* Heading 1"))
|
||||
(should-not (org-goto-sibling 'previous)))
|
||||
;; Inside heading.
|
||||
(org-test-with-temp-text
|
||||
"* Parent
|
||||
** Heading 1
|
||||
** Heading 2
|
||||
Some text.<point>
|
||||
** Heading 3"
|
||||
(should (org-goto-sibling))
|
||||
(should (looking-at-p "^\\*\\* Heading 3")))
|
||||
(org-test-with-temp-text
|
||||
"* Parent
|
||||
** Heading 1
|
||||
** Heading 2
|
||||
Some text.<point>
|
||||
** Heading 3"
|
||||
(should (org-goto-sibling 'previous))
|
||||
(should (looking-at-p "^\\*\\* Heading 1")))
|
||||
(org-test-with-temp-text
|
||||
"* Parent
|
||||
** Heading 2
|
||||
Some text.<point>
|
||||
"
|
||||
(should-not (org-goto-sibling))
|
||||
(should-not (org-goto-sibling 'previous)))
|
||||
;; Ignore inlinetasks.
|
||||
(let ((org-inlinetask-min-level 3))
|
||||
(org-test-with-temp-text
|
||||
"* Parent
|
||||
** Heading 1
|
||||
** Heading 2
|
||||
*** Inlinetask 1
|
||||
test <point>
|
||||
*** END
|
||||
*** Inlinetask 2
|
||||
** Heading 3"
|
||||
(should (org-goto-sibling))
|
||||
(should (looking-at-p "^\\*\\* Heading 3"))
|
||||
(should-not (org-goto-sibling))
|
||||
(should (org-goto-sibling 'previous))
|
||||
(should (looking-at-p "^\\*\\* Heading 2"))
|
||||
(should (org-goto-sibling 'previous))
|
||||
(should (looking-at-p "^\\*\\* Heading 1"))
|
||||
(should-not (org-goto-sibling 'previous)))))
|
||||
|
||||
(ert-deftest test-org/get-heading ()
|
||||
"Test `org-get-heading' specifications."
|
||||
;; Return current heading, even if point is not on it.
|
||||
|
|
Loading…
Reference in a new issue