diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-16 17:39:04 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2014-11-16 17:39:04 +0100 |
commit | 6b3aa710612b22d587f27237925bffdd3116a43c (patch) | |
tree | 5586aa2cad80eeb95b4b91332e3ec47b044cdab3 | |
parent | 1452b1523538a811dc7e45079e3492d4c5aa6d12 (diff) | |
download | org-mode-6b3aa710612b22d587f27237925bffdd3116a43c.tar.gz |
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.
-rwxr-xr-x | lisp/org.el | 20 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 7 |
2 files changed, 21 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el index d07b61d..1f33d2a 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 cc06432..f48e8b1 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<point>" + (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. |