From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Doug Maxey Newsgroups: gmane.emacs.bugs Subject: bug#53817: 28.0.91; sh-mode indent misses on 'if test; then' when 'then' is on 'if' line Date: Sun, 06 Feb 2022 18:14:45 -0600 Message-ID: <14f63bd0e8e26669615c2661dfe53f43420a0aca.camel@maxeygroup.tech> References: <87czk0zk43.fsf@maxeygroup.tech> <87y22n367a.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-flhOq5yb523YyV/ObgCM" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19812"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.42.3 (3.42.3-1.fc35) Cc: Doug Maxey , 53817@debbugs.gnu.org To: Stefan Monnier , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 07 02:03:37 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 1nGsRN-0004vA-Ce for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Feb 2022 02:03:37 +0100 Original-Received: from localhost ([::1]:37444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGsRK-0007et-0I for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 06 Feb 2022 20:03:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGsQp-0007H9-Sv for bug-gnu-emacs@gnu.org; Sun, 06 Feb 2022 20:03:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGsQo-0007qz-JT for bug-gnu-emacs@gnu.org; Sun, 06 Feb 2022 20:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nGsQo-0004P2-E1 for bug-gnu-emacs@gnu.org; Sun, 06 Feb 2022 20:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Doug Maxey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Feb 2022 01:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53817 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 53817-submit@debbugs.gnu.org id=B53817.164419576316897 (code B ref 53817); Mon, 07 Feb 2022 01:03:02 +0000 Original-Received: (at 53817) by debbugs.gnu.org; 7 Feb 2022 01:02:43 +0000 Original-Received: from localhost ([127.0.0.1]:40405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGsQU-0004OT-I7 for submit@debbugs.gnu.org; Sun, 06 Feb 2022 20:02:43 -0500 Original-Received: from mail.maxeygroup.tech ([70.231.4.161]:12525) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGrg8-0002Xy-Bp for 53817@debbugs.gnu.org; Sun, 06 Feb 2022 19:14:49 -0500 Original-Received: from [10.11.45.164] (php.internal.maxeygroup.tech [10.11.45.164]) by mail.maxeygroup.tech (8.17.1/8.17.1) with ESMTP id 2170Ek4P188704; Sun, 6 Feb 2022 18:14:46 -0600 In-Reply-To: X-Mailman-Approved-At: Sun, 06 Feb 2022 20:02:41 -0500 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:226207 Archived-At: --=-flhOq5yb523YyV/ObgCM Content-Type: multipart/alternative; boundary="=-OUNIwG1PnDjthbABt7ZD" --=-OUNIwG1PnDjthbABt7ZD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2022-02-06 at 19:11 -0500, Stefan Monnier wrote: > > (defun sh-smie--default-backward-token () > > [...] > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (pro= gn (skip-syntax-backward ".w_'") > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (or (not (zerop (skip-syntax-backwa= rd "\\"))) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (when (eq ?= \\ (char-before (1- (point)))) > >=20 > > Semi-colons have punctuation syntax, so we're skipping back over > > the > > entirety of "test;then" instead of stopping after "then". >=20 > We should indeed only skip over "then", and then only over ";" and > then > only over "test". >=20 > > This looks easy enough to fix, but the overall logic of that > > function is > > somewhat obscure to me, so I've added Stefan to the comments; > > perhaps he > > has some comments. >=20 > The sh syntax is fairly nasty to parse, especially backwards, so I > can't > give you any general comment here.=C2=A0 I'd try something and then see i= f > it > breaks any tests (including looking at test/manual/indent/shell.sh). >=20 > For sure, I'd recommend adding a regression test. just a further point, if it helps, this was fine in 27.2. =C2=A0 >=20 >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Stefan >=20 --=-OUNIwG1PnDjthbABt7ZD Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
On Sun, 2022-02-06 at 19:11 -0500, Stefan Mon= nier wrote:
(defun sh-smie--default-backward-token ()
[...]
            (progn= (skip-syntax-backward ".w_'")
     =             &nb= sp; (or (not (zerop (skip-syntax-backward "\\")))
  = ;            &n= bsp;        (when (eq ?\\ (char-before (= 1- (point))))

Semi-colons have punctuation syn= tax, so we're skipping back over the
entirety of "test;then" = instead of stopping after "then".

We should indeed only skip over "then", and then only over ";" and then
only over "test".

This looks easy enough to fix, but the overall logic of that fun= ction is
somewhat obscure to me, so I've added Stefan to the = comments; perhaps he
has some comments.

The sh syntax is fairly nasty to parse, especially bac= kwards, so I can't
give you any general comment here.  I= 'd try something and then see if it
breaks any tests (includi= ng looking at test/manual/indent/shell.sh).

Fo= r sure, I'd recommend adding a regression test.
=
just a further point, if it helps, this was fine in 27.2.
 


        Stefan

=

--=-OUNIwG1PnDjthbABt7ZD-- --=-flhOq5yb523YyV/ObgCM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgEFqv+KdzexjaJ05sIZSRoIHzIkFAmIAZHUACgkQsIZSRoIH zImVqg//U0R6aAJggg5AZSOPfXIor6ghf+q6hEj4Bx23L1O4tQhICZp/zw3h8Liu rhkbypR9QF/ltrppyo2KRYu1goOdsqHb+dzcM21xhg0+Oc6phA94l1h1akxsG/EF Dou6IVtBVz1r73w0mzGBR7lmC4HFupCj1pnifp8r5wgODpI1cRwyy/3ENTylbWxd RPi4vh+ilhm8zmEGVN14hvmvora/JX7iDwKD2mBeq+e9SxMT/1CuYyzOhqLwPrtH tiduT97AEmsPljQxC2U+sCLypgQPSUuU7c0rBfGRBrf2GN9opIv8V+EiTJQIwttg yael0rGfmg0812PsLJeQN+CwkyuMdxQ3fArYthn9H/saV8Pc2kIAkVFi99wqEKcD p8EeGglpvs4sC+v/2NkdD7tt+eshVrYvRdtd06u7lIM/PB8uvMPGVQ6TdWPp8TuN bRoLwzQ0gU8mrTY8tsoBD09cYRb/z0V35fDiau3FDwyY4NruQBpSB9jd0rK+iM2w xmcnCFCWfrcAABVyOq8msVwlGbnOwUcg020m3JviVDlDRrLyDm6R790d5M8dIiko APD/FmDOZhBK5+lq/X5SNRsEpHpeQ3MNufePhea8J0OACqUONkXT9DZ9DO9A3w8H ouFJxFCHfYNRc5DDGBzCXX5A00NmKXuLsE9Ep9xqpKDg4u3nxm0= =FBpa -----END PGP SIGNATURE----- --=-flhOq5yb523YyV/ObgCM--