bugGNU nano - Bugs: bug #52147, trailing whitespace is getting...

 
 

bug #52147: trailing whitespace is getting colored also in the help texts

Submitted by:  None
Submitted on:  Sat 30 Sep 2017 08:43:37 PM UTC  
 
Severity: 2 - MinorStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 12 Oct 2017 05:19:58 PM UTC, comment #12:

Fixed in git, 44368157.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 09 Oct 2017 08:12:30 AM UTC, comment #11:

ha, daar had ik niet aan gedacht.

Good catch and thanks for finding the root cause, it was driving me crazy. I'll submit another report regarding the trimming in word wrap mode.

I think we have what is called french spacing? Maybe i should also use dutch locale when using nano because double spaces after a sentence end is something i don't like.

Thanks for looking into it!

Anonymous
Sun 08 Oct 2017 07:30:55 PM UTC, comment #10:

[Changing the subject of this bug report, as it has concentrated on the miscoloring in the help text. Please rereport your request for the live trimming of trailing spaces in new "bug".]

When I copy your exact setup (/etc/nanor fully commented, an exact copy and paste of your ~/.nanorc, and that on a Manjaro system, which should be comparable to an Arch Linux system, and using the Manjaro binary), I still cannot reproduce your result. Okay, the trailing whitespace in a normal buffer is colored cyan, so apparently a default syntax definition is not ignored when it has stuff after its name. Okay, I was mistaken there. But I always get the warning "[ Unknown syntax name: nanohelp ]" when I do ^G. How come that sometimes you do get this warning, and sometimes not? If you remove just the "set quiet", does then the warning appear?

But even if I evade the warning (by modifying the code and setting syntaxstr to NULL in src/help.c), I still don't get colored trailing whitespace in the ^G help text. Or...

Oh, shait! I was using the Dutch locale! As soon as I started using LANGUAGE=en, I saw the four cyan blocks! It's the double spaces between sentences. In English, four sentences end at the end of a row. In Dutch, none of them do. Nor in any other language that I've tried: de, es, fr, hr, pl, sv. :|

Okay, now I can reproduce. I will have it fixed later this week. Thanks a lot for reporting. If you tell me your name, you'll get a Reported-by tag in the git repo.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 08 Oct 2017 03:23:42 PM UTC, comment #9:

my grep command looks funky although it worked on zsh and it also shows no output with ^# quoted. I've also attached /etc/nanorc

