Fix indentation bug

* lisp/org.el (org--get-expected-indentation): Fix indentation bug.
* testing/lisp/test-org.el (test-org/indent-line): Add test.

In the following document, the last line would be indented to "|"

- item

  #+BEGIN_SRC emacs-lisp
    (+ 1 1)
  #+END_SRC
    |
This commit is contained in:
Nicolas Goaziou 2016-02-24 20:58:55 +01:00
parent 1f84cc2182
commit 41d005822e
2 changed files with 10 additions and 11 deletions

View File

@ -22860,11 +22860,7 @@ ELEMENT."
(let ((cend (org-element-property :contents-end element)))
(and cend (<= cend pos))))
(if (memq type '(footnote-definition item plain-list))
(let ((last (org-element-at-point)))
(org--get-expected-indentation
last
(memq (org-element-type last)
'(footnote-definition item plain-list))))
(org--get-expected-indentation (org-element-at-point) t)
(goto-char start)
(org-get-indentation)))
;; In any other case, indent like the current line.

View File

@ -718,20 +718,23 @@
;; whole list.
(should
(= 4
(org-test-with-temp-text "* H\n- A\n - AA\n"
(goto-char (point-max))
(org-test-with-temp-text "* H\n- A\n - AA\n<point>"
(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))
(org-test-with-temp-text "* H\n- A\n - AA\n\n\n\n<point>"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
(should
(= 4
(org-test-with-temp-text "* H\n- A\n - \n"
(goto-char (point-max))
(org-test-with-temp-text "* H\n- A\n - \n<point>"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
(should
(= 4
(org-test-with-temp-text
"* H\n - \n #+BEGIN_SRC emacs-lisp\n t\n #+END_SRC\n<point>"
(let ((org-adapt-indentation t)) (org-indent-line))
(org-get-indentation))))
;; Likewise, on a blank line at the end of a footnote definition,