nano-devel
[Top][All Lists]
Advanced

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

the justifying of indented text


From: Benno Schulenberg
Subject: the justifying of indented text
Date: Tue, 17 Dec 2019 12:16:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

Op 16-12-2019 om 20:20 schreef Seb:
> Yes, I did add \ to the quotestring, but only as a poor solution to a problem 
> I
> met when newer versions of Nano starting differing from Pico's behavior. Here 
> is
> an example:

I've changed your example a bit, because the "\noindent" on a line that is
itself indented was confusing.

>     \somecommand
>     Lorem ipsum dolor sit amet, consectetur adipiscing elit
> 
> Each line starts with a <Tab> and there is no more text than that. When the
> cursor is on the second line, I expect ^J to leave the two lines alone.

Why do you expect that?  Just because that is how Pico did it?  Or because
you think that indented lines should never be rewrapped?  Or to be more
precise: that an indented line can only ever be the start of a paragraph,
never the continuation of a paragraph?  If you opine the latter, please
give your reasoning.

> Moreover, if the text becomes a little longer:
> 
>     \somecommand
>     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
> eiusmod tempor incididunt ut labore
> 
> then the behavior of ^J depends on which line it was called.

Not really.  It's just that nano parses the paragraphs differently from
you.  For nano (since 2.9.8) two lines that have the same indentation
clearly belong to the same paragraph.  And after the second line of a
paragraph, its indentation may not change any more.  So nano sees
"\somecommand" and "Lorem ipsum..." as a single paragraph, and the
"eiusmod tempor..." as a separate paragraph.  That is clearly not
the right way to see (it is not the way a human sees it), but how
can nano know that the "\somecommand" is not normal text and should
not be justified together with the succeeding lines?

Now, if the indentation in the above example does not consist of tabs
but of spaces, then with 'pico -r120', ^J on the first or the second
line will justify those lines into a single one, and a second ^J will
add the third to it too.  Strange and unwanted behavior, I would think.

To complicate matters further, older nanos (before 2.9.8) would leave
the "/somecommand" alone and would justify only the two lines that
start with "Lorem ipsum...".  (That is the behavior you seem to want.)
*But*, when one used --autoindent, then a ^J would rewrap all three
lines as a single paragraph at once.  So... this means you never
used --autoindent, or you toggled it off before you type ^J?

As seen above, Pico makes a difference between lines indented with a tab
or tabs (or even just containing a tab somewhere in its indentation) and
lines that have only spaces as their indentation.  The lines that contain
a tab somewhere in their indentation can only be the start of a paragraph,
they are never seen a a continuation, whereas lines that start with spaces
can be anything.  Nano does not make this difference, and never did.  This
divergence between nano and Pico I have reported in:

  https://savannah.gnu.org/bugs/?57402

But I don't know what to do about it.  I can make a patch that would
consider any line that starts with a tab as the start of a paragraph,
but I don't think that would be a good default behavior, as it would
prevent justifying an indented comment block.  True, the latter is
not very common, but it is what makes ^J useful when writing code.
And to add an option that determines how to behave when finding a
tab-indented line... that goes too far.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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