Subject: bug#9193: 23.3; newline-and-indent broken in shell-script (sh mode)

From: Stefan Monnier <[email-masked]>
Date: Tue, 02 Aug 2011 21:46:53 -0400

> #! /bin/sh

> if [ $a == $b ]
> then
>     echo newline-and-indent is OK here
>     echo "newline-and-indent is NOT OK here"
> fi

> Now, put the cursor at the end of the first "echo" line and type ^J
> (bound to newline-and-indent).  As expected, it does a
> newline-and-indent.  Now put the cursor at the end of the second "echo"
> line and type ^J.  It does the newline, but not the indent.

> [ Other possibly completely irrelevant information:
> Playing around a bit, I found that if I create my own function and
> instead of using (newline-and-indent) I use
>     (newline)
>     (sit-for .001)
>     (indent-according-to-mode)
> then calling that function Does The Right Thing.
> ]

FWIW it seems to be fixed in the trunk (i.e. in the upcoming Emacs-24).
Could you try it out to confirm it fixes your problems?

        Stefan