From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#55764: 29.0.50; sh-mode: Support mksh's alternate case brace syntax Date: Thu, 02 Jun 2022 19:03:47 +0530 Message-ID: <87o7zbp4uc.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24459"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 55764@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 02 15:35:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwkyt-000697-L5 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jun 2022 15:35:19 +0200 Original-Received: from localhost ([::1]:58836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwkys-0006uW-49 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jun 2022 09:35:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwkyd-0006sh-31 for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2022 09:35:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwkyc-0001an-QP for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2022 09:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nwkyc-0001Hf-Ns for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2022 09:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jun 2022 13:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55764 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16541768474835 (code B ref -1); Thu, 02 Jun 2022 13:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Jun 2022 13:34:07 +0000 Original-Received: from localhost ([127.0.0.1]:53153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwkxj-0001Fu-II for submit@debbugs.gnu.org; Thu, 02 Jun 2022 09:34:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:37836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwkxi-0001Fn-Bz for submit@debbugs.gnu.org; Thu, 02 Jun 2022 09:34:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwkxh-0006h1-Jr for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2022 09:34:06 -0400 Original-Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:39457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwkxd-0001Tt-Tf for bug-gnu-emacs@gnu.org; Thu, 02 Jun 2022 09:34:03 -0400 Original-Received: by mail-pl1-x642.google.com with SMTP id o17so4544183pla.6 for ; Thu, 02 Jun 2022 06:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:user-agent:mime-version; bh=qj6h7rSSPWFJetNFB51VE7L/peXA1VDLl7wDC+wavGw=; b=RPAEqKvWVzORe2d2LdCWR2bUlMOn0qplRmr+KmXZoOExSbYaF1mW0imI7Kgz6GLQ+n GAnSpKoPrUGgLotLCtqHkqlqTS7VpaBnJ2UPLu9gbBk6mte3tDdx47ld9+LvFIb6vFqL K5lq/1am1BDXS5HPBnIvDAW/r0LKPzjf1EgLU6AE0JVkvR6sFZlUGci8tKrjpcpd/qMY DhLecleQGv354s0voWuxH7HYQYYQ2d6cpDMrOhtQ3lgZlYmLdZRTZ7c41vJXz4lzTCF8 RRxYGf/MOyM4/BM0buYelmPr9mj7w0j8iaTMauo9hvYMrDLqKkBvVVlMH0LhRiyeuqtj uRmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=qj6h7rSSPWFJetNFB51VE7L/peXA1VDLl7wDC+wavGw=; b=NXO7Zj/W7612KxfNzBqhixXEq3cjoytcQSZCSasls33UFxFzBRKcum9e1ji3ugH4ER WgIrvLExgOmXD2f/55synpxZ9tSgtQOuRFqfXaDlPhjw/tiKNM6M6AavNab6X4FeMFUH Dry0lHFAyzh8XE3XXD0HoPVVq25nuvqZCSjhkZsG+M840lbn6AV6aFFfYcHql4cmji1N xSQo7HRk3nxjXwEiWqjzT5/d14deaeGpd/O/HQhJGgLtAQ583WsCrVKi0lFMZsE0u9mU EWH+x+KswfESJRf3jpMildiR2nBpzCls/8ARMAqOSsP/ODZC51iDPdAuA71EerRI92nB q3nA== X-Gm-Message-State: AOAM531gkkx6JZ7fSV5O5Qh5mQ5SaTeZd8XcapLXqrdFmfFsqOrrzDu+ AB/TTsCrr8eYrNly0A1A9Fd2dsEuzbg= X-Google-Smtp-Source: ABdhPJzGGC7eh+JJcGowzRN3nqDBeWnpnd9QcKopzxsj2173g32PTLhO3InZHL7kEXDYW44ySM0aPQ== X-Received: by 2002:a17:90a:2807:b0:1e6:7eef:8e9d with SMTP id e7-20020a17090a280700b001e67eef8e9dmr5134520pjd.109.1654176840011; Thu, 02 Jun 2022 06:34:00 -0700 (PDT) Original-Received: from localhost ([49.204.135.220]) by smtp.gmail.com with ESMTPSA id m10-20020a170902db0a00b0015ee985999dsm3592932plx.97.2022.06.02.06.33.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 06:33:57 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x642.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233551 Archived-At: --=-=-= Content-Type: text/plain mksh and OpenBSD's ksh support an alternative case syntax for historical reasons [1], case $i { *pattern) do ;; *pattern2) do2 ;; } Currently, sh-mode cannot handle this and the easy way out of writing a semicolon after $i is out since, % case "foo"; { *o) echo 1;; } /bin/mksh: syntax error: unexpected ';' I came with the attached patch after a bit of trial and error but I'm not sure if it is the right way to do it. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=mksh-braces.patch diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 4d2554c087..588d9038e5 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1971,9 +1971,10 @@ (sh-var-value 'sh-indent-for-case-label))) (`(:before . ,(or "(" "{" "[" "while" "if" "for" "case")) (cond - ((and (equal token "{") (smie-rule-parent-p "for")) + ((and (equal token "{") (or (smie-rule-parent-p "for") + (smie-rule-parent-p "case"))) (let ((data (smie-backward-sexp "in"))) - (when (equal (nth 2 data) "for") + (when (member (nth 2 data) '("for" "case")) `(column . ,(smie-indent-virtual))))) ((not (smie-rule-prev-p "&&" "||" "|")) (when (smie-rule-hanging-p) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable -- [1] Here's what the mksh manual says, For historical reasons, open and close braces may be used instead of in and esac, for example: =E2=80=9Ccase $foo { (ba[rz]|blah) date ;;= }=E2=80=9D and OpenBSD's ksh manual says, For historical reasons, open and close braces may be used instead of in and esac e.g. case $foo { *) echo bar; }. --=-=-=--