help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Debugging SMIE for sh-script.el


From: Stefan Monnier
Subject: Re: Debugging SMIE for sh-script.el
Date: Sun, 05 Sep 2021 19:02:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> I do understand that, but the default (smie-indent-calculate) cycle being
> inadequate for the current use case is where we started at.

I don't think so.

At the beginning the case for continuation lines was handled directly to
indent things like

    /usr/bin/emacs -l foo/bar.el   \
                   toto/titi.el

and

    cat food; /usr/bin/emacs -l foo/bar.el   \
                             toto/titi.el

If you remove `sh-smie--indent-continuation` you should see that indeed
the above lines are indented as shown.

Then some users came and said they didn't like this style and wanted
instead continuation lines to be indented without paying attention to
the structure of the code on the logical line (which is spread over
several lines) and just indent the subsequent lines at a fixed offset
from the first line, as in:

    /usr/bin/emacs -l foo/bar.el   \
        toto/titi.el

That's when `sh-smie--indent-continuation` was added (along with the
var `sh-indent-after-continuation`), IIRC.
Additionally, the original scheme (which pays attention to the structure
of the code) was refined to make sure that continuation lines are
indented at least a bit more than the first line,
i.e. instead of

    if grep foo    \
            files; \
    then bar;      \
    else baz;      \
    fi

we wanted to impose something like:

    if grep foo    \
            files; \
        then bar;  \
        else baz;  \
        fi

which is why `sh-smie--indent-continuation` calls
`smie-indent-calculate` first, then looks at the result and if it's less
deep than "baseline indent + offset" then it forces "baseline indent + offset".


        Stefan




reply via email to

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