From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Phil Newsgroups: gmane.emacs.bugs Subject: bug#21321: 24.5; sh-mode incorrectly indents case statements in certain cases Date: Sat, 22 Aug 2015 15:49:39 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113796fc057c69051de6a9ec X-Trace: ger.gmane.org 1440263607 13059 80.91.229.3 (22 Aug 2015 17:13:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Aug 2015 17:13:27 +0000 (UTC) To: 21321@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 22 19:13:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZTCLy-0006qU-Ke for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Aug 2015 19:13:15 +0200 Original-Received: from localhost ([::1]:47291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTCLx-0005gr-QD for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Aug 2015 13:13:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTCLp-0005bx-HB for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 13:13:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTCLn-00059t-Es for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 13:13:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTCLn-00059Y-53 for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 13:13:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZTCLm-0001ZQ-LD for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 13:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Aug 2015 17:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21321 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14402635505983 (code B ref -1); Sat, 22 Aug 2015 17:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Aug 2015 17:12:30 +0000 Original-Received: from localhost ([127.0.0.1]:35323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZTCLE-0001YQ-E4 for submit@debbugs.gnu.org; Sat, 22 Aug 2015 13:12:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49511) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZT9BO-0005K1-Uh for submit@debbugs.gnu.org; Sat, 22 Aug 2015 09:50:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZT9BM-0001go-Mk for submit@debbugs.gnu.org; Sat, 22 Aug 2015 09:50:06 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZT9BM-0001gH-IZ for submit@debbugs.gnu.org; Sat, 22 Aug 2015 09:50:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZT9BK-0003mU-FJ for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 09:50:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZT9BI-0001Zq-Cc for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 09:50:02 -0400 Original-Received: from mail-yk0-x235.google.com ([2607:f8b0:4002:c07::235]:34639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZT9BI-0001ZX-6F for bug-gnu-emacs@gnu.org; Sat, 22 Aug 2015 09:50:00 -0400 Original-Received: by ykdt205 with SMTP id t205so96523837ykd.1 for ; Sat, 22 Aug 2015 06:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=5KY0OakDf6Kh6uKYbzwNsa0wOgoIRVJLP0rl7o+MkRE=; b=oIwLzxMS96Q5hUR48pYtBGO2qZXVlI58QG2o9nONX13FfjKKbnwotgHWn8CoHY5Uxr 9UR68dUKTWf3wzDmc8xVo27CogRBmnmWmaWoxZF9UfjPa3G8wZkbh39iu7d2MgEQutR2 O9ePRjS7+NG3Qf+WfGENppa4NLk7Q8mrM/Kf33ToYrcQzc1uMzjbYaFyX43nz0bJVfCf gsDtWb90Y8Dg5ZQs51xGi0E1wfmZf1y7TO/e+iqBJGNiXnHcWLKZcwNBXme9+6clkHyw fN9+EdtHfC/fKcBW1qjq/vLe4XYKPiRiUOlEsitNL1bqlGQvisvpXAwf20upycvn1hT9 BWvg== X-Received: by 10.170.114.200 with SMTP id g191mr18789949ykb.71.1440251398943; Sat, 22 Aug 2015 06:49:58 -0700 (PDT) Original-Received: by 10.37.22.11 with HTTP; Sat, 22 Aug 2015 06:49:39 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Sat, 22 Aug 2015 13:12:26 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105702 Archived-At: --001a113796fc057c69051de6a9ec Content-Type: text/plain; charset=UTF-8 If there is a pair of parens (for bash globbing) in a case match, the indentation of sh-mode indents everything after the match expression to the end of that expression. If there are multiple such expressions, it will progressively indent further and further. To see what I mean, load the example below into an emacs buffer with sh-mode and press M-x mark-whole-buffer RET M-x indent-region RET ------------- Example ---------------------- #!/bin/bash TEST=foo234bar ###### Expected: (does not contain the offending parens) case $TEST in foo[0-9]bar) echo "TEST contains a digit between foo and bar"; ;; foobar) echo "TEST does not contain numbers"; ;; *) echo "Invalid value in TEST"; ;; esac ###### End expected ###### Actual: (contains the parens for the repeating pattern match) case $TEST in foo+([0-9])bar) echo "TEST contains numbers between foo and bar"; ;; foobar) echo "TEST does not contain numbers"; ;; *) echo "Invalid value in TEST"; ;; esac; ###### End actual ----------------- END Example ------------------- Thanks for looking at this Regards, Philip Stark In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.2) of 2015-04-20 on bitzer.hoetzel.info Windowing system distributor `The X.Org Foundation', version 11.0.11702000 Configured using: `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro' Important settings: value of $LC_MONETARY: de_CH.UTF-8 value of $LC_NUMERIC: de_CH.UTF-8 value of $LC_TIME: de_CH.UTF-8 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 global-diff-hl-mode: t diff-hl-mode: t diff-auto-refine-mode: t winner-mode: t global-undo-tree-mode: t undo-tree-mode: t global-anzu-mode: t anzu-mode: t projectile-global-mode: t projectile-mode: t shell-dirtrack-mode: t volatile-highlights-mode: t global-hl-line-mode: t recentf-mode: t savehist-mode: t show-smartparens-global-mode: t show-smartparens-mode: t global-auto-revert-mode: t delete-selection-mode: t prelude-global-mode: t prelude-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-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 size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent messages: Saving file /home/phil/tmp/emacs_indentation_test.sh... Wrote /tmp/.!home!phil!tmp!emacs_indentation_test.sh.~undo-tree~ Wrote /home/phil/tmp/emacs_indentation_test.sh Saving file /home/phil/tmp/emacs_indentation_test.sh... Wrote /tmp/.!home!phil!tmp!emacs_indentation_test.sh.~undo-tree~ Wrote /home/phil/tmp/emacs_indentation_test.sh byte-code: Beginning of buffer [7 times] Making completion list... Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message idna rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils easy-kill vc-git sh-script smie executable help-mode server flatland-theme prelude-global-keybindings prelude-editor operate-on-number calc-bin calc-ext calc calc-loaddefs calc-macs diff-hl smartrep vc-dir ewoc vc vc-dispatcher diff-mode easy-mmode winner undo-tree diff esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util re-builder whitespace tabify browse-kill-ring midnight ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff dired-x dired anzu avy projectile compile ibuf-ext ibuffer bookmark pp expand-region text-mode-expansions er-basic-expansions expand-region-core expand-region-custom flyspell ispell tramp tramp-compat auth-source gnus-util mm-util mail-prsvr password-cache tramp-loaddefs trampver shell pcomplete comint ansi-color format-spec etags ring volatile-highlights hl-line windmove recentf tree-widget wid-edit savehist saveplace diminish edmacro kmacro smartparens-config smartparens time-date autorevert filenotify delsel prelude-mode prelude-core imenu epl ido ov dash thingatpt prelude-ui smart-mode-line mule-util rich-minority prelude-custom prelude-packages finder-inf eieio byte-opt bytecomp byte-compile cl-extra cconv eieio-core cl-macs advice help-fns info easymenu package epg-config cl gv cl-loaddefs cl-lib theme 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 dbusbind gfilenotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs) Memory information: ((conses 16 267771 213712) (symbols 48 38350 1) (miscs 40 482 957) (strings 32 70315 175298) (string-bytes 1 1986298) (vectors 16 30716) (vector-slots 8 613249 119243) (floats 8 168 1362) (intervals 56 1105 3300) (buffers 960 16) (heap 1024 67464 33453)) --001a113796fc057c69051de6a9ec Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

