[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] history: remember the commands that were executed d
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] history: remember the commands that were executed during this session |
Date: |
Wed, 13 Sep 2017 20:44:05 +0200 |
From: Marco Diego Aurélio Mesquita <address@hidden>
Signed-off-by: Marco Diego Aurélio Mesquita <address@hidden>
---
src/files.c | 3 ++-
src/global.c | 18 ++++++++++++------
src/proto.h | 3 +++
src/search.c | 13 +++++++++++++
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/files.c b/src/files.c
index df3bb3e3..aa2ceab2 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1081,7 +1081,7 @@ void do_insertfile(void)
#endif
MINSERTFILE, given,
#ifndef DISABLE_HISTORIES
- NULL,
+ execute ? &execute_history : NULL,
#endif
edit_refresh, msg,
#ifndef DISABLE_OPERATINGDIR
@@ -1144,6 +1144,7 @@ void do_insertfile(void)
#endif
/* Save the command's output in the current buffer. */
execute_command(answer);
+ update_history(&execute_history, answer);
#ifdef ENABLE_MULTIBUFFER
/* If this is a new buffer, put the cursor at the top. */
diff --git a/src/global.c b/src/global.c
index 7a56664b..f58be846 100644
--- a/src/global.c
+++ b/src/global.c
@@ -216,6 +216,12 @@ filestruct *replaceage = NULL;
/* The top of the replace string history list. */
filestruct *replacebot = NULL;
/* The bottom of the replace string history list. */
+filestruct *execute_history = NULL;
+ /* The list of commands that have been run with ^R ^X. */
+filestruct *executetop = NULL;
+ /* The top of the execute history list. */
+filestruct *executebot = NULL;
+ /* The bottom of the execute history list. */
poshiststruct *position_history = NULL;
/* The cursor position history list. */
#endif
@@ -1266,17 +1272,17 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"^P", 0, get_history_older_void, 0);
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"^N", 0, get_history_newer_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"^P", 0, get_history_older_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
{
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"Up", KEY_UP, get_history_older_void, 0);
- add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP,
"Down", KEY_DOWN, get_history_newer_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"Up", KEY_UP, get_history_older_void, 0);
+
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD,
"Down", KEY_DOWN, get_history_newer_void, 0);
}
#endif
#ifdef ENABLE_BROWSER
diff --git a/src/proto.h b/src/proto.h
index a9f826b3..b7a279c4 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -165,6 +165,9 @@ extern filestruct *searchbot;
extern filestruct *replace_history;
extern filestruct *replaceage;
extern filestruct *replacebot;
+extern filestruct *execute_history;
+extern filestruct *executetop;
+extern filestruct *executebot;
extern poshiststruct *position_history;
#endif
diff --git a/src/search.c b/src/search.c
index 92d90223..b04e9a37 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1107,6 +1107,11 @@ void history_init(void)
replace_history->data = mallocstrcpy(NULL, "");
replaceage = replace_history;
replacebot = replace_history;
+
+ execute_history = make_new_node(NULL);
+ execute_history->data = mallocstrcpy(NULL, "");
+ executetop = execute_history;
+ executebot = execute_history;
}
/* Set the current position in the history list h to the bottom. */
@@ -1116,6 +1121,8 @@ void history_reset(const filestruct *h)
search_history = searchbot;
else if (h == replace_history)
replace_history = replacebot;
+ else if (h == execute_history)
+ execute_history = executebot;
}
/* Return the first node containing the first len characters of the
@@ -1148,6 +1155,9 @@ void update_history(filestruct **h, const char *s)
} else if (*h == replace_history) {
hage = &replaceage;
hbot = &replacebot;
+ } else if (*h == execute_history) {
+ hage = &executetop;
+ hbot = &executebot;
}
assert(hage != NULL && hbot != NULL);
@@ -1248,6 +1258,9 @@ char *get_history_completion(filestruct **h, char *s,
size_t len)
} else if (*h == replace_history) {
hage = replaceage;
hbot = replacebot;
+ } else if (*h == execute_history) {
+ hage = executetop;
+ hbot = executebot;
}
assert(hage != NULL && hbot != NULL);
--
2.14.1
- [Nano-devel] [PATCH] history: remember the commands that were executed during this session,
Benno Schulenberg <=