2014-03-01 Chris Allegretta <chrisa@asty.org>

* 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
This commit is contained in:
Chris Allegretta 2014-03-02 05:27:56 +00:00
parent bc5c7c3b74
commit e52eac51f5
5 changed files with 65 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2014-03-01 Chris Allegretta <chrisa@asty.org>
* 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 <vapier@gentoo.org>
* src/color.c (color_update) - Do not write to stderr on magic
errors. If the magic db has errors such that magic_load() fails,

View File

@ -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:

View File

@ -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

View File

@ -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. */

View File

@ -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;