(file #42091)

Anonymous
Sun 08 Oct 2017 03:17:02 PM UTC, comment #8:

I must have a magick nano then i guess;

% grep -v ^# /etc/nanorc | grep -v '^$'
%

% cat ~/.nanorc
set fill 72
set nowrap
set speller ispell
set autoindent
#set morespace
#set nohelp

# newer options which might not be
# supported so set quiet also
set quiet
set justifytrim
#set titlecolor white,blue
#set statuscolor brightyellow
#set keycolor brightyellow
#set functioncolor yellow

syntax "default" ".*"
# Trailing whitespace.
color ,cyan "[[:space:]]+$"

(I've re-added the ".*" now)

There is no mention of bad syntax with set quiet and trailing whitespace is shown in cyan color, yes, also in the help text

I've attached a screenshot (i hope).

(file #42090)

Anonymous
Sat 07 Oct 2017 03:24:42 PM UTC, comment #7:

If your /etc/nanorc is effectively empty of commands, and the only syntax definition that your ~/.nanorc contains is ignored because it is invalid, how then can you see colored trailing whitespace anywhere? Let alone in the ^G help texts? If you change the color name in your ~/.nanorc from green to cyan, do the trailing spaces in the ^G help text adopt that color after a restart of nano? If yes, you have a miracle nano. :)

(No, the 'set quiet' does not suppress the "Unknown syntax name" message. If you did not see it before, maybe /etc/nanorc included all /usr/share/nano/*.nanorc files by default? And maybe someone modified those files to add the trailing-spaces line to all of them? Because that is the only way that I can imagine that you could see green trailing blocks in the ^G help texts.)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sat 07 Oct 2017 10:41:46 AM UTC, comment #6:

my /etc/nanorc is completely commented out, it's on the default arch linux install and i'm using the nano that is supplied with it, i didn't compile it from source

This is the output of nano --version:

% nano --version
GNU nano, version 2.8.7
(C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
(C) 2014-2017 the contributors to nano
Email: -unavailable- Web: https://nano-editor.org/
Compiled options: --disable-wrapping-as-root --enable-utf8

Ah, i do get an error message which i didn't notice before (probably also due to using set quiet?)

It says: "[ Unknown syntax name: nanohelp ]"

Anonymous
Wed 04 Oct 2017 07:21:32 PM UTC, comment #5:

What's in your /etc/nanorc? Did you compile nano yourself? How did you configure it? What's the output of 'nano --vesion'? When you type ^G, do you get any error message?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 01 Oct 2017 11:55:06 AM UTC, comment #4:

i've read the other bugreport and i see this is how pico does it and nano should be compatible. I understand that. It also mentions double spaces but what i mean and get after enabling word wrap is just a single trailing space. There's no undo for wordwrapping like there is with justify anyway i believe so i'm not sure how much harm would be done.

Thanks again

Anonymous
Sun 01 Oct 2017 11:46:57 AM UTC, comment #3:

Yes, i have justifytrim enabled, this is my .nanorc:

set fill 72
set nowrap
set speller ispell
set autoindent
#set morespace
#set nohelp

# newer options which might not be
# supported so set quiet also
set quiet
set justifytrim
#set titlecolor white,blue
#set statuscolor brightyellow
#set keycolor brightyellow
#set functioncolor yellow

syntax "default" ".*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

-- end --

You are right regarding the error for the syntax command, i didn't see it because i also set quiet. It is however enabled and the help screen (with ^G) does show some trailing whitespace with it.

I use nowrap as the 'default' setting but also set fill for when i turn it on.

Personally i think trimming trailing whitespace when hardwrapping is on (and only then) would be nice so i don't have to run a replace or justify everytime i send an email for instance.

When i use it for coding i disable hardwrap.

I'm not sure what people would expect for this but i think it's like at least some other editors do it.

Thank you for looking into this 'issue' :)

Anonymous
Sun 01 Oct 2017 10:15:55 AM UTC, comment #2:

> When you justify, all this whitespace is deleted


This means you are using 'set justifytrim', right?

> syntax "default" ".*"


This should produce an error message:
The "default" syntax does not accept extensions

So your three-line example should have zero effect, because nano will ignore both the syntax command and the subsequent color command.

> they turn up in unexpected places like for instance the help text.


You mean in the help text shown by ^G? That help text should never be governed by the default syntax. It is governed by the nanohelp syntax, and if that one doesn't exist, it should be governed by no syntax at all (the "none" syntax).

So... if you see trailing whitespace highlighted in the ^G help texts, please attach your entire .nanorc and /etc/nanorc.

About the wish to have nano strip any trailing spaces on-the-fly while doing hard line wrapping... Most people have hard-wrapping switched off, because it's a nuisance when editing code or config files, so few people experience this problem. Also see bug #46361 (comment #1) for two reasons why trimming this whitespace hasn't been done.

But... I guess we could generalize the option 'justifytrim' to 'trimtrailing', to also trim trailing whitespace on-the-fly -- but only when hard-wrapping kicks in, not when the user manually breaks a line (for example, <Space> <Space> <Enter> would leave the two spaces alone). Would that be what you want?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 01 Oct 2017 09:41:36 AM UTC, comment #1:

hmm i think this is intentional as the comment in text.c says

"We are going to add a new line
* after a blank character.
..."

Maybe this is because you don't want to change user input? But why would one use wordwrap anyway in that case i wonder. Wouldn't it be more intuitive to replace that blank with \n?

Anonymous
Sat 30 Sep 2017 08:43:37 PM UTC, original submission:

When using nano 2.8.7 with word wrap enabled nano leaves whitespace after every line. When you justify all this whitespace is deleted but it would be nice if that wasn't needed.
When you use

syntax "default" ".*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

in ~/.nanorc you can see where it leaves them and they turn up in unexpected places like for instance the help text.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #42091:  nanorc added by None (9KiB - application/octet-stream)
file #42090:  whitespace.png added by None (944KiB - image/png - a picture of ^G)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 19 Nov 2017 08:16:09 AM UTCbensOpen/ClosedOpen=>Closed
    Thu 12 Oct 2017 05:19:58 PM UTCbensStatusIn Progress=>Fixed
    Sun 08 Oct 2017 07:30:55 PM UTCbensSeverity3 - Normal=>2 - Minor
      StatusNone=>In Progress
      Assigned toNone=>bens
      Summary[Request] remove trailing whitespace on-the-fly=>trailing whitespace is getting colored also in the help texts
    Sun 08 Oct 2017 03:23:42 PM UTCNoneAttached File-=>Added nanorc, #42091
    Sun 08 Oct 2017 03:17:02 PM UTCNoneAttached File-=>Added whitespace.png, #42090
    Sun 01 Oct 2017 10:15:55 AM UTCbensSummarytrailing whitespace=>[Request] remove trailing whitespace on-the-fly

    Back to the top


    Powered by Savane 3.1-cleanup1