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

From: Jim Diamond <[email-masked]>
Date: Thu, 28 Jul 2011 12:57:34 -0300

Create the following file

#! /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.
]

In GNU Emacs 23.3.1 (x86_64-slackware-linux-gnu, GTK+ Version 2.24.1)
 of 2011-03-12 on midas64
Windowing system distributor `The X.Org Foundation', version 11.0.10905000
configured using `configure  '--prefix=/usr' '--sysconfdir=/etc' '--localstatedir=/var' '--program-prefix=' '--program-suffix=' '--mandir=/usr/man' '--infodir=/usr/info' '--enable-static=no' '--enable-shared=yes' '--with-x' '--with-x-toolkit=gtk' '--build=x86_64-slackware-linux' 'build_alias=x86_64-slackware-linux' 'CFLAGS=-O2 -fPIC''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_CA
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default enable-multibyte-characters: t

Major mode: Shell-script

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<backspace> C-e C-j <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> M-x b u g <tab> 
<tab> C-g M-x a p r o <tab> <return> b u g <return> 
<down-mouse-1> <mouse-movement> <mouse-movement> <mouse-1> 
C-s - b u g C-s C-s <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<return> <return> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <down-mouse-1> 
<mouse-movement> <drag-mouse-1> C-x b <return> C-x 
C-f a . s h <backspace> <backspace> <backspace> <backspace> 
b u g g y . s h <return> # ! SPC / b i n s <backspace> 
/ s h <return> <return> i f SPC [ SPC a SPC = SPC <backspace> 
= SPC b SPC ] <return> t h e n <return> f i <up> C-e 
<return> <tab> a <up> <up> $ <right> <right> <right> 
<right> <right> $ <down> <down> = <backspace> <backspace> 
e c h o SPC t h i s SPC i s SPC o k <return> <tab> 
<up> <down> C-a <backspace> C-j e c h o SPC " t h i 
s SPC i s SPC n o t " C-j <backspace> <up> <left> <left> 
<left> <left> <left> <left> <left> <left> <left> <left> 
<left> SPC n e w l i n e SPC a n d SPC i n d C-w C-w 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> - a n d - i n d 
e n t C-d C-d C-d C-d C-d C-e SPC h e r e <down> M-b 
M-b M-b n e w M-/ SPC M-d C-d <right> <right> <right> 
M-u SPC O K <backspace> K SPC h e r e <up> M-b M-b 
M-u C-e C-j <backspace> <backspace> <backspace> <backspace> 
<backspace> <down> C-e C-j <backspace> M-x g n u - 
e m C-u C-g M-x r e p o r t <tab> <return>

Recent messages:
Quit
Mark saved where search started
Type C-x 4 C-o RET to restore the other window.
(New file)
Setting up indent for shell type sh
setting up indent stuff
Indentation variables are now local.
Indentation setup for shell type sh
kill-region: The mark is not set now, so there is no region [2 times]
Auto-saving...done
Quit

Load-path shadows:
/usr/share/emacs/site-lisp/t-mouse hides /usr/share/emacs/23.3/lisp/t-mouse

Features:
(shadow sort mail-extr message idna sendmail ecomplete rfc822 mml
mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse
rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util
netrc time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock
sha1 hex-util hashcash mail-utils emacsbug dabbrev help-fns apropos
skeleton multi-isearch kmacro two-column iso-transl help-mode easymenu
view regexp-opt sh-script executable tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process dbusbind
font-render-setting gtk x-toolkit x multi-tty emacs)