From 14637812471cb6caebb845c233b0a2035796f854 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 28 Oct 2017 14:18:37 +0200 Subject: [PATCH] startup: when an rcfile contains errors, report this on the status bar Suggested-by: Brand Huntsman --- src/global.c | 2 ++ src/nano.c | 3 +++ src/proto.h | 1 + src/rcfile.c | 3 +++ 4 files changed, 9 insertions(+) diff --git a/src/global.c b/src/global.c index d20d9e45..32096605 100644 --- a/src/global.c +++ b/src/global.c @@ -242,6 +242,8 @@ int interface_color_pair[] = {0}; char *homedir = NULL; /* The user's home directory, from $HOME or /etc/passwd. */ +char *rcfile_with_errors = NULL; + /* The first nanorc file, if any, that produced warnings. */ /* Return the number of entries in the shortcut list for a given menu. */ diff --git a/src/nano.c b/src/nano.c index 3db1ee63..8ef381e8 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2594,6 +2594,9 @@ int main(int argc, char **argv) prepare_for_display(); + if (rcfile_with_errors != NULL) + statusline(ALERT, _("Mistakes in '%s'"), rcfile_with_errors); + while (TRUE) { #ifdef ENABLE_LINENUMBERS int needed_margin = digits(openfile->filebot->lineno) + 1; diff --git a/src/proto.h b/src/proto.h index 9c3c6383..559f1521 100644 --- a/src/proto.h +++ b/src/proto.h @@ -181,6 +181,7 @@ extern char* specified_color_combo[NUMBER_OF_ELEMENTS]; extern int interface_color_pair[NUMBER_OF_ELEMENTS]; extern char *homedir; +extern char *rcfile_with_errors; typedef void (*functionptrtype)(void); diff --git a/src/rcfile.c b/src/rcfile.c index 8fa2f737..a2d8f834 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -141,6 +141,9 @@ void rcfile_error(const char *msg, ...) { va_list ap; + if (rcfile_with_errors == NULL) + rcfile_with_errors = strdup(nanorc); + if (lineno > 0) fprintf(stderr, _("Error in %s on line %lu: "), nanorc, (unsigned long)lineno);