From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philippe Altherr Newsgroups: gmane.emacs.bugs Subject: bug#60832: [PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations. Date: Sun, 15 Jan 2023 12:55:43 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000024153a05f24c26e7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31034"; mail-complaints-to="usenet@ciao.gmane.io" To: 60832@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 15 15:14:33 2023 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 1pH3mL-0007tS-3G for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Jan 2023 15:14:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH3lv-0002b7-Ff; Sun, 15 Jan 2023 09:14:07 -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 1pH3ls-0002ao-GT for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2023 09:14:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pH3lq-00082N-N4 for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2023 09:14:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pH3lq-0001WF-FW for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2023 09:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philippe Altherr Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Jan 2023 14:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60832 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16737920185787 (code B ref -1); Sun, 15 Jan 2023 14:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Jan 2023 14:13:38 +0000 Original-Received: from localhost ([127.0.0.1]:56419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pH3lS-0001VG-2g for submit@debbugs.gnu.org; Sun, 15 Jan 2023 09:13:38 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:48296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pH1cH-0001aa-DR for submit@debbugs.gnu.org; Sun, 15 Jan 2023 06:56:02 -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 1pH1cE-00026Y-TD for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2023 06:56:00 -0500 Original-Received: from mail-ua1-x92e.google.com ([2607:f8b0:4864:20::92e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pH1cC-0005wH-UX for bug-gnu-emacs@gnu.org; Sun, 15 Jan 2023 06:55:58 -0500 Original-Received: by mail-ua1-x92e.google.com with SMTP id f26so6121647uab.2 for ; Sun, 15 Jan 2023 03:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=PaSwfub54QK4u4yLLZ6DGFmmY9BtgrYcbirEL/VPaN8=; b=c9El0VFoaxOLxU5yl3B95zW8qapRr1H/NUnHxTLj6vU2IWN/HcQY+/VAAs3SqhZL2V KNy/ECNo5Xa5uRxi317/JthWnPJm1fTTOCUVr6LO8VtyS8NEb3VvBmJHdA53f0yNOqeZ G9OQ5KmlgBccbrxpK1+12NmsDhtneYg7e3elwl8+CoAJoPT+LxdJjXWolujmkIhpM5Ef kh/hzvQLIx4Eq8dJt3cXQ5po7306ghWQ7HZJQEMniGDOHF7IM8uHOAwymFTKCowHhkXO 9UkF0XAUJnxqdUu4BjNefj0Ss3C1fBW+7p1akcLNW82zHzxGhtwpdni8pttP4nLGoTk5 SQOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PaSwfub54QK4u4yLLZ6DGFmmY9BtgrYcbirEL/VPaN8=; b=6N8Injb8D5sgQz7amuBs/W9FexRxYD4gVTNBa44guxBCermOMyVOmwMZYxhX3yfxzV e7azIE06XU4u6zbrw4v3DmOSigM12AZZ8Ga4WnwY9Zqg0bHuF3VVnQP46EJvoTLqf9zt nn2huZaa7zYGO9Tn9ST3c/UISsmp2mM8dLDmGWtgDY511O8kZXUGZcRENUxohyLioVxJ 4lGdcHcBon1+wKuAoRRtCrRdnBX3aof5cRQlZ7iC5IgiN9QtVc3ZXEikkBAT8H1GDLyX 0Rz0wk2ZMhTLJq28Qvj8pxtcgS5t7jcHKDbzI9TApvE0TdoeyWdOw51fYNBgWnKUyNvh DLIw== X-Gm-Message-State: AFqh2krR/IGDKW3vh58SOjn/nJmZk5ipVkBX/a6zDsj7b/jPZ+wtJz+K vqwH+OWng17hw1Mi8H9RDM7R2BITE+gWyToodZRfnJ64+w0= X-Google-Smtp-Source: AMrXdXs5S0ecstGQ5hsEC6RtH4kw4LOSN4Qy/3chTP9TbaR1RE0XUlnqcxEKIRFU6p1Df58OkH9UFGZG/GRQNNGOVGQ= X-Received: by 2002:a9f:368d:0:b0:5d7:ae9f:6208 with SMTP id p13-20020a9f368d000000b005d7ae9f6208mr3436744uap.6.1673783754879; Sun, 15 Jan 2023 03:55:54 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::92e; envelope-from=philippe.altherr@gmail.com; helo=mail-ua1-x92e.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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 15 Jan 2023 09:13:36 -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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253431 Archived-At: --00000000000024153a05f24c26e7 Content-Type: multipart/alternative; boundary="00000000000024153705f24c26e5" --00000000000024153705f24c26e5 Content-Type: text/plain; charset="UTF-8" The variable sh-indent-for-continuation is defined in sh-script.el as "How much to indent for a continuation statement." but it is never used. In particular, the function sh-smie--indent-continuation , which indents line continuations, doesn't use it and instead uses sh-basic-offset. The attached patch modifies sh-smie--indent-continuation to use sh-indent-for-continuation instead of sh-basic-offset. I have tested the patch by adding the patched function sh-smie--indent-continuation to my .emacs (in a (with-eval-after-load 'sh-script ...) statement). Here are details of what changes on the example used in the description of sh-indent-after-continuation . In all cases I have used the following settings: (setq sh-basic-offset 4) (setq sh-indent-for-continuation '++) - With (setq sh-indent-after-continuation 'always), I get the following result with the unpatched function: for f \ in a; do \ toto; \ done This looks wrong to me because it doesn't take into account my setting (setq sh-indent-for-continuation '++) for line continuations. With the patched function I get the expected result: for f \ in a; do \ toto; \ done - With (setq sh-indent-after-continuation nil), I get the following result with the unpatched and the patched function: for f \ in a; do \ toto; \ done This looks correct to me. My understanding is that with (setq sh-indent-after-continuation nil), line continuations are kind of ignored and thus the setting (setq sh-indent-for-continuation '++) should never intervene, which is also the case. - With (setq sh-indent-after-continuation t), I get the following result with the unpatched function: for f \ in a; do \ toto; \ done With the patched function, I get the following result: for f \ in a; do \ toto; \ done I think that's also what's expected with (setq sh-indent-for-continuation '++) but I'm not entirely sure as I don't fully understand how (setq sh-indent-after-continuation t) is supposed to work. Overall, I'm pretty confident that the first change in my patch should be done. It's what affects the setting (setq sh-indent-after-continuation 'always). I'm a bit less confident about the second change, which affects the setting (setq sh-indent-after-continuation t). Philippe --00000000000024153705f24c26e5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The variable sh-indent-for-continuation is defined in sh-script.= el as "How much to indent for a continuation statement." but it i= s never used. In particular, the function=C2=A0sh-smie--indent-continuation, which indents = line continuations, doesn't use it and instead uses sh-basic-offset. Th= e attached patch modifies sh-smie--indent-continuation=C2=A0to use=C2=A0sh-= indent-for-continuation instead of sh-basic-offset.

