all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Peter Vasil <mailing_lists@petervasil.net>
To: emacs-devel@gnu.org
Subject: Re: Wrong indentation of defun with indent-region
Date: Sun, 30 Apr 2017 18:51:11 +0200	[thread overview]
Message-ID: <oe54lo$a30$1@blaine.gmane.org> (raw)
In-Reply-To: <oe53h3$66a$1@blaine.gmane.org>

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)))






  reply	other threads:[~2017-04-30 16:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-30 16:31 Wrong indentation of defun with indent-region Peter Vasil
2017-04-30 16:51 ` Peter Vasil [this message]
2017-04-30 17:58 ` Noam Postavsky
2017-04-30 18:34   ` Peter Vasil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='oe54lo$a30$1@blaine.gmane.org' \
    --to=mailing_lists@petervasil.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.