From 2971ab6126882f1a49f72750d9adcbaeb9534b7c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 29 Feb 2016 16:25:24 +0100 Subject: [PATCH] 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 --- lisp/org.el | 16 +++++++++------- testing/lisp/test-org.el | 7 ++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index bff37c576..ea75d2ee6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11714,18 +11714,20 @@ order.") Outline path is a list of strings, in reverse order. When 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." (org-back-to-heading t) (or (and use-cache (cdr (assq (point) org-outline-path-cache))) (let ((p (point)) - (heading (progn (looking-at org-complex-heading-regexp) - (org-trim - ;; Remove statistical/checkboxes cookies. - (replace-regexp-in-string - "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" - (org-match-string-no-properties 4)))))) + (heading (progn + (looking-at org-complex-heading-regexp) + (if (not (match-end 4)) "" + ;; Remove statistics cookies. + (org-trim + (replace-regexp-in-string + "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" + (org-match-string-no-properties 4))))))) (if (org-up-heading-safe) (let ((path (cons heading (org--get-outline-path-1 use-cache)))) (when use-cache diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 5ce5c990e..e64bdf4cf 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1340,7 +1340,12 @@ (setq org-outline-path-cache nil) (org-get-outline-path t) (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 () "Test `org-format-outline-path' specifications."