org-get-outline-path: Drop COMMENT keywords from the outline path

* lisp/org.el (org--get-outline-path-1): Remove comment keyword from
title when current heading is commented.
* testing/lisp/test-org.el (test-org/get-outline-path): Add test.
This commit is contained in:
Ihor Radchenko 2024-01-18 15:13:04 +01:00
parent a19a72f7d3
commit 92c53f23d3
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 12 additions and 1 deletions

View File

@ -7500,6 +7500,8 @@ Assume buffer is widened and point is on a headline."
(replace-regexp-in-string
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
(match-string-no-properties 4))))))))
(when (org-element-property :commentedp (org-element-at-point))
(setq heading (replace-regexp-in-string (format "^%s[ \t]*" org-comment-string) "" heading)))
(if (org-up-heading-safe)
(let ((path (cons heading (org--get-outline-path-1 use-cache))))
(when use-cache

View File

@ -2780,7 +2780,16 @@ test <point>
(org-get-outline-path)))
(should
(org-test-with-temp-text "* \n** H<point>"
(org-get-outline-path))))
(org-get-outline-path)))
;; Remove COMMENTED keywords.
(should
(equal '("This" "is")
(org-test-with-temp-text
"* COMMENT This
** COMMENT is
*** test<point>
"
(org-get-outline-path)))))
(ert-deftest test-org/format-outline-path ()
"Test `org-format-outline-path' specifications."