GNU bug report logs - #55764
29.0.50; sh-mode: Support mksh's alternate case brace syntax

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Visuwesh <visuweshm@HIDDEN>; Keywords: patch; dated Thu, 2 Jun 2022 13:35:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) patch. Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 55764 <at> debbugs.gnu.org:


Received: (at 55764) by debbugs.gnu.org; 2 Jun 2022 14:01:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 10:01:31 2022
Received: from localhost ([127.0.0.1]:54346 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nwlOF-0002Lk-2A
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2022 10:01:31 -0400
Received: from mail-pf1-f195.google.com ([209.85.210.195]:40635)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <visuweshm@HIDDEN>) id 1nwlOD-0002LW-FL
 for 55764 <at> debbugs.gnu.org; Thu, 02 Jun 2022 10:01:29 -0400
Received: by mail-pf1-f195.google.com with SMTP id z17so4835987pff.7
 for <55764 <at> debbugs.gnu.org>; Thu, 02 Jun 2022 07:01:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=J24xUZcFQ6uHYiqQxa91VUqCnO7ugSToxPx7wuPH/Oc=;
 b=Tt938TlqrqtibBR8IsoyZkSy5ljJyojbL4cnyiu2oLfaNbyG/T7KknLbgIcEq2/EDR
 Qknmv7WFtY8v41haflupofnSW32RHcaPNRxMIkCl0bffY2RMPUHf0RlDzH+ePHf/ZY7L
 JyFGD/aqSsM8bk6RDQof+tgdOvStMXz38hFPq8WiGrBBPWe5OGtS2ER6r0JQ0W7nqf5l
 kptyLxpd1nK691QWHP2X3J8aMj0y5gzl2CBeciSf1yMOXOeS4Kn3DnHZzwotIURvL29q
 4Bm9pqb0IwEFbqlK2OiEYMwcXGL4p0KGOh47as48OCEZsdNWkRfSMdOUMLgrlZsAFHRS
 USMQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=J24xUZcFQ6uHYiqQxa91VUqCnO7ugSToxPx7wuPH/Oc=;
 b=FN9h462+nXf25lfoVoVBRXnpUnl9yJhUm4H6JVbOZYYXnQeli0keZ5eGxeE2nt/uF0
 09k6GMspOG0tDUGAmyDB1dWs3OQwmc+/Thv7CyULlAIGNPHXHhdLbx01a9OotpKMdcaP
 BPdRCaxlJPfbZwq70Q1Chc5KAFZVLcsVxAt64A6ECErU0+QtAiMxrFugNgULw/1v5G+7
 +qmKR1v/Wg5UpDJYnVRmohdRriTYJaQfo1mPTAr4tLCEIgy6Rjl+VY8RjbNB1JWAP+rk
 1cw++emELVhQtizNlk+30QQ0aPaXXTkEcLe1ymbubFtaa5Hp94H6cjjfqj8iRRNVUyhr
 +NCw==
X-Gm-Message-State: AOAM532e5NVDYh4tqNuCYaFxrOop86HsVBUPIyS1Ws9NwxkhwI0X1goV
 ayR0CvJbJyk+tcxzFdWOEno=
X-Google-Smtp-Source: ABdhPJzXhjm9t2ir9HPJYOIJFrfbj8d8Y5CkS4TMFMy3uPJyGhoyB2x0zAl2Z/bKe/l0HVX7ucbpxw==
X-Received: by 2002:a63:4d0:0:b0:3fc:4f01:dac6 with SMTP id
 199-20020a6304d0000000b003fc4f01dac6mr4451214pge.263.1654178483601; 
 Thu, 02 Jun 2022 07:01:23 -0700 (PDT)
Received: from localhost ([49.204.135.220]) by smtp.gmail.com with ESMTPSA id
 j187-20020a638bc4000000b003db822e2170sm3418304pge.23.2022.06.02.07.01.20
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 02 Jun 2022 07:01:22 -0700 (PDT)
From: Visuwesh <visuweshm@HIDDEN>
To: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: Re: bug#55764: 29.0.50; sh-mode: Support mksh's alternate case
 brace syntax
References: <87o7zbp4uc.fsf@HIDDEN> <87o7zbw5dz.fsf@HIDDEN>
Date: Thu, 02 Jun 2022 19:31:18 +0530
In-Reply-To: <87o7zbw5dz.fsf@HIDDEN> (Lars Ingebrigtsen's message of "Thu,
 02 Jun 2022 15:40:08 +0200")
Message-ID: <87k09zp3kh.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 55764
Cc: 55764 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

[=E0=AE=B5=E0=AE=BF=E0=AE=AF=E0=AE=BE=E0=AE=B4=E0=AE=A9=E0=AF=8D =E0=AE=9C=
=E0=AF=82=E0=AE=A9=E0=AF=8D 02, 2022] Lars Ingebrigtsen wrote:

> Visuwesh <visuweshm@HIDDEN> writes:
>
>> 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.
>
> I think that might make sense, but perhaps Stefan has some comments here
> (added to the CCs).

To no one's surprise, the patch is not the right approach.  IIUC, when I
use braces, *pattern) thingies are not recognised as "case-)" anymore so
sh-indent-for-case-label does not get applied.  I tried a bit more but I
only got it to respect the first line but still it is definitely not the
right approach,


