From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#55764: 29.0.50; sh-mode: Support mksh's alternate case brace syntax Date: Wed, 10 Jan 2024 14:24:34 -0800 Message-ID: References: <87o7zbp4uc.fsf@gmail.com> <87o7zbw5dz.fsf@gnus.org> <87k09zp3kh.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1502"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 55764@debbugs.gnu.org, Visuwesh To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 10 23:25:28 2024 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 1rNh0p-0000D2-VG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jan 2024 23:25:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNh0S-0007Li-Lr; Wed, 10 Jan 2024 17:25:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNh0R-0007LS-84 for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 17:25:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNh0Q-0007Jk-Vt for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 17:25:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rNh0P-0007qF-OD for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 17:25:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jan 2024 22:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55764 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 55764-submit@debbugs.gnu.org id=B55764.170492548330113 (code B ref 55764); Wed, 10 Jan 2024 22:25:01 +0000 Original-Received: (at 55764) by debbugs.gnu.org; 10 Jan 2024 22:24:43 +0000 Original-Received: from localhost ([127.0.0.1]:43449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNh07-0007pd-Ff for submit@debbugs.gnu.org; Wed, 10 Jan 2024 17:24:43 -0500 Original-Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:56410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNh04-0007pO-7b for 55764@debbugs.gnu.org; Wed, 10 Jan 2024 17:24:41 -0500 Original-Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-555aa7fd668so5437266a12.0 for <55764@debbugs.gnu.org>; Wed, 10 Jan 2024 14:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704925475; x=1705530275; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=sayAdyRpNvk2t9Q37UspohPp80f3TBu6aREpQlgKbao=; b=Bf+FlFv8l7LOGiIGoqW9GsisbI22Ny99ZAeBzrpVbfnHX0dygmugKslbC1jptTyN9F 85+6amPVWgU8Da0EUzoasd75VvMgc3MpHbkyMXRXxesCesKVLPx/5MWdcP+PrNF2KXBQ X2iYWeTVkMzPiBLGhcM12Lsyum/GjnWcJzZ5ee+Gr39KKYMhwdOACUmLFqlq83GUnu20 GsE9/Y1g4umbx7PwdSJCOpj22DhWJGgBxHd8NnfOOzGlnXwmEAwO4jMa6JyqQjHsHelZ ImvW36gVvEyYANm8wV708PU/Nw4zfLQlgyGqlt35FWd57ka+0nKVnswO4F6YIJb04Ix3 ErpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704925475; x=1705530275; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sayAdyRpNvk2t9Q37UspohPp80f3TBu6aREpQlgKbao=; b=feA3HDSLIYHvbBN4q0i0/C58qqFAti0h7/Nsqt4Md5p1DXLzcTRqXr5x6TajIQW6fW ia8G5vLd1Mu1FxeNv+XECgeGK7y3jKuLLeQ0wgiHIDtNalV0270mJ7etp48Pw5zK03Qv 0Wx/oJyxQV/A35X1xDrO2mk7v0Uap8nzq9n8XcJl8Q9Abnqp50/I1zUPuTMfCK/TLrDu xklqXxhc+ISGkDy5D4E4yuuwLGIDaK2ER1sUL2qFL2Z64sNCd98nF+88Jj75oHqNJNpM fq57RgngtmVJKvOrUuKj/TEoKRhakyUqWXitvjifoljRs+WP0mX0ST6H7+GDfJbzTKR8 C/dw== X-Gm-Message-State: AOJu0YxqvL7Yf7nbBRMkN+lz/jDGuj5151WOWBQsTBvhKV8+pFTVM2zZ 0U0k9WU7UH4Z+10R/AmYp/gCUMevIxB0VsqFJ8g= X-Google-Smtp-Source: AGHT+IGUWaO9CkTtxNTcnCvxCCbC3xYYn0j+TnIhxtNRcOeQyKUKVwfQ4Gn84eTO2TW0/FA3mfxC0EB7Q2+vRNrThCs= X-Received: by 2002:a05:6402:34d0:b0:557:aff:2de8 with SMTP id w16-20020a05640234d000b005570aff2de8mr81931edc.19.1704925475131; Wed, 10 Jan 2024 14:24:35 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 10 Jan 2024 14:24:34 -0800 In-Reply-To: (Stefan Monnier's message of "Sat, 30 Sep 2023 23:37:28 -0400") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277840 Archived-At: Stefan Monnier writes: >> 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, > > The first part of the puzzle is to fix the syntax-category of the `)` so > it's recognized as a "case-)" rather than a normal ("matched") paren. > > The patch below seems to do the trick. If you think it looks good, then please install. Nothing stood out when I read it over, FWIW. > > > Stefan > > > diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el > index cc521cb0591..b34be83367a 100644 > --- a/lisp/progmodes/sh-script.el > +++ b/lisp/progmodes/sh-script.el > @@ -1053,7 +1053,8 @@ 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 ";\\(?:;&?\\|[&|]\\)\\|\\_ + ;; Also recognize OpenBSD's case X { ... } (bug#55764). > + (and (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_ ;; ";; 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 > @@ -2053,9 +2054,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) > diff --git a/test/manual/indent/shell.sh b/test/manual/indent/shell.sh > index 5b3fb0e66fb..42a981d312e 100755 > --- a/test/manual/indent/shell.sh > +++ b/test/manual/indent/shell.sh > @@ -189,3 +189,10 @@ bar () > > fi > } > + > +case $i { # Bug#55764 > + *pattern) > + (cd .; echo hi); > + do1 ;; > + *pattern2) do2 ;; > +}