nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit ede64d7ea0520a1a0a413023ea6613660fd3526b
parent e8db390d6fd1250dc5a4158f65035a2d1ce6af31
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sat, 13 Mar 2021 12:08:47 +0100

feedback: upon first switch to a buffer, show its error message (if any)

When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>

Diffstat:
Msrc/definitions.h | 2++
Msrc/files.c | 8++++++++
Msrc/winio.c | 6++++++
3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h @@ -567,6 +567,8 @@ typedef struct openfilestruct { /* The syntax that applies to this file, if any. */ #endif #ifdef ENABLE_MULTIBUFFER + char *errormessage; + /* The ALERT message (if any) that occurred when opening the file. */ struct openfilestruct *next; /* The next open file, if any. */ struct openfilestruct *prev; diff --git a/src/files.c b/src/files.c @@ -92,6 +92,8 @@ void make_new_buffer(void) openfile->statinfo = NULL; openfile->lock_filename = NULL; + + openfile->errormessage = NULL; #endif #ifdef ENABLE_COLOR openfile->syntax = NULL; @@ -558,6 +560,11 @@ void redecorate_after_switch(void) /* Prevent a possible Shift selection from getting cancelled. */ shift_held = TRUE; + if (openfile->errormessage) { + statusline(ALERT, openfile->errormessage); + free(openfile->errormessage); + openfile->errormessage = NULL; + } else /* Indicate on the status bar where we switched to. */ mention_name_and_linecount(); } @@ -595,6 +602,7 @@ void close_buffer(void) /* Free the undo stack. */ discard_until(NULL); #endif + free(orphan->errormessage); openfile = orphan->prev; free(orphan); diff --git a/src/winio.c b/src/winio.c @@ -2229,6 +2229,12 @@ void statusline(message_type importance, const char *msg, ...) vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap); va_end(ap); +#ifdef ENABLE_MULTIBUFFER + if (!we_are_running && importance == ALERT && + !openfile->errormessage && openfile->next != openfile) + openfile->errormessage = copy_of(compound); +#endif + /* If there are multiple alert messages, add trailing dots to the first. */ if (lastmessage == ALERT) { if (start_col > 4) {