Subject: bug#18756: closed (Re: bug#18756: 24.4; shell-script-mode does wrong indentation)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 06 Jan 2015 18:56:02 +0000

Your bug report

#18756: 24.4; shell-script-mode does wrong indentation

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
18756: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18756
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#18756: 24.4; shell-script-mode does wrong indentation
From: Glenn Morris <[email-masked]>
To: Peter Oliver <[email-masked]>
Cc: [email-masked]
Date: Tue, 06 Jan 2015 13:55:17 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 24.5

Peter Oliver wrote:

> I can reproduce this when electric-indent-mode is on and sh-set-shell
> is run for a csh-family shell.

Thanks for this vital clue.
I installed the following, which seems to fix it.

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index d79b387..4700324 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2477,7 +2475,8 @@ Lines containing only comments are considered empty."
 		    (current-column)))
 	current)
     (save-excursion
-      (indent-to (if (eq this-command 'newline-and-indent)
+      (indent-to (if (or (eq this-command 'newline-and-indent)
+                         (and electric-indent-mode (eq this-command 'newline)))
 		     previous
 		   (if (< (current-column)
 			  (setq current (progn (back-to-indentation)

Subject: 24.4; shell-script-mode does wrong indentation
From: Daniel Daboul <[email-masked]>
To: [email-masked]
Date: Fri, 17 Oct 2014 22:36:03 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

M-x shell-script-mode<Enter>
#hi<Enter>
ls<Enter>
x-3<Enter>

With every <Enter> key-press the current line gets indeted, so that
the buffer looks like:
    #hi
        ls
            x=3

<Tab> also mis-behaves. Emacs 24.3.1, OTOH, works fine for me.

In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-10-17 on icsl5123
System Description:    SUSE Linux Enterprise Server 10 (x86_64)

Configured using:
 `configure --prefix=/nfs/iil/home/ddaboul/r/sles10 --with-gif=no
 --without-pop --without-sound --without-gpm --without-dbus
 --with-x-toolkit=lucid'

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell-script

Minor modes in effect:
  sh-electric-here-document-mode: t
  tooltip-mode: t
  electric-indent-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ > 0 ; 2 0 8 ; 0 c ESC x s h e l l - s c r i p
t - m o d e RET # h i RET l s RET x = 3 RET ESC x r
e p o r t - e m a c s - b u g RET

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
No indentation for this shell type.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils sh-script smie executable xterm
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar 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 minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dynamic-setting x-toolkit x multi-tty
emacs)

Memory information:
((conses 16 83253 3991)
 (symbols 48 18103 0)
 (miscs 40 31 113)
 (strings 32 12327 4537)
 (string-bytes 1 361598)
 (vectors 16 7894)
 (vector-slots 8 361363 27987)
 (floats 8 63 284)
 (intervals 56 186 0)
 (buffers 960 11)
 (heap 1024 8017 572))