From 954103dd9b21c6de5d6d9ea638ebb7cd8b5db016 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 30 Mar 2016 15:34:24 +0200 Subject: [PATCH] Fix indentation bug * lisp/org.el (org--get-expected-indentation): Return correct columns when at the end of an empty item. * testing/lisp/test-org.el (test-org/indent-line): Add test. --- lisp/org.el | 7 +++++-- testing/lisp/test-org.el | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5d6ad6dd9..3df694eeb 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -23004,12 +23004,15 @@ ELEMENT." ;; ;; As a special case, if point is at the end of a footnote ;; definition or an item, indent like the very last element - ;; within. + ;; within. If that last element is an item, indent like its + ;; contents. ((and (not (eq type 'paragraph)) (let ((cend (org-element-property :contents-end element))) (and cend (<= cend pos)))) (if (memq type '(footnote-definition item plain-list)) - (org--get-expected-indentation (org-element-at-point) nil) + (let ((last (org-element-at-point))) + (org--get-expected-indentation + last (eq (org-element-type last) 'item))) (goto-char start) (org-get-indentation))) ;; In any other case, indent like the current line. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index d64da2a04..0c0a506c8 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -645,6 +645,11 @@ (let ((org-adapt-indentation t)) (org-indent-line)) (org-get-indentation)))) (should + (= 4 + (org-test-with-temp-text "* H\n- A\n -\n\n" + (let ((org-adapt-indentation t)) (org-indent-line)) + (org-get-indentation)))) + (should (zerop (org-test-with-temp-text "* H\n- A\n - AA\n\n\n\n" (goto-char (point-max)) -- 2.11.4.GIT