diff --git a/ChangeLog b/ChangeLog index 6320d6c71365eca31d224fbc1000c4d0476d6754..0f134a318a268c66809cabe9d8c369359f4d4dc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,9 +53,10 @@ CVS code - regex strings constantly, and to actually compile them on an as-needed basis. Also, make a color syntax specified on the command line override the syntax associated with the current - file extension, and add a "default" syntax that takes no + file extension, add a "default" syntax that takes no extensions for those files that don't match any other - syntax's extensions. Changes to update_color(), + syntax's extensions, and add a "none" syntax that's the same + as having no syntax at all. Changes to update_color(), thanks_for_all_the_fish(), nregcomp(), parse_syntax(), and parse_colors(). (Brand Huntsman and DLR) - Various other color fixes. Handle unspecified foreground diff --git a/doc/nanorc.sample b/doc/nanorc.sample index 4226275bed1128c1094b6d5a01101b8e256e382f..61396b3171c5d0003a95dbe952f804c69979fc63 100644 --- a/doc/nanorc.sample +++ b/doc/nanorc.sample @@ -147,9 +147,10 @@ ## ## syntax "short description" ["filename regex" ...] ## -## (The syntax "default" is reserved: it takes no filename regexes, and -## applies to files that don't match any other syntax's filename -## regexes.) +## (The "none" syntax is reserved; specifying it on the command line is +## the same as not having a syntax at all. The "default" syntax is +## special: it takes no filename regexes, and applies to files that +## don't match any other syntax's filename regexes.) ## ## color foreground,background "regex" ["regex"...] ## or diff --git a/src/color.c b/src/color.c index 24482f80c4ce592d0ac771348142df670b1f6264..1ef7b6eacdccfdf5eb0ceb5a5ba51a849409ffa4 100644 --- a/src/color.c +++ b/src/color.c @@ -117,6 +117,11 @@ void color_update(void) /* If we specified a syntax override string, use it. */ if (syntaxstr != NULL) { + /* If the syntax override is "none", it's the same as not having + * a syntax at all, so get out. */ + if (strcmp(syntaxstr, "none") == 0) + return; + for (tmpsyntax = syntaxes; tmpsyntax != NULL; tmpsyntax = tmpsyntax->next) { if (strcmp(tmpsyntax->desc, syntaxstr) == 0) diff --git a/src/rcfile.c b/src/rcfile.c index c628efca5ca1288f20bba3644ecc1be0e34afb1b..9747ceef2df2307b7deec1456942310db9ecf2fe 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -322,9 +322,17 @@ void parse_syntax(char *ptr) fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr); #endif + /* The "none" syntax is the same as not having a syntax at all, so + * we can't assign any extensions or colors to it. */ + if (strcmp(endsyntax->desc, "none") == 0) { + rcfile_error(N_("The \"none\" syntax is reserved")); + return; + } + /* The default syntax should have no associated extensions. */ if (strcmp(endsyntax->desc, "default") == 0 && *ptr != '\0') { - rcfile_error(N_("The default syntax must take no extensions")); + rcfile_error( + N_("The \"default\" syntax must take no extensions")); return; }