constantly flashing bright green while typing

Bug #1361131 reported by tommy
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nano (Ubuntu)
New
Undecided
Unassigned

Bug Description

While editing a shell script (.sh file) nano colours trailing spaces bright green.

It also considers spaces that have just been typed to be trailing spaces.

This results in constant flashing bright green while typing, which is both distracting and annoying.

It's at its most ridiculous when typing comments (for which trailing whitespace is obviously completely irrelevant), but is also irritating any time you happen to look at what you're typing. Which for me is, as it happens, all the time.

Ideal solution: only display trailing whitespace if the user is not, you know, still typing on that line, with the cursor right there.

Easy solution: just shut up about the damn spaces already.

Revision history for this message
Benno Schulenberg (bennoschulenberg) wrote :

If the trailing-whitespace highlighting annoys you, you can edit /usr/share/nano/sh.nanorc and remove or comment out the line that says: color ,green "[[:space:]]+$". Problem solved. (You will then probably want to do the same for the other *.nanorc files there.)

Revision history for this message
tommy (mesilliac) wrote : Re: [Bug 1361131] Re: constantly flashing bright green while typing

Why would this flashing behaviour ever be a desirable default?

On 26/03/15 01:12, Benno Schulenberg wrote:
> If the trailing-whitespace highlighting annoys you, you can edit
> /usr/share/nano/sh.nanorc and remove or comment out the line that says:
> color ,green "[[:space:]]+$". Problem solved. (You will then probably
> want to do the same for the other *.nanorc files there.)
>

Revision history for this message
Benno Schulenberg (bennoschulenberg) wrote :

Code is inspected far more often than it is written, and when inspecting code, some people do want to be alerted to trailing whitespace. So that's why it is in several of the *.nanorc files. However, those files in /usr/share/nano are just examples -- they are meant to be customized by the user. Most distributions, however, include and activate them by default.

By the way, it is not necessary to edit the files in /usr/share/nano; you can instead redefine any syntax in your ~/.nanorc: just put in 'syntax "sh" "\.sh$"' and follow it by the color commands that you do want.

(In newer nanos (2.4.0 and higher) there is no need to completely redefine a syntax; you can just add or override things with 'extendsyntax'. In your case you would put 'extendsyntax sh color black, "[[:space:]]+$"' to get rid of the trailing-whitespace colouring.)

If, when reading code, you do want trailing whitespace to be highlighted, you can just toggle syntax colouring off with Alt+Y while you are typing the code, and toggle it back on when you are done writing.

Okay, all that is selfhelp. But if you think that for most people the colouring of trailing whitespace should never be the default, you could report a bug to nano itself (https://savannah.gnu.org/bugs/?group=nano) or send an email to its development list (https://lists.gnu.org/mailman/listinfo/nano-devel).

Revision history for this message
tommy (mesilliac) wrote :

I'm not against the highlighting of trailing whitespace, most of the time i do actually want to be notified of it. The problem is that the syntax highlighting code considers all spaces to be "trailing whitespace" while the user is typing them. It's like a bell going off every time you press the spacebar.

I have no idea if it's possible to specify "don't complain about trailing whitespace when the cursor is at the end of the line", but if it is that seems like it would be the best solution. That way it wouldn't complain about spaces while typing, but after going on to the next line if there were still trailing spaces it would correctly complain.

Revision history for this message
Benno Schulenberg (bennoschulenberg) wrote :

Nano colours the things on the screen using just the regular expressions specified in the relevant syntax file. There is no way that these regexes can take the position of the cursor into account. (Well, not without a major and ugly patch, and that for just one special case.) So... unless you are willing to write the patch...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.