From: Chris Allegretta Date: Sun, 2 Mar 2014 05:27:56 +0000 (+0000) Subject: 2014-03-01 Chris Allegretta X-Git-Tag: v2.3.3~300 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=e52eac51f565c7c934b09ba4a3fa489566d2a230;p=nano.git 2014-03-01 Chris Allegretta * global.c (shortcut_init) - fix an issue with the split do_research() setup when using --enable-tiny * rcfile.c (parse_linter) - Allow linter to be unset using "" * rcfile.c - Allow syntaxes to be extended via "extendsyntax" directive. Color, header, magic and linter should all be able to be extended. Man page updates for nanorc(5). * doc/nanorc.sample.in - Document 'set quiet' git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4630 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 45739ad1..b6e56f2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-03-01 Chris Allegretta + * global.c (shortcut_init) - fix an issue with the split + do_research() setup when using --enable-tiny + * rcfile.c (parse_linter) - Allow linter to be unset using "" + * rcfile.c - Allow syntaxes to be extended via "extendsyntax" + directive. Color, header, magic and linter should all be + able to be extended. Man page updates for nanorc(5). + * doc/nanorc.sample.in - Document 'set quiet' + 2014-03-01 Mike Frysinger * src/color.c (color_update) - Do not write to stderr on magic errors. If the magic db has errors such that magic_load() fails, diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5 index 3ea5e84a..f499ff6a 100644 --- a/doc/man/nanorc.5 +++ b/doc/man/nanorc.5 @@ -287,6 +287,13 @@ Same as above, except that the expression matching is case insensitive. Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that \fIsyntaxfile\fP can only contain \fBsyntax\fP, \fBcolor\fP, and \fBicolor\fP commands. +.TP +.B extendsyntax \fIstr\fP \fIdirective\fP [ \fIarg\fP ... ] +Extend the syntax previously defined as \fIstr\fP to include +new information. Allows you to add a new \fIcolor\fP, \fIicolor\fP, +\fImagic\fP, \fIheader\fP, or \fIlinter\fP directive to a syntax +defined. Useful when you want to add to definitions from the +system-installed syntax definitions (which are normally not writable). .SH KEY BINDINGS Key bindings may be reassigned via the following commands: diff --git a/doc/nanorc.sample.in b/doc/nanorc.sample.in index 34d6eacd..f7f3097d 100644 --- a/doc/nanorc.sample.in +++ b/doc/nanorc.sample.in @@ -15,6 +15,11 @@ ## its end. For example, for the "brackets" option, ""')>]}" will match ## ", ', ), >, ], and }. +## Silently ignore problems with unknown directives in the nanorc file. +## Useful when your nanorc file might be read on systems with multiple +## versions of nano installed (e.g. your home directory is on NFS) +# set quiet + ## Use auto-indentation. # set autoindent diff --git a/src/global.c b/src/global.c index a21adc78..47efcda1 100644 --- a/src/global.c +++ b/src/global.c @@ -789,8 +789,10 @@ void shortcut_init(bool unjustify) add_to_funcs(do_search, MMAIN|MBROWSER, whereis_msg, IFSCHELP(nano_whereis_msg), FALSE, VIEW); +#ifndef NANO_TINY add_to_funcs(do_research, MBROWSER, whereis_next_msg, IFSCHELP(nano_whereis_next_msg), TRUE, VIEW); +#endif /* NANO_TINY */ #ifndef DISABLE_JUSTIFY /* TRANSLATORS: Try to keep this at most 10 characters. */ diff --git a/src/rcfile.c b/src/rcfile.c index ce6d0665..ddd05f1b 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -834,6 +834,9 @@ void parse_colors(char *ptr, bool icase) #ifdef DEBUG fprintf(stderr, "Adding new entry for fg %hd, bg %hd\n", fg, bg); #endif + /* Need to recompute endcolor now so we can extend colors to syntaxes */ + for (endcolor = endsyntax->color; endcolor->next != NULL; endcolor = endcolor->next) + ; endcolor->next = newcolor; } @@ -962,7 +965,11 @@ void parse_linter(char *ptr) if (endsyntax->linter != NULL) free(endsyntax->linter); - endsyntax->linter = mallocstrcpy(syntaxes->linter, ptr); + /* Let them unset the linter by using "" */ + if (!strcmp(ptr, "\"\"")) + endsyntax->linter = NULL; + else + endsyntax->linter = mallocstrcpy(syntaxes->linter, ptr); } #endif /* ENABLE_COLOR */ @@ -1007,6 +1014,9 @@ void parse_rcfile(FILE *rcstream char *buf = NULL; ssize_t len; size_t n = 0; +#ifdef ENABLE_COLOR + syntaxtype *end_syn_save = NULL; +#endif while ((len = getline(&buf, &n, rcstream)) > 0) { char *ptr, *keyword, *option; @@ -1031,6 +1041,28 @@ void parse_rcfile(FILE *rcstream keyword = ptr; ptr = parse_next_word(ptr); + + /* Handle extending first... */ + if (strcasecmp(keyword, "extendsyntax") == 0) { + char *syntaxname = ptr; + syntaxtype *ts = NULL; + + ptr = parse_next_word(ptr); + for (ts = syntaxes; ts != NULL; ts = ts->next) + if (!strcmp(ts->desc, syntaxname)) + break; + + if (ts == NULL) { + rcfile_error(N_("Could not find syntax \"%s\" to extend"), syntaxname); + continue; + } else { + end_syn_save = endsyntax; + endsyntax = ts; + keyword = ptr; + ptr = parse_next_word(ptr); + } + } + /* Try to parse the keyword. */ if (strcasecmp(keyword, "set") == 0) { #ifdef ENABLE_COLOR @@ -1084,6 +1116,15 @@ void parse_rcfile(FILE *rcstream else rcfile_error(N_("Command \"%s\" not understood"), keyword); +#ifdef ENABLE_COLOR + /* If we temporarily reset emdsyntax to allow extending, reset + the value here */ + if (end_syn_save != NULL) { + endsyntax = end_syn_save; + end_syn_save = NULL; + } +#endif + if (set == 0) continue;