emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60832: closed ([PATCH] sh-script.el: Use sh-indent-for-continuation


From: GNU bug Tracking System
Subject: bug#60832: closed ([PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations.)
Date: Thu, 02 Mar 2023 10:43:02 +0000

Your message dated Thu, 02 Mar 2023 12:42:13 +0200
with message-id <83ilfje8oq.fsf@gnu.org>
and subject line Re: bug#60832: Acknowledgement ([PATCH] sh-script.el: Use 
sh-indent-for-continuation to indent line continuations.)
has caused the debbugs.gnu.org bug report #60832,
regarding [PATCH] sh-script.el: Use sh-indent-for-continuation to indent line 
continuations.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
60832: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60832
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations. Date: Sun, 15 Jan 2023 12:55:43 +0100
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

Attachment: 0001-For-line-continuations-use-sh-indent-for-continuatio.patch
Description: Source code patch


--- End Message ---
--- Begin Message --- Subject: Re: bug#60832: Acknowledgement ([PATCH] sh-script.el: Use sh-indent-for-continuation to indent line continuations.) Date: Thu, 02 Mar 2023 12:42:13 +0200
> From: Philippe Altherr <philippe.altherr@gmail.com>
> Date: Fri, 17 Feb 2023 16:21:36 +0100
> 
> Here is an updated patch against the current master branch.

Thanks, installed on master.

Please in the future accompany the changes with a ChangeLog-style
commit log messages (see CONTRIBUTE for details).  Also, the summary
in the Subject line cannot be longer than 78 characters (again
mentioned in CONTRIBUTE), otherwise our Git commit hooks reject the
patch, and I need to apply it by hand.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]