bugGNU nano - Bugs: bug #66020, [Wish] a way to switch off syntax...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #66020: [Wish] a way to switch off syntax highlighting via nanorc

Submitter:  Michael Siegel <msi>
Submitted:  Wed 24 Jul 2024 05:58:39 PM UTC
   
 
Severity:  1 - Wish Status:  Wontfix
Assigned to:  None Open/Closed:  Closed

Fri 09 Aug 2024 09:47:30 AM UTC, comment #5: 

Nano itself does not install /etc/nanorc -- all it contains is a doc/sample.nanorc with all settings commented out.  It are some of the distros that install this file to /etc/nanorc and uncomment some of the lines.

Having an option to turn syntax highlighting on or off while no syntaxes have actually been loaded would be confusing: the user sets it to "on", but nothing has changed when restarting nano.

(If you have suggestions for improvements to the docs, please post them to the nano-devel list.)

Benno Schulenberg <bens>
Group administrator
Thu 08 Aug 2024 04:16:25 PM UTC, comment #4: 


> Setting or unsetting options in a per-user nanorc file overrides (of
> course) any options set in /etc/nanorc, but once a file is included, the
> syntax that this file defines cannot be undefined -- it can only be
> redefined, for example with 'color normal ".*"' to effectively colorize
> nothing.  But having to do that for each syntax that /etc/nanorc included is
> cumbersome.


I see.

> (In my opinion, the fact that nano reads an /etc/nanorc was a
> mistake -- the best advice I can give users is to simply delete it, so
> that all your settings for nano are made in one place.)


A system-wide configuration file is nice to have, though.

It seems to me that a better approach would be not to include the "include"
command in the configuration file and instead limit that file's scope to
flipping the syntax highlighting switch on or off and containing the paths
to any syntax files that are to be used.

Then Nano could first read the hierarchy of configuration files, and then
include syntax highlighting defintions as configured – or not do that if
syntax highlighting has ultimately been switched off.

> If the descriptions under OPTIONS in `man nanorc` and under FILES in `man
> nano` could be improved, please post suggestions.


There are a few little rough edges in these manual pages (I've started a
list.) but, as far as I can see, none of them should cause any damage.

Michael Siegel <msi>
Sat 27 Jul 2024 09:26:29 AM UTC, comment #3: 

Setting or unsetting options in a per-user nanorc file overrides (of course) any options set in /etc/nanorc, but once a file is included, the syntax that this file defines cannot be undefined -- it can only be redefined, for example with 'color normal ".*"' to effectively colorize nothing.  But having to do that for each syntax that /etc/nanorc included is cumbersome.

(In my opinion, the fact that nano reads an /etc/nanorc was a mistake -- the best advice I can give users is to simply delete it, so that all your settings for nano are made in one place.)

If the descriptions under OPTIONS in `man nanorc` and under FILES in `man nano` could be improved, please post suggestions.

Benno Schulenberg <bens>
Group administrator
Fri 26 Jul 2024 10:05:47 PM UTC, comment #2: 


> Nano does not do syntax highlighting by default.  So... the way to avoid having syntax highlighting is to not use any 'include' staments in your nanorc files.
>
> Some distros (Debian and its derivatives, and maybe others) have an 'include /usr/share/nano/*.nanorc' in their /etc/nanorc.  The best way to defeat that is to simply delete /etc/nanorc.


I see. Thanks for clearing this up.

I'm running the distribution package for Nano 7.2 on Devuan here. Commenting all 'include' statements in /etc/nanorc did it for me. Doing the same in the user-specific nanorc file (~/.config/nano/nanorc or ~/.nanorc) while not touching /etc/nanorc (i.e., not commenting the generic 'include' statement you mentioned above) did, however, not switch off syntax highlighting.

So, apparently, the per-user configuration does not take precedence over the system-wide one (at least in this specific case). I assumed it would. It does work the other way around, though, i.e., switching highlighting off system-wide, and switching it on for the user.

> I don't understand the bit about running nano from scripts.  Why is having to use `-Y none` more of a nuisance there than on the command line?
>
> If deleting /etc/nanorc is not an option, maybe aliasing nano to '/bin/nano -Ynone' is?


Right. I currently have 'nano' aliased to a Nano invocation containing all the command-line options that configure it to my liking. So, I never actually have to type '-Y none' on the command line.

The problem with this concerning shell scripts is that shell scripts are, by default, unaware of a user's command aliases. I. e., if the only reliable way to switch off syntax highlighting was using a command-line option, you'd end up having to hard-code the respective alias into your scripts. This would then break the configuration for users who do want syntax highlighting.

Running the editor from within a pager breaks configuration via shell command aliases as well.

Michael Siegel <msi>
Thu 25 Jul 2024 02:34:18 PM UTC, comment #1: 

Nano does not do syntax highlighting by default.  So... the way to avoid having syntax highlighting is to not use any 'include' staments in your nanorc files.

Some distros (Debian and its derivatives, and maybe others) have an 'include /usr/share/nano/*.nanorc' in their /etc/nanorc.  The best way to defeat that is to simply delete /etc/nanorc.

I don't understand the bit about running nano from scripts.  Why is having to use `-Y none` more of a nuisance there than on the command line?

If deleting /etc/nanorc is not an option, maybe aliasing nano to '/bin/nano -Ynone' is?

Benno Schulenberg <bens>
Group administrator
Wed 24 Jul 2024 05:58:39 PM UTC, original submission:  

Please provide a way to switch off all syntax highlighting in Nano explicitly via its configuration file. Having to rely on `-Y none` for this is quite a nuisance, especially when running the editor from scripts.

Michael Siegel <msi>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by msi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-08-18 bens Open/ClosedOpen Closed
    2024-08-09 bens StatusNone Wontfix
    2024-07-25 bens Severity3 - Normal 1 - Wish
        SummaryProvide a way to switch off syntax highlighting via nanorc [Wish] a way to switch off syntax highlighting via nanorc

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code