1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

org-back-to-heading: Fix at inlinetask END

* lisp/org.el (org-back-to-heading): Fix when at inlinetask END.
* testing/lisp/test-org.el (test-org/org-back-to-heading): Add new
test.

Reported-by: Alain.Cochard@unistra.fr
Link: https://orgmode.org/list/25508.20192.899342.932809@gargle.gargle.HOWL
This commit is contained in:
Ihor Radchenko 2022-12-25 15:49:28 +03:00
parent f138810065
commit 718e196830
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 46 additions and 1 deletions

View File

@ -20213,7 +20213,10 @@ interactive command with similar behavior."
(defun org-back-to-heading (&optional invisible-ok)
"Go back to beginning of heading."
(beginning-of-line)
(or (org-at-heading-p (not invisible-ok))
(or (and (org-at-heading-p (not invisible-ok))
(not (and (featurep 'org-inlinetask)
(fboundp 'org-inlinetask-end-p)
(org-inlinetask-end-p))))
(if (org-element--cache-active-p)
(let ((heading (org-element-lineage (org-element-at-point)
'(headline inlinetask)

View File

@ -2281,6 +2281,48 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46"
;;; Headline
(ert-deftest test-org/org-back-to-heading ()
"Test `org-back-to-heading' specifications."
;; On heading already
(org-test-with-temp-text "* Head<point>ing"
(org-back-to-heading)
(should (bobp)))
;; Below heading
(org-test-with-temp-text "* Heading
Text<point>"
(org-back-to-heading)
(should (bobp)))
;; At inlinetask
(let ((org-inlinetask-min-level 3))
(org-test-with-temp-text "* Heading
*** Inlinetask <point>"
(org-back-to-heading)
(should (= 11 (point)))))
;; Below inlinetask
(let ((org-inlinetask-min-level 3))
(org-test-with-temp-text "* Heading
*** Inlinetask
Test <point>"
(org-back-to-heading)
;; Not at or inside inlinetask. Move to parent heading.
(should (bobp))))
;; Inside inlinetask
(let ((org-inlinetask-min-level 3))
(org-test-with-temp-text "* Heading
*** Inlinetask
Test <point>
*** END"
(org-back-to-heading)
(should (= 11 (point)))))
;; At END
(let ((org-inlinetask-min-level 3))
(org-test-with-temp-text "* Heading
*** Inlinetask
Test
*** END<point>"
(org-back-to-heading)
(should (= 11 (point))))))
(ert-deftest test-org/get-heading ()
"Test `org-get-heading' specifications."
;; Return current heading, even if point is not on it.