--=-=-=
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..96ff8e8627 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1971,9 +1971,9 @@ sh-smie-sh-rules
                              (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 "{") (smie-rule-parent-p "for" "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)
@@ -2021,10 +2021,13 @@ sh-smie-sh-rules
     ('(:after . "in") (sh-var-value 'sh-indent-for-case-label))
     ;; sh-indent-for-continuation: Line continuations are handled differently.
     (`(:after . ,(or "(" "{" "["))
-     (if (not (looking-at ".[ \t]*[^\n \t#]"))
-         (sh-var-value 'sh-indent-after-open)
-       (goto-char (1- (match-end 0)))
-       `(column . ,(current-column))))
+     (cond
+      ((smie-rule-parent-p "case")
+       (sh-var-value 'sh-indent-for-case-label))
+      ((not (looking-at ".[ \t]*[^\n \t#]"))
+       (sh-var-value 'sh-indent-after-open))
+      (t (goto-char (1- (match-end 0)))
+         `(column . ,(current-column)))))
     ;; sh-indent-after-function: we don't handle it differently.
     ))
 

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#55764; Package emacs. Full text available.

Message received at 55764 <at> debbugs.gnu.org:


Received: (at 55764) by debbugs.gnu.org; 2 Jun 2022 13:40:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 09:40:23 2022
Received: from localhost ([127.0.0.1]:53187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nwl3n-0001SJ-0k
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2022 09:40:23 -0400
Received: from quimby.gnus.org ([95.216.78.240]:51404)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1nwl3l-0001Rz-RN
 for 55764 <at> debbugs.gnu.org; Thu, 02 Jun 2022 09:40:22 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=PGfpmo1SKuCWidtaOVbc5Zfb8Vd9j0F4o5QxRSUFpB4=; b=TbCIfsvuSPSk26PYg5KPHtkYPB
 b67bm9gClhpMKJJskio1E2ybvQXrTM57yrBSBF3YipYAoNcT32Vx4VgOj9ibao2GI3Nfvw8VkuflQ
 TNjjI1eVLwmBBCXtKj2Iq3YvkUscO1Y7QUzdeaou59JWS05GtjH6RxdKTV9XBjTpJmfg=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1nwl3b-0008Qj-DM; Thu, 02 Jun 2022 15:40:13 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Visuwesh <visuweshm@HIDDEN>
Subject: Re: bug#55764: 29.0.50; sh-mode: Support mksh's alternate case
 brace syntax
References: <87o7zbp4uc.fsf@HIDDEN>
Date: Thu, 02 Jun 2022 15:40:08 +0200
In-Reply-To: <87o7zbp4uc.fsf@HIDDEN> (Visuwesh's message of "Thu, 02 Jun
 2022 19:03:47 +0530")
Message-ID: <87o7zbw5dz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Visuwesh <visuweshm@HIDDEN> writes: > 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 [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 55764
Cc: 55764 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Visuwesh <visuweshm@HIDDEN> writes:

> 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.

I think that might make sense, but perhaps Stefan has some comments here
(added to the CCs).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#55764; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Jun 2022 13:34:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 02 09:34:07 2022
Received: from localhost ([127.0.0.1]:53153 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nwkxj-0001Fu-II
	for submit <at> debbugs.gnu.org; Thu, 02 Jun 2022 09:34:07 -0400
Received: from lists.gnu.org ([209.51.188.17]:37836)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <visuweshm@HIDDEN>) id 1nwkxi-0001Fn-Bz
 for submit <at> debbugs.gnu.org; Thu, 02 Jun 2022 09:34:06 -0400
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 <visuweshm@HIDDEN>)
 id 1nwkxh-0006h1-Jr
 for bug-gnu-emacs@HIDDEN; Thu, 02 Jun 2022 09:34:06 -0400
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 <visuweshm@HIDDEN>)
 id 1nwkxd-0001Tt-Tf
 for bug-gnu-emacs@HIDDEN; Thu, 02 Jun 2022 09:34:03 -0400
Received: by mail-pl1-x642.google.com with SMTP id o17so4544183pla.6
 for <bug-gnu-emacs@HIDDEN>; 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)
Received: from localhost ([49.204.135.220]) by smtp.gmail.com with ESMTPSA id
 m10-20020a170902db0a00b0015ee985999dsm3592932plx.97.2022.06.02.06.33.56
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 02 Jun 2022 06:33:57 -0700 (PDT)
From: Visuwesh <visuweshm@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 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@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2607:f8b0:4864:20::642;
 envelope-from=visuweshm@HIDDEN; 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-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
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; }.

--=-=-=--




Acknowledgement sent to Visuwesh <visuweshm@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#55764; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 28 Jun 2022 21:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.