I have tested the patch by adding the patched function sh-smie--indent-co= ntinuation to my .emacs (in a=C2=A0(with-eval-after-load 'sh-script ...= ) statement).

Here are details of what changes on = the example used in the description of sh-indent-after-continuation. In all cases I have us= ed the following settings:

(setq sh-basic-offset 4= )
(setq sh-indent-for-continuation '++)

  • With (setq sh-indent-after-continuation 'always), I get the fo= llowing result with the unpatched function:

    for f \
    =C2=A0 =C2=A0= in a; do \
    =C2=A0 =C2=A0 toto; \
    =C2=A0 =C2=A0 done

    This look= s wrong to me because it doesn't take into account my setting (setq sh-= indent-for-continuation '++) for line continuations. With the patched f= unction I get the expected result:

    for f \
    =C2=A0 =C2=A0 =C2=A0 = =C2=A0 in a; do \
    =C2=A0 =C2=A0 =C2=A0 =C2=A0 toto; \
    =C2=A0 =C2=A0 = =C2=A0 =C2=A0 done

  • With (setq sh-indent-after-continuation = nil), I get the following result with the unpatched and the patched functio= n:

    for f \
    in a; do \
    =C2=A0 =C2=A0 toto; \
    done

    Thi= s looks correct to me. My understanding is that with (setq sh-indent-after-= continuation nil), line continuations=C2=A0are kind of ignored and thus the= setting (setq sh-indent-for-continuation '++) should never intervene, = which is also the case.

  • With (setq sh-indent-after-continua= tion t), I get the following result with the unpatched function:

    for= f \
    =C2=A0 =C2=A0 in a; do \
    =C2=A0 =C2=A0 toto; \
    =C2=A0 =C2=A0 = done

    With the patched function, I get the following result:

    f= or f \
    =C2=A0 =C2=A0 =C2=A0 =C2=A0 in a; do \
    =C2=A0 =C2=A0 toto; \=C2=A0 =C2=A0 done

    I think that's also what's expected wit= h (setq sh-indent-for-continuation '++) but I'm not entirely sure a= s I don't fully understand how (setq sh-indent-after-continuation t) is= supposed to work.
Overall, I'm pretty confident that the= first change in my patch should be done. It's what affects the setting= (setq sh-indent-after-continuation 'always). I'm a bit less confid= ent about the second=C2=A0change, which affects the setting (setq sh-indent= -after-continuation t).

Philippe
=

--00000000000024153705f24c26e5-- --00000000000024153a05f24c26e7 Content-Type: application/x-patch; name="0001-For-line-continuations-use-sh-indent-for-continuatio.patch" Content-Disposition: attachment; filename="0001-For-line-continuations-use-sh-indent-for-continuatio.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lcvgiiu60 RnJvbSBjODVlNzNkNzQyNDUzZGEzMzBkODUwOGFj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bmRlbnQtZm9yLWNvbnRpbnVh dGlvbikpKSkpCiAgICAodAogICAgIDs7IEp1c3QgbWFrZSBzdXJlIGEgbGluZS1jb250aW51YXRp b24gaXMgaW5kZW50ZWQgZGVlcGVyLgogICAgIChzYXZlLWV4Y3Vyc2lvbgpAQCAtMjAzMSw3ICsy MDMxLDEwIEBAIE1heSByZXR1cm4gbmlsIGlmIHRoZSBsaW5lIHNob3VsZCBub3QgYmUgdHJlYXRl ZCBhcyBjb250aW51ZWQuIgogICAgICAgICAgICAgICAgICAgICAgICA7OyBjaGVjayB0aGUgbGlu ZSBiZWZvcmUgdGhhdCBvbmUuCiAgICAgICAgICAgICAgICAgICAgICAgICg+IGNpIGluZGVudCkp CiAgICAgICAgICAgICAgICAgICAgICAgKHQgO1ByZXZpb3VzIGxpbmUgaXMgdGhlIGJlZ2lubmlu ZyBvZiB0aGUgY29udGludWVkIGxpbmUuCi0gICAgICAgICAgICAgICAgICAgICAgIChzZXRxIGlu ZGVudCAobWluICgrIGNpIHNoLWJhc2ljLW9mZnNldCkgbWF4KSkKKyAgICAgICAgICAgICAgICAg ICAgICAgKHNldHEKKyAgICAgICAgICAgICAgICAgICAgICAgIGluZGVudAorICAgICAgICAgICAg ICAgICAgICAgICAgKG1pbgorICAgICAgICAgICAgICAgICAgICAgICAgICgrIGNpIChzaC12YXIt dmFsdWUgJ3NoLWluZGVudC1mb3ItY29udGludWF0aW9uKSkgbWF4KSkKICAgICAgICAgICAgICAg ICAgICAgICAgbmlsKSkpKSkKICAgICAgICAgICBpbmRlbnQpKSkpKSkKIAotLSAKMi4zOS4wCgo= --00000000000024153a05f24c26e7--