nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] the way of matching a syntax (to use for coloring)


From: Benno Schulenberg
Subject: [Nano-devel] the way of matching a syntax (to use for coloring)
Date: Fri, 26 Feb 2016 19:04:02 +0100

Hi,

Currently, when nano goes about determining which syntax to
use for coloring the contents of a file, there a five steps.
(A given syntax name, the name of the file, the contents of
the first line, a magic match, and as last resort a default.)

The "problem" is: four of those steps take the matching syntax
that was defined last, the other one takes the matching one
that was defined first.

The one that takes the first match is the libmagic match, and
this has been so from the beginning, five years ago.  I think
it is wrong, because it prevents the user from defining in her
.nanorc a syntax with a magicstring that overrides that match.

* So I intend to change the libmagic matching behavior to mimic
the behavior of the other four steps.

(At a later stage I intend to turn the list of syntaxes around,
last one first, so that it becomes a little quicker to find the
last-defined one, and easier to add items.)

Also, currently, when an empty syntax is selected (a syntax
that was not followed by any color commands), nano acts as
if nothing was specified and uses the default syntax instead.
I think this is wrong: when the user specified something, she
should get what she asked for: in this case an empty, and
therefore colorless syntax.

I've become aware that nano behaves this way because on help-nano
someone asked how to switch off all syntax coloring.  When you're
on the univeristy's computer, you don't have access to /etc/nanorc
so you can't disable any includes there.  Of course it's possible
to make an alias (alias nano="nano --syntax=none"), but there is
no elegant way to do this in the user's .nanorc.  Specifying

    syntax "all" ".*"

on the last line is not enough, because then you will get the
default syntax coloring.  You have to add some color command:

    color green "^$"

That should not be necessary.  (Of course you will get a warning
that there is a syntax without color commands, but maybe we can
suppress that one when at the end of file.)

* So I intend to let nano choose the default syntax only when
absolutely nothing matched.  If anything matched, even if it's
empty, then that is taken.

Comments?

Benno

-- 
http://www.fastmail.com - Accessible with your email software
                          or over the web




reply via email to

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