From fe6c1c2603aaab818c4d1586929f9a760502230b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Thu, 14 Sep 2017 20:02:24 -0300 Subject: [PATCH] Enable persistence for executed commands. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Diego Aurélio Mesquita --- src/files.c | 13 ++++++++++--- src/global.c | 3 +++ src/proto.h | 2 ++ src/search.c | 4 ---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/files.c b/src/files.c index aa2ceab..2360767 100644 --- a/src/files.c +++ b/src/files.c @@ -1145,6 +1145,7 @@ void do_insertfile(void) /* Save the command's output in the current buffer. */ execute_command(answer); update_history(&execute_history, answer); + history_changed = TRUE; #ifdef ENABLE_MULTIBUFFER /* If this is a new buffer, put the cursor at the top. */ @@ -2828,8 +2829,11 @@ void load_history(void) /* Encode any embedded NUL as 0x0A. */ unsunder(line, read); update_history(history, line); - } else + } else if (history == &search_history) history = &replace_history; + else + history = &execute_history; + } fclose(hist); @@ -2871,7 +2875,8 @@ void save_history(void) /* If the histories are unchanged or empty, don't bother saving them. */ if (!history_has_changed() || (searchbot->lineno == 1 && - replacebot->lineno == 1)) + replacebot->lineno == 1 && + executebot->lineno == 1)) return; searchhist = histfilename(); @@ -2888,7 +2893,9 @@ void save_history(void) /* Don't allow others to read or write the history file. */ chmod(searchhist, S_IRUSR | S_IWUSR); - if (!writehist(hist, searchage) || !writehist(hist, replaceage)) + if (!writehist(hist, searchage) || + !writehist(hist, replaceage)|| + !writehist(hist, executetop)) fprintf(stderr, _("Error writing %s: %s\n"), searchhist, strerror(errno)); diff --git a/src/global.c b/src/global.c index f58be84..822fe41 100644 --- a/src/global.c +++ b/src/global.c @@ -224,6 +224,9 @@ filestruct *executebot = NULL; /* The bottom of the execute history list. */ poshiststruct *position_history = NULL; /* The cursor position history list. */ +bool history_changed = FALSE; + /* Have any of the history lists changed? */ + #endif regex_t search_regexp; diff --git a/src/proto.h b/src/proto.h index b7a279c..f986bc2 100644 --- a/src/proto.h +++ b/src/proto.h @@ -169,6 +169,8 @@ extern filestruct *execute_history; extern filestruct *executetop; extern filestruct *executebot; extern poshiststruct *position_history; +extern bool history_changed; + #endif extern regex_t search_regexp; diff --git a/src/search.c b/src/search.c index b04e9a3..3fa1c56 100644 --- a/src/search.c +++ b/src/search.c @@ -28,10 +28,6 @@ static bool came_full_circle = FALSE; /* Have we reached the starting line again while searching? */ -#ifndef DISABLE_HISTORIES -static bool history_changed = FALSE; - /* Have any of the history lists changed? */ -#endif static bool regexp_compiled = FALSE; /* Have we compiled any regular expressions? */ -- 2.7.4