If there is a pair of parens (for b= ash globbing) in a case match, the

indentation of sh-mode indents ever= ything after the match expression to

the end of that expression. If there are multiple such expressions, it= will

progressively indent furth= er and further.


To see what I mean, load the example be= low into an emacs buffer with sh-mode and press


M-x mar= k-whole-buffer RET M-x indent-region RET


------------- Example -------------= ---------

#!/bin/bash

TEST=3Dfoo234bar


###### Expected: (does not contain = the offending parens)


case $TEST in

foo[0-9]bar)

echo "TEST contains a = digit between foo and bar";

;;


foobar)

echo "TEST does not co= ntain numbers";

;;


*)

echo "Invalid value in= TEST";

;;

esac


###### End expected


###### Actual: (contains the parens= for the repeating pattern match)


case $TEST in

foo+([0-9])bar)

echo "TEST = contains numbers between foo and bar";

;;


foobar)

echo "T= EST does not contain numbers";

;;


*)

echo "I= nvalid value in TEST";

;;

esac;



###### End actual

----------------- END Example -----= --------------


Thanks for looking at this


Regards,

Philip Stark





In GNU Emacs 24.5.1 (x86_64-unknown= -linux-gnu, GTK+ Version 3.16.2)

of 2015-04-20 on bitzer.hoetzel.info

Windowing system distributor `The X= .Org Foundation', version 11.0.11702000

Configured using:

`configure --prefix=3D/usr --sysco= nfdir=3D/etc --libexecdir=3D/usr/lib

--localstatedir=3D/var --with-x-to= olkit=3Dgtk3 --with-xft

'CFLAGS=3D-march=3Dx86-64 -mtu= ne=3Dgeneric -O2 -pipe -fstack-protector-strong

--param=3Dssp-buffer-size=3D4'= CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2

LDFLAGS=3D-Wl,-O1,--sort-common,--= as-needed,-z,relro'


Important settings:

value of $LC_MONETARY: de_CH.UTF-= 8

value of $LC_NUMERIC: de_CH.UTF-8=

value of $LC_TIME: de_CH.UTF-8

value of $LANG: en_US.UTF-8

