From f5b681e3279d0d3687f0cdd51f4bd0cb775f9f45 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Tamotsu Date: Thu, 27 Jan 2005 19:00:59 +0000 Subject: [PATCH] Add terminal newline when it lacks after editing a message. Originally from TAKIZAWA Takashi. --- curs_lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/curs_lib.c b/curs_lib.c index d546182ec..15e4543fd 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -154,6 +154,19 @@ void mutt_clear_error (void) CLEARLINE (LINES-1); } +static void fix_end_of_file (const char *data) +{ + FILE *fp; + int c; + + if ((fp = safe_fopen (data, "a+")) == NULL) + return; + fseek (fp,-1,SEEK_END); + if ((c = fgetc(fp)) != '\n') + fputc ('\n', fp); + safe_fclose (&fp); +} + void mutt_edit_file (const char *editor, const char *data) { char cmd[LONG_STRING]; @@ -162,6 +175,7 @@ void mutt_edit_file (const char *editor, const char *data) mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data); if (mutt_system (cmd) == -1) mutt_error (_("Error running \"%s\"!"), cmd); + fix_end_of_file (data); keypad (stdscr, TRUE); clearok (stdscr, TRUE); } -- 2.40.0