Subject: bug#753: [Fwd: sh-script.el: indentation of ( )]

From: Stefan Monnier <[email-masked]>
Date: Thu, 08 Jan 2009 22:58:08 -0500

>> Basically, what I saw is that it recognized "done|" as a keyword,
>> which I fixed by adding ?| to the "not in keywords" chars. By the
>> same reasonging "done)" is not a keyword, so I added ?\) (and ?\( as
>> well for good measure).

> Adding them causes the problem you are trying to avoid.

I don't follow you.

> Applying (skip-chars-forward "^ \t\n;&|")
> to "done) "
> results in "done)", which is not a recognized keyword.

So does the original code (skip-chars-forward "^ \t\n;&"), but so
doesn't my code (skip-chars-forward "^ \t\n;&|()").  In this sense my
code did make things more correct.

>> I guess that sh-get-kw should be fixed more robustly by recognizing
>> ")" and "(" but not "(done", nor "(done|toto)" for that matter. Can
>> you take care of that and make sure it fixes the problem at hand
>> without breaking the problem that prompted my misguided fix?

> It's tricky. Consider the following two examples:

> for f in 1; do
>     case $f in
>         done) echo t ;;
>     esac
> done

> (for f in 1; do
>    echo $f
> done)

> In the second one, "done)" ends a for loop, in the first one it does not.

It doesn't matter.  "done)" is not an entity in `sh', so we should not
treat it as one.  After all if you replace "done)" with "done )" in the
above 2 scripts, they still mean the same.

> Both Emacs 22.3 and the current CVS get both examples wrong, in
> different ways.

Yes, but it's a due to different bug than the one at hand, IIUC.

        Stefan