nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] [PATCH 7/7] wrapping: when autoindenting, use indentati


From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH 7/7] wrapping: when autoindenting, use indentation of next line as example
Date: Sun, 27 May 2018 11:15:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

Op 22-05-18 om 21:21 schreef Benno Schulenberg:
> When doing autoindentation, and the next line is not the start of
> a new paragraph, then use the indentation of that line for the new
> line, as it is more likely to have the desired indentation -- the
> current line might be the start of the paragraph and thus could
> have a deviant indentation.

This new behavior is needed so that, when the user is writing prose
and adds some text to the first line of a paragraph, that then the
words that get auto-wrapped to a new line get the right indentation,
so that a ^J will rewrap the paragraph as a whole instead of only
the first line and the added line.

But I worry that when the user is writing code, that the new behavior
is too unpredictable.  Because, for example, when things look like:

    if (condition)
        statement;

and the user wants to add a second statement to the body of the 'if',
places the cursor at the end of the 'if' line, adds a " {" and presses
<Enter>...  With the new behavior, the cursor will be where the x is:

    if (condition) {
        x
        statement;

Which is cool.  But when the original text looked like this:

    /* Comment. */
    if (condition)
        statement;

Then after the addition of " {" and <Enter>, the cursor will be here:

    /* Comment. */
    if (condition) {
    x
        statement;

because to nano the 'if' line looked like the end of a paragraph and
nano assumes the user wants to extend it.

It would be possible to differentiate between an automatic hard-wrap
and the user pressing <Enter>, so that in the latter case, the new
line is always given the same indentation as the previous one, but...
that also kills the "clever" behavior of the first example.

I don't want to go to the trouble of differentiating between an
automatic and an explicit <Enter>, so I will leave things as they
are for now, and will see how people react to the new behavior.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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