[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wrong indentation of defun with indent-region
From: |
Peter Vasil |
Subject: |
Re: Wrong indentation of defun with indent-region |
Date: |
Sun, 30 Apr 2017 18:51:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 |
On 04/30/2017 06:31 PM, Peter Vasil wrote:
> Hello,
>
> Since commit 6fa9cc0593150a318f0e08e69ec10672d548a7c1 indent-region
> doesn't indent correctly a defun when docstring is more than one line.
>
> Reproduction:
>
> (defun test ()
> "Test.
> Two lines docstring."
> (message "Test"))
>
> With cursor somewhere in the function and after M-x mark-defun RET and
> M-x indent-region RET is this the result:
>
>
> (defun test-func ()
> "Test func.
> Two lines docstring."
> (message "Test"))
>
> However if the docstring is only one line the indentation stays correct.
>
> Regards,
> Peter Vasil
>
>
>
I wrote this small ert test which fails:
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el
b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 27f0bb5..4856318 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -97,5 +97,19 @@
(indent-sexp)
(should (equal (buffer-string) correct)))))
+(ert-deftest indent-region ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "
+(defun test ()
+ \"Test func.
+Two lines docstring.\"
+ (message \"Test\"))")
+ (let ((correct (buffer-string)))
+ (search-backward "message")
+ (mark-defun)
+ (indent-region (region-beginning) (region-end))
+ (should (equal (buffer-string) correct)))))
+
(provide 'lisp-mode-tests)
Result:
Selector: t
Passed: 0
Failed: 1 (1 unexpected)
Skipped: 0
Total: 1/1
Started at: 2017-04-30 18:49:36+0200
Finished.
Finished at: 2017-04-30 18:49:36+0200
F
F indent-region
(ert-test-failed
((should
(equal
(buffer-string)
correct))
:form
(equal "
(defun test ()
\"Test func.
Two lines docstring.\"
(message \"Test\"))" "
(defun test ()
\"Test func.
Two lines docstring.\"
(message \"Test\"))")
:value nil :explanation
(arrays-of-different-length 76 71 "
(defun test ()
\"Test func.
Two lines docstring.\"
(message \"Test\"))" "
(defun test ()
\"Test func.
Two lines docstring.\"
(message \"Test\"))" first-mismatch-at 54)))