From: Philippe Altherr <philippe.altherr@gmail.com>
To: 60833@debbugs.gnu.org
Subject: bug#60833: Acknowledgement ([PATCH] sh-script.el: Add support for Zsh's case branches ; |.)
Date: Fri, 17 Feb 2023 16:20:59 +0100 [thread overview]
Message-ID: <CAGdYchsdFu5Q0z5ZiQ6OHuo2yKnwpBiDaF67A0--=WUaEp0otA@mail.gmail.com> (raw)
In-Reply-To: <handler.60833.B.16737920195794.ack@debbugs.gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 905 bytes --]
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@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@gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 60833@debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@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@gnu.org with problems
>
[-- Attachment #1.2: Type: text/html, Size: 1657 bytes --]
[-- Attachment #2: 0001-Add-support-for-Zsh-s-case-branches.patch --]
[-- Type: application/octet-stream, Size: 3658 bytes --]
From f5c500be11a2a77f2a9e45f68a6010924d86e945 Mon Sep 17 00:00:00 2001
From: Philippe Altherr <philippe.altherr@gmail.com>
Date: Sun, 15 Jan 2023 13:37:00 +0100
Subject: [PATCH] Add support for Zsh's case branches ;|.
---
lisp/progmodes/sh-script.el | 18 +++++++++++-------
test/manual/indent/shell.sh | 1 +
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 17c22ff4751..2982bb3f345 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1042,7 +1042,9 @@ sh-font-lock-paren
;; Maybe we've bumped into an escaped newline.
(sh-is-quoted-p (point)))
(backward-char 1))
- (when (eq (char-before) ?|)
+ (when (and
+ (eq (char-before) ?|)
+ (not (eq (char-before (1- (point))) ?\;)))
(backward-char 1) t)))
(and (> (point) (1+ (point-min)))
(progn (backward-char 2)
@@ -1053,7 +1055,7 @@ sh-font-lock-paren
;; a normal command rather than the real `in' keyword.
;; I.e. we should look back to try and find the
;; corresponding `case'.
- (and (looking-at ";[;&]\\|\\_<in")
+ (and (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in")
;; ";; esac )" is a case that looks
;; like a case-pattern but it's really just a close
;; paren after a case statement. I.e. if we skipped
@@ -1784,8 +1786,9 @@ sh-smie-sh-grammar
(pattern (rpattern) ("case-(" rpattern))
(branches (branches ";;" branches)
(branches ";&" branches) (branches ";;&" branches) ;bash.
+ (branches ";|" branches) ;zsh.
(pattern "case-)" cmd)))
- '((assoc ";;" ";&" ";;&"))
+ '((assoc ";;" ";&" ";;&" ";|"))
'((assoc ";" "&") (assoc "&&" "||") (assoc "|" "|&")))))
(defconst sh-smie--sh-operators
@@ -2055,11 +2058,11 @@ sh-smie-sh-rules
`(column . ,(smie-indent-virtual))))))
;; FIXME: Maybe this handling of ;; should be made into
;; a smie-rule-terminator function that takes the substitute ";" as arg.
- (`(:before . ,(or ";;" ";&" ";;&"))
- (if (and (smie-rule-bolp) (looking-at ";;?&?[ \t]*\\(#\\|$\\)"))
+ (`(:before . ,(or ";;" ";&" ";;&" ";|"))
+ (if (and (smie-rule-bolp) (looking-at ";\\(?:;&?\\|[&|]\\)?[ \t]*\\(#\\|$\\)"))
(cons 'column (smie-indent-keyword ";"))
(smie-rule-separator kind)))
- (`(:after . ,(or ";;" ";&" ";;&"))
+ (`(:after . ,(or ";;" ";&" ";;&" ";|"))
(with-demoted-errors "SMIE rule error: %S"
(smie-backward-sexp token)
(cons 'column
@@ -2148,8 +2151,9 @@ sh-smie-rc-grammar
(pattern (pattern "|" pattern))
(branches (branches ";;" branches)
(branches ";&" branches) (branches ";;&" branches) ;bash.
+ (branches ";|" branches) ;zsh.
(pattern "case-)" cmd)))
- '((assoc ";;" ";&" ";;&"))
+ '((assoc ";;" ";&" ";;&" ";|"))
'((assoc "case") (assoc ";" "&") (assoc "&&" "||") (assoc "|" "|&")))))
(defun sh-smie--rc-after-special-arg-p ()
diff --git a/test/manual/indent/shell.sh b/test/manual/indent/shell.sh
index bd4a74f7054..5b3fb0e66fb 100755
--- a/test/manual/indent/shell.sh
+++ b/test/manual/indent/shell.sh
@@ -140,6 +140,7 @@ bar ()
5) hello ;;
4) hello ;&
4) hello ;;&
+ 4) hello ;|
5) hello ;;
5) hello ;;
esac
--
2.39.1
next prev parent reply other threads:[~2023-02-17 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-15 13:28 bug#60833: [PATCH] sh-script.el: Add support for Zsh's case branches ; | Philippe Altherr
2023-01-21 7:33 ` Eli Zaretskii
2023-01-23 4:13 ` Philippe Altherr
2023-01-23 15:16 ` Eli Zaretskii
[not found] ` <handler.60833.B.16737920195794.ack@debbugs.gnu.org>
2023-02-17 15:20 ` Philippe Altherr [this message]
2023-03-02 10:50 ` bug#60833: Acknowledgement ([PATCH] sh-script.el: Add support for Zsh's case branches ; |.) Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGdYchsdFu5Q0z5ZiQ6OHuo2yKnwpBiDaF67A0--=WUaEp0otA@mail.gmail.com' \
--to=philippe.altherr@gmail.com \
--cc=60833@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).