locale-coding-system: utf-8-unix<= /p>


Major mode: Shell-script


Minor modes in effect:

sh-electric-here-document-mode: t=

global-diff-hl-mode: t

diff-hl-mode: t

diff-auto-refine-mode: t

winner-mode: t

global-undo-tree-mode: t

undo-tree-mode: t

global-anzu-mode: t

anzu-mode: t

projectile-global-mode: t

projectile-mode: t

shell-dirtrack-mode: t

volatile-highlights-mode: t

global-hl-line-mode: t

recentf-mode: t

savehist-mode: t

show-smartparens-global-mode: t

show-smartparens-mode: t

global-auto-revert-mode: t

delete-selection-mode: t

prelude-global-mode: t

prelude-mode: t

tooltip-mode: t

electric-indent-mode: t

mouse-wheel-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

size-indication-mode: t

column-number-mode: t

line-number-mode: t

transient-mark-mode: t


Recent messages:

Saving file /home/phil/tmp/emacs_in= dentation_test.sh...

Wrote /tmp/.!home!phil!tmp!emacs_in= dentation_test.sh.~undo-tree~

Wrote /home/phil/tmp/emacs_indentat= ion_test.sh

Saving file /home/phil/tmp/emacs_in= dentation_test.sh...

Wrote /tmp/.!home!phil!tmp!emacs_in= dentation_test.sh.~undo-tree~

Wrote /home/phil/tmp/emacs_indentat= ion_test.sh

byte-code: Beginning of buffer [7 t= imes]

Making completion list...


Load-path shadows:

None found.


Features:

(shadow sort mail-extr emacsbug mes= sage idna rfc822 mml mml-sec

mm-decode mm-bodies mm-encode mail-= parse rfc2231 mailabbrev gmm-utils

mailheader sendmail rfc2047 rfc2045= ietf-drums mail-utils easy-kill

vc-git sh-script smie executable he= lp-mode server flatland-theme

prelude-global-keybindings prelude-= editor operate-on-number calc-bin

calc-ext calc calc-loaddefs calc-ma= cs diff-hl smartrep vc-dir ewoc vc

vc-dispatcher diff-mode easy-mmode = winner undo-tree diff esh-var esh-io

esh-cmd esh-opt esh-ext esh-proc es= h-arg eldoc esh-groups eshell

esh-module esh-mode esh-util re-bui= lder whitespace tabify

browse-kill-ring midnight ediff-mer= g ediff-wind ediff-diff ediff-mult

ediff-help ediff-init ediff-util ed= iff dired-x dired anzu avy projectile

compile ibuf-ext ibuffer bookmark p= p expand-region text-mode-expansions

er-basic-expansions expand-region-c= ore expand-region-custom flyspell

ispell tramp tramp-compat auth-sour= ce gnus-util mm-util mail-prsvr

password-cache tramp-loaddefs tramp= ver shell pcomplete comint ansi-color

format-spec etags ring volatile-hig= hlights hl-line windmove recentf

tree-widget wid-edit savehist savep= lace diminish edmacro kmacro

smartparens-config smartparens time= -date autorevert filenotify delsel

prelude-mode prelude-core imenu epl= ido ov dash thingatpt prelude-ui

smart-mode-line mule-util rich-mino= rity prelude-custom prelude-packages

finder-inf eieio byte-opt bytecomp = byte-compile cl-extra cconv

eieio-core cl-macs advice help-fns = info easymenu package epg-config cl

gv cl-loaddefs cl-lib theme tooltip= electric uniquify ediff-hook

vc-hooks lisp-float-type mwheel x-w= in x-dnd tool-bar dnd fontset image

regexp-opt fringe tabulated-list ne= wcomment lisp-mode prog-mode register

page menu-bar rfn-eshadow timer sel= ect scroll-bar mouse jit-lock

font-lock syntax facemenu font-core= frame cham georgian utf-8-lang

misc-lang vietnamese tibetan thai t= ai-viet lao korean japanese hebrew

greek romanian slovak czech europea= n ethiopic indian cyrillic chinese

case-table epa-hook jka-cmpr-hook h= elp simple abbrev minibuffer nadvice

loaddefs button faces cus-face macr= oexp files text-properties overlay

sha1 md5 base64 format env code-pag= es mule custom widget

hashtable-print-readable backquote = make-network-process dbusbind

gfilenotify dynamic-setting system-= font-setting font-render-setting

move-toolbar gtk x-toolkit x multi-= tty emacs)


Memory information:

((conses 16 267771 213712)

(symbols 48 38350 1)

(miscs 40 482 957)

(strings 32 70315 175298)

(string-bytes 1 1986298)

(vectors 16 30716)

(vector-slots 8 613249 119243)

(floats 8 168 1362)

(intervals 56 1105 3300)

(buffers 960 16)

(heap 1024 67464 33453))


--001a113796fc057c69051de6a9ec--