From 6b3aa710612b22d587f27237925bffdd3116a43c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 16 Nov 2014 17:39:04 +0100 Subject: [PATCH] Fix `org-indent-line' on blank lines after a paragraph * lisp/org.el (org--get-expected-indentation): Properly compute expected indentation on blank lines after a paragraph. (org-indent-line): Update docstring. * testing/lisp/test-org.el (test-org/indent-line): Add test. --- lisp/org.el | 20 ++++++++++++++------ testing/lisp/test-org.el | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d07b61dcc..1f33d2a80 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -22653,8 +22653,9 @@ 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. - ((let ((cend (org-element-property :contents-end element))) - (and cend (<= cend pos))) + ((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) (goto-char start) @@ -22691,15 +22692,22 @@ Indentation is done according to the following rules: 2. If element has a parent, indent like its contents. More precisely, if parent is an item, indent after the description part, if any, or the bullet (see - ``org-list-description-max-indent'). Else, indent like + `org-list-description-max-indent'). Else, indent like parent's first line. 3. Otherwise, indent relatively to current level, if `org-adapt-indentation' is non-nil, or to left margin. - - On a blank line at the end of a plain list, an item, or - a footnote definition, indent like the very last element - within. + - On a blank line at the end of an element, indent according to + the type of the element. More precisely + + 1. If element is a plain list, an item, or a footnote + definition, indent like the very last element within. + + 2. If element is a paragraph, indent like its last non blank + line. + + 3. Otherwise, indent like its very first line. - In the code part of a source block, use language major mode to indent current line if `org-src-tab-acts-natively' is diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index cc06432c4..f48e8b117 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -587,6 +587,13 @@ (forward-line 2) (org-indent-line) (org-get-indentation)))) + ;; On blank lines after a paragraph, indent like its last non-empty + ;; line. + (should + (= 1 + (org-test-with-temp-text " Paragraph\n\n" + (org-indent-line) + (org-get-indentation)))) ;; At the first line of an element, indent like previous element's ;; first line, ignoring footnotes definitions and inline tasks, or ;; according to parent. -- 2.11.4.GIT