From: David Lawrence Ramsey Date: Mon, 1 Aug 2005 04:59:34 +0000 (+0000) Subject: port over Brand Huntsman's reserved "none" syntax to counteract his X-Git-Tag: v1.3.9~85 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d152ad378b878e9830e359714989684ad68af2d1;p=nano.git port over Brand Huntsman's reserved "none" syntax to counteract his "default" syntax when necessary (the latter *is* actually ported mostly from his patch with a few tweaks; the "default-syntax" option is apparently something else entirely) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2961 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 6320d6c7..0f134a31 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 4226275b..61396b31 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 24482f80..1ef7b6ea 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 c628efca..9747ceef 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; }