GNU bug report logs - #1320
sh-mode indentation of "case $foo in (bar)"

Previous Next

Package: emacs;

Reported by: Karl Chen <quarl <at> cs.berkeley.edu>

Date: Sun, 9 Nov 2008 21:30:02 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1320 in the body.
You can then email your comments to 1320 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report stored:
bug#1320; Package emacs. Full text and rfc822 format available.

Message #3 received at quiet <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Karl Chen <quarl <at> cs.berkeley.edu>
To: quiet <at> debbugs.gnu.org
Subject: sh-mode indentation of "case $foo in (bar)"
Date: Fri, 31 Oct 2008 03:29:13 -0700
[ resent from
http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00906.html ]

emacs -Q /tmp/case.sh
#
case x in
y)
y2
;;
(z)
z2
;;
esac

M-: (indent-region (point-min) (point-max))


Result:
#
case x in
    y)
        y2
	;;
    (z)
    z2
    ;;
esac


Expected:
#
case x in
    y)
        y2
	;;
    (z)
        z2
        ;;
esac



Running (sh-get-indent-info) on the y2 line includes
sh-indent-for-case-alt in the result (as expected); running
(sh-get-indent-info) on the z2 line doesn't yield
sh-indent-for-case-alt.

The "(altpattern)" syntax with leading opening parenthesis is
supported by various shells (bash, ksh, zsh).


Also, a second indentation bug: if the first line in the buffer is
the case statement, sh-mode gets even more confused and
double-indents the y2 line.  This is rare though since usually the
first line is "#!"; I only noticed it while constructing this bug
report.

Tested on emacs 22.2 and emacs 2008-10-31.




Information stored:
bug#1320; Package emacs. Full text and rfc822 format available.

Reply sent to Chong Yidong <cyd <at> stupidchicken.com>:
You have taken responsibility. (Sat, 24 Oct 2009 21:25:06 GMT) Full text and rfc822 format available.

Notification sent to Karl Chen <quarl <at> cs.berkeley.edu>:
bug acknowledged by developer. (Sat, 24 Oct 2009 21:25:06 GMT) Full text and rfc822 format available.

Message #10 received at 1320-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Karl Chen <quarl <at> cs.berkeley.edu>
Cc: 1320-done <at> debbugs.gnu.org
Subject: Re: sh-mode indentation of "case $foo in (bar)"
Date: Sat, 24 Oct 2009 17:16:39 -0400
> #
> case x in
> y)
> y2
> ;;
> (z)
> z2
> ;;
> esac
>
> Running (sh-get-indent-info) on the y2 line includes
> sh-indent-for-case-alt in the result (as expected); running
> (sh-get-indent-info) on the z2 line doesn't yield
> sh-indent-for-case-alt.

Sorry for the late response.  I've checked in a fix for this problem
into Emacs CVS.



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Sun, 22 Nov 2009 15:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.