Fix `org-get-outline-path'

* lisp/org.el (org--get-outline-path-1): Fix wrong type arrayp error
  when trying to get the outline path of an empty headline.
* testing/lisp/test-org.el (test-org/get-outline-path): Add test.

Reported-by: Tobias Getzner <tobias.getzner@gmx.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/105407>
This commit is contained in:
Nicolas Goaziou 2016-02-29 16:25:24 +01:00
parent dc68d28d67
commit 2971ab6126
2 changed files with 15 additions and 8 deletions

View File

@ -11714,18 +11714,20 @@ order.")
Outline path is a list of strings, in reverse order. When Outline path is a list of strings, in reverse order. When
optional argument USE-CACHE is non-nil, make use of a cache. See optional argument USE-CACHE is non-nil, make use of a cache. See
`org-get-outline-path' for delails. `org-get-outline-path' for details.
Assume buffer is widened." Assume buffer is widened."
(org-back-to-heading t) (org-back-to-heading t)
(or (and use-cache (cdr (assq (point) org-outline-path-cache))) (or (and use-cache (cdr (assq (point) org-outline-path-cache)))
(let ((p (point)) (let ((p (point))
(heading (progn (looking-at org-complex-heading-regexp) (heading (progn
(org-trim (looking-at org-complex-heading-regexp)
;; Remove statistical/checkboxes cookies. (if (not (match-end 4)) ""
(replace-regexp-in-string ;; Remove statistics cookies.
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" (org-trim
(org-match-string-no-properties 4)))))) (replace-regexp-in-string
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
(org-match-string-no-properties 4)))))))
(if (org-up-heading-safe) (if (org-up-heading-safe)
(let ((path (cons heading (org--get-outline-path-1 use-cache)))) (let ((path (cons heading (org--get-outline-path-1 use-cache))))
(when use-cache (when use-cache

View File

@ -1340,7 +1340,12 @@
(setq org-outline-path-cache nil) (setq org-outline-path-cache nil)
(org-get-outline-path t) (org-get-outline-path t)
(search-forward "S2") (search-forward "S2")
(org-get-outline-path t))))) (org-get-outline-path t))))
;; Do not choke on empty headlines.
(should
(org-test-with-temp-text "* "
(setq org-outline-path-cache nil)
(org-get-outline-path t))))
(ert-deftest test-org/format-outline-path () (ert-deftest test-org/format-outline-path ()
"Test `org-format-outline-path' specifications." "Test `org-format-outline-path' specifications."