GNU bug report logs -
#753
[Fwd: sh-script.el: indentation of ( )]
Previous Next
Reported by: occitan <at> esperanto.org
Date: Wed, 20 Aug 2008 21:45:04 UTC
Severity: normal
Tags: unreproducible
Done: Andrew Hyatt <ahyatt <at> gmail.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 753 in the body.
You can then email your comments to 753 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
occitan <at> esperanto.org
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
since I abandoned Shell in favour of Perl, over to you maintainers:
-------- Original-Nachricht --------
Betreff: sh-script.el: indentation of ( )
Datum: Wed, 20 Aug 2008 12:12:12 -0400
Von: Darren Stuart Embry <dse <at> webonastick.com>
An: Daniel Pfeiffer <occitan <at> esperanto.org>
Hello,
I'd like to report an issue regarding indentation of compound commands
surrounded with parenthesis.
Desired indentation:
#!/bin/sh
(
true
)
{
true
}
What indent-region on the entire buffer yields:
#!/bin/sh
(
true
)
{
true
}
Note that the same behavior does not happen with the { } pair.
You have any idea why this is happening and/or how to fix this?
Version of emacs:
GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll
bars) of 2008-04-27 on raven, modified by Debian
Version of sh-script.el:
;; Author: Daniel Pfeiffer <occitan <at> esperanto.org>
;; Version: 2.0f
Thanks in advance.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in email?
coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer
--
lerne / learn / apprends / lär dig / ucz się Esperanto:
http://lernu.net / http://ikurso.net
[Message part 2 (text/html, inline)]
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
Full text and
rfc822 format available.
Message #8 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
Daniel Pfeiffer wrote:
> What indent-region on the entire buffer yields:
>
> #!/bin/sh
>
> (
> true
> )
> {
> true
> }
Emacs 21.4 gets it right here, whereas 22.1 and later gets it wrong.
The difference seems to be caused by sh-get-kw, specifically:
2006-10-10 Stefan Monnier <monnier <at> iro.umontreal.ca>
* progmodes/sh-script.el (sh-get-kw): | is not among the allowed chars
for a keyword.
In making this change (rev 1.191), you also added '()' to the
non-allowed characters along with '|'. Since it wasn't documented in
the ChangeLog, was this a mistake?
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
Full text and
rfc822 format available.
Message #11 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
Glenn Morris wrote:
> The difference seems to be caused by sh-get-kw, specifically:
>
> 2006-10-10 Stefan Monnier <monnier <at> iro.umontreal.ca>
>
> * progmodes/sh-script.el (sh-get-kw): | is not among the allowed chars
> for a keyword.
>
> In making this change (rev 1.191), you also added '()' to the
> non-allowed characters along with '|'. Since it wasn't documented in
> the ChangeLog, was this a mistake?
Ping.
Can you remember why you added '()'?
Here's why the '|' got added:
http://lists.gnu.org/archive/html/emacs-pretest-bug/2006-10/msg00160.html
Reply sent to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
Full text and
rfc822 format available.
Notification sent to
occitan <at> esperanto.org
:
bug acknowledged by developer.
Full text and
rfc822 format available.
Message #16 received at 753-done <at> emacsbugs.donarmstrong.com (full text, mbox):
2008-09-06 Glenn Morris <rgm <at> gnu.org>
* progmodes/sh-script.el (sh-get-kw): Remove '()' from the list of
unallowed characters; added 2006-10-10 without comment. (Bug#753)
bug archived.
Request was from
Debbugs Internal Request <don <at> donarmstrong.com>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Sun, 05 Oct 2008 14:24:03 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Thu, 08 Jan 2009 08:00:05 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Thu, 08 Jan 2009 08:10:04 GMT)
Full text and
rfc822 format available.
Message #23 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> The difference seems to be caused by sh-get-kw, specifically:
>>
>> 2006-10-10 Stefan Monnier <monnier <at> iro.umontreal.ca>
>>
>> * progmodes/sh-script.el (sh-get-kw): | is not among the allowed chars
>> for a keyword.
>>
>> In making this change (rev 1.191), you also added '()' to the
>> non-allowed characters along with '|'. Since it wasn't documented in
>> the ChangeLog, was this a mistake?
> Ping.
> Can you remember why you added '()'?
Because neither ( nor ) are allowed in keywords.
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Thu, 08 Jan 2009 08:10:05 GMT)
Full text and
rfc822 format available.
Message #26 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
[ You must unarchive old bugs before mailing them ]
Stefan Monnier wrote:
>> Can you remember why you added '()'?
>
> Because neither ( nor ) are allowed in keywords.
They _are_ keywords, along with { and }, as evidenced by their entries
in the constant `sh-kw'.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Thu, 08 Jan 2009 16:50:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 08 Jan 2009 16:50:04 GMT)
Full text and
rfc822 format available.
Message #31 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
> [ You must unarchive old bugs before mailing them ]
Yes: I didn't know it was old :-(
>>> Can you remember why you added '()'?
>> Because neither ( nor ) are allowed in keywords.
> They _are_ keywords, along with { and }, as evidenced by their entries
> in the constant `sh-kw'.
Hmm... I think I see what might be the problem, tho I don't understand
the code enough. 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). 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?
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Fri, 09 Jan 2009 02:50:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> 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.
Applying (skip-chars-forward "^ \t\n;&|")
to "done) "
results in "done)", which is not a recognized keyword.
> 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.
Both Emacs 22.3 and the current CVS get both examples wrong, in
different ways.
ii), though valid syntax, seems ugly (and hopefully uncommon) to me,
especially considering that in Bash at least, the same problem cannot
arise with {}, since these must be isolated by whitespace.
A simple fix for i) is as follows. I don't know how to fix both i) and ii).
Did you have any other examples of shell syntax to be considered?
*** sh-script.el 5 Jan 2009 03:23:50 -0000 1.220
--- sh-script.el 9 Jan 2009 02:22:31 -0000
***************
*** 1421,1427 ****
"Make a regexp which matches WORD as a word.
This specifically excludes an occurrence of WORD followed by
punctuation characters like '-'."
! (concat word "\\([^-[:alnum:]_]\\|$\\)"))
(defconst sh-re-done (sh-mkword-regexpr "done"))
--- 1421,1428 ----
"Make a regexp which matches WORD as a word.
This specifically excludes an occurrence of WORD followed by
punctuation characters like '-'."
! ;; ")}" excludes things like "done)" in case statements.
! (concat word "\\([^-[:alnum:]_)}]\\|$\\)"))
(defconst sh-re-done (sh-mkword-regexpr "done"))
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Fri, 09 Jan 2009 04:05:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 09 Jan 2009 04:05:06 GMT)
Full text and
rfc822 format available.
Message #39 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> 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
bug reopened, originator not changed.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Fri, 09 Jan 2009 04:55:05 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Fri, 09 Jan 2009 05:10:04 GMT)
Full text and
rfc822 format available.
Message #44 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> It doesn't matter. "done)" is not an entity in `sh', so we should not
> treat it as one.
Yes, but it is a useful shortcut to treat it as one IMO, since it
gets the indentation "mostly right" for little effort.
I'm afraid I don't know how to fix it (indentation) properly, so I
reopened this bug.
> After all if you replace "done)" with "done )" in the above 2
> scripts, they still mean the same.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#753
; Package
emacs
.
(Fri, 09 Jan 2009 17:30:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> IRO.UMontreal.CA>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 09 Jan 2009 17:30:03 GMT)
Full text and
rfc822 format available.
Message #49 received at 753 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> It doesn't matter. "done)" is not an entity in `sh', so we should not
>> treat it as one.
> Yes, but it is a useful shortcut to treat it as one IMO, since it
> gets the indentation "mostly right" for little effort.
It still gets it wrong for "done )". And it introduces bugs elsewhere.
I'm pretty sure it was not done on purpose: it's basically a bug that
accidentally does the right thing in some corner cases.
> I'm afraid I don't know how to fix it (indentation) properly, so I
> reopened this bug.
We know how to fix the OP's bug without re-introducing the bug that my
misguided patch tried to fix. So we should do that and close this bug.
Then we can open another bug about the "done )" case pattern since it's
a different bug.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#753
; Package
emacs
.
(Wed, 30 Dec 2015 00:46:02 GMT)
Full text and
rfc822 format available.
Message #52 received at 753 <at> debbugs.gnu.org (full text, mbox):
+occitan (the original reported)
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
>>> It doesn't matter. "done)" is not an entity in `sh', so we should not
>>> treat it as one.
>> Yes, but it is a useful shortcut to treat it as one IMO, since it
>> gets the indentation "mostly right" for little effort.
>
> It still gets it wrong for "done )". And it introduces bugs elsewhere.
> I'm pretty sure it was not done on purpose: it's basically a bug that
> accidentally does the right thing in some corner cases.
>
>> I'm afraid I don't know how to fix it (indentation) properly, so I
>> reopened this bug.
>
> We know how to fix the OP's bug without re-introducing the bug that my
> misguided patch tried to fix. So we should do that and close this bug.
> Then we can open another bug about the "done )" case pattern since it's
> a different bug.
>
>
> Stefan
I can't reproduce the original bug on Emacs 25. Can anyone reproduce
it? If not, or I don't hear anything in a few weeks, I'll close this.
Added tag(s) unreproducible.
Request was from
Andrew Hyatt <ahyatt <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 30 Dec 2015 00:46:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#753
; Package
emacs
.
(Sat, 02 Jan 2016 01:52:08 GMT)
Full text and
rfc822 format available.
Message #57 received at 753 <at> debbugs.gnu.org (full text, mbox):
Andrew Hyatt wrote:
> I can't reproduce the original bug on Emacs 25. Can anyone reproduce
> it? If not, or I don't hear anything in a few weeks, I'll close this.
The remaining issue was not with the original recipe, it was with the
related stuff that was discussed later. You might like to check if any
of it is still relevant.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#753
; Package
emacs
.
(Sat, 02 Jan 2016 20:57:01 GMT)
Full text and
rfc822 format available.
Message #60 received at 753 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
> Andrew Hyatt wrote:
>
>> I can't reproduce the original bug on Emacs 25. Can anyone reproduce
>> it? If not, or I don't hear anything in a few weeks, I'll close this.
>
> The remaining issue was not with the original recipe, it was with the
> related stuff that was discussed later. You might like to check if any
> of it is still relevant.
There is a problem, but it seems fairly minor, and arguably not a bug -
if you use a case identifier that's also a keyword, it doesn't behave
correctly. That has a trivial workaround - just wrap the keyword in
quotes. I think to some extent, modes having issues with keywords
acting as identifiers or variables is pretty normal - at least hard to
fix without real semantic parsing.
I'm going to close this bug, and if anyone feels like there's still an
issue worth fixing here, please open a new bug.
Thanks for the response!
bug closed, send any further explanations to
753 <at> debbugs.gnu.org and occitan <at> esperanto.org
Request was from
Andrew Hyatt <ahyatt <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 02 Jan 2016 21:25:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 31 Jan 2016 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 135 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.