GNU bug report logs -
#60833
[PATCH] sh-script.el: Add support for Zsh's case branches ;|.
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60833 in the body.
You can then email your comments to 60833 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60833
; Package
emacs
.
(Sun, 15 Jan 2023 14:14:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Philippe Altherr <philippe.altherr <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 15 Jan 2023 14:14:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
In shell scripts, case branches traditionally end with ;;. Bash
additionally supports case branches ending with ;& and ;;&. Zsh similarly
supports case branches ending with ;& and ;|. Currently sh-script.el
supports case branches ending with ;;, ;&, and ;;&, but not with ;|. The
attached patch adds support for case branches ending with ;|.
I have tested the patch by defining all the modified functions
(sh-smie-sh-rules, sh-font-lock-paren) and constants (sh-smie-sh-grammar,
sh-smie-rc-grammar, sh-smie--sh-operators, sh-smie--sh-operators-re,
sh-smie--sh-operators-back-re) in my .emacs (in a (with-eval-after-load
'sh-script ...) statement).
Here is an example indented without the patch:
case $input in
*a* ) echo A;;
*b* ) echo B;&
*c* ) echo C;;&
*d* ) echo D;|
*e* ) echo E;;
esac
and with the (simulated) patch:
case $input in
*a* ) echo A;;
*b* ) echo B;&
*c* ) echo C;;&
*d* ) echo D;|
*e* ) echo E;;
esac
The first change in the patch replaces an (eq (char-before) ?|)
<https://github.com/emacs-mirror/emacs/blob/77ca6aa56e3425c87861cab8abce52bee3697cf4/lisp/progmodes/sh-script.el#L1045>
with
(and (eq (char-before) ?|) (not (eq (char-before (1- (point))) ?\;))). It
is needed to avoid confusing ;| tokens with plain | tokens. I wonder
however whether there would be a cleaner way of expressing the same.
The second change replaces a (looking-at ";[;&]\\|\\_<in")
<https://github.com/emacs-mirror/emacs/blob/77ca6aa56e3425c87861cab8abce52bee3697cf4/lisp/progmodes/sh-script.el#L1056>
with (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in"). The original expression
is looking for ;; and ;& tokens but not for ;;& tokens, which looks like an
oversight to me. That's why I have changed it to look for ;;, ;&, ;| but
also ;;&.
The other changes simply add support for ;| where there was previously
support for ;;, ;&, and ;;&.
Philippe
[Message part 2 (text/html, inline)]
[0001-Add-support-for-Zsh-s-case-branches.patch (application/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60833
; Package
emacs
.
(Sat, 21 Jan 2023 07:34:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 60833 <at> debbugs.gnu.org (full text, mbox):
> From: Philippe Altherr <philippe.altherr <at> gmail.com>
> Date: Sun, 15 Jan 2023 14:28:08 +0100
>
> In shell scripts, case branches traditionally end with ;;. Bash additionally supports case branches ending with
> ;& and ;;&. Zsh similarly supports case branches ending with ;& and ;|. Currently sh-script.el supports case
> branches ending with ;;, ;&, and ;;&, but not with ;|. The attached patch adds support for case branches
> ending with ;|.
>
> I have tested the patch by defining all the modified functions (sh-smie-sh-rules, sh-font-lock-paren) and
> constants (sh-smie-sh-grammar, sh-smie-rc-grammar, sh-smie--sh-operators, sh-smie--sh-operators-re,
> sh-smie--sh-operators-back-re) in my .emacs (in a (with-eval-after-load 'sh-script ...) statement).
>
> Here is an example indented without the patch:
>
> case $input in
> *a* ) echo A;;
> *b* ) echo B;&
> *c* ) echo C;;&
> *d* ) echo D;|
> *e* ) echo E;;
> esac
>
> and with the (simulated) patch:
>
> case $input in
> *a* ) echo A;;
> *b* ) echo B;&
> *c* ) echo C;;&
> *d* ) echo D;|
> *e* ) echo E;;
> esac
Thanks. First, would it be possible to add tests for these
situations?
And second, your contributions (this and the other one) are larger
than we can accept without your assigning the copyright to the FSF.
Would you like to start your legal paperwork at this time, so that we
could accept the changes after it is completed? If so, I will send
you the form to fill.
Thanks again for your interest in Emacs.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60833
; Package
emacs
.
(Mon, 23 Jan 2023 05:53:04 GMT)
Full text and
rfc822 format available.
Message #11 received at 60833 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>
> Thanks. First, would it be possible to add tests for these
> situations?
>
I added a test case in the attached updated patch. I wasn't able to test it
though. Please make sure it works as expected.
> And second, your contributions (this and the other one) are larger
> than we can accept without your assigning the copyright to the FSF.
> Would you like to start your legal paperwork at this time, so that we
> could accept the changes after it is completed? If so, I will send
> you the form to fill.
>
Sure
[Message part 2 (text/html, inline)]
[0001-Add-support-for-Zsh-s-case-branches.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60833
; Package
emacs
.
(Mon, 23 Jan 2023 15:17:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 60833 <at> debbugs.gnu.org (full text, mbox):
> From: Philippe Altherr <philippe.altherr <at> gmail.com>
> Date: Mon, 23 Jan 2023 05:13:36 +0100
> Cc: 60833 <at> debbugs.gnu.org
>
> And second, your contributions (this and the other one) are larger
> than we can accept without your assigning the copyright to the FSF.
> Would you like to start your legal paperwork at this time, so that we
> could accept the changes after it is completed? If so, I will send
> you the form to fill.
>
> Sure
Form sent off-list.
(I will review the patch soon.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60833
; Package
emacs
.
(Fri, 17 Feb 2023 15:22:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 60833 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Here is an updated patch against the current master branch.
On Sun, Jan 15, 2023 at 3:14 PM GNU bug Tracking System <
help-debbugs <at> gnu.org> wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
> bug-gnu-emacs <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 60833 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 60833: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60833
> GNU Bug Tracking System
> Contact help-debbugs <at> gnu.org with problems
>
[Message part 2 (text/html, inline)]
[0001-Add-support-for-Zsh-s-case-branches.patch (application/octet-stream, attachment)]
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Thu, 02 Mar 2023 10:51:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Philippe Altherr <philippe.altherr <at> gmail.com>
:
bug acknowledged by developer.
(Thu, 02 Mar 2023 10:51:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 60833-done <at> debbugs.gnu.org (full text, mbox):
> From: Philippe Altherr <philippe.altherr <at> gmail.com>
> Date: Fri, 17 Feb 2023 16:20:59 +0100
>
> Here is an updated patch against the current master branch.
Thanks, installed on master, and closing the bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 30 Mar 2023 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 44 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.