[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] bindings: make ^T invoke the Execute-Command prompt, and ^T^
From: |
Benno Schulenberg |
Subject: |
[PATCH 2/2] bindings: make ^T invoke the Execute-Command prompt, and ^T^T the Speller |
Date: |
Fri, 22 May 2020 14:45:24 +0200 |
Make the Execute-Command menu accessible also with a single keystroke
(^T), not just with a double one (^R^X). This is useful, because no one
will suspect that "Execute Command" can be found behind "Read File".
To not disturb muscle memory too much for people who are used to ^T
invoking the Spell Checker, a second ^T will invoke it.
---
src/files.c | 14 +++++++++++---
src/global.c | 27 +++++++++++++++++----------
src/proto.h | 3 +++
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/files.c b/src/files.c
index dde7ac55..343c5bca 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1072,7 +1072,7 @@ bool execute_command(const char *command)
/* Insert a file into the current buffer, or into a new buffer when
* the MULTIBUFFER flag is set. */
-void do_insertfile(void)
+void do_insertfile(bool execute)
{
int response;
const char *msg;
@@ -1080,7 +1080,6 @@ void do_insertfile(void)
/* The last answer the user typed at the status-bar prompt. */
#ifndef NANO_TINY
format_type was_fmt = openfile->fmt;
- bool execute = FALSE;
#endif
/* Display newlines in filenames as ^J. */
@@ -1269,9 +1268,18 @@ void do_insertfile(void)
void do_insertfile_void(void)
{
if (!in_restricted_mode())
- do_insertfile();
+ do_insertfile(FALSE);
}
+#ifndef NANO_TINY
+/* If the current mode of operation allows it, go prompt for a command. */
+void do_execute(void)
+{
+ if (!in_restricted_mode())
+ do_insertfile(TRUE);
+}
+#endif
+
/* For the given bare path (or path plus filename), return the canonical,
* absolute path (plus filename) when the path exists, and NULL when not. */
char *get_full_path(const char *origpath)
diff --git a/src/global.c b/src/global.c
index 0cbe4dfc..adfbe3cf 100644
--- a/src/global.c
+++ b/src/global.c
@@ -693,7 +693,7 @@ void shortcut_init(void)
const char *append_gist = N_("Toggle appending");
const char *prepend_gist = N_("Toggle prepending");
const char *backup_gist = N_("Toggle backing up of the original file");
- const char *execute_gist = N_("Execute external command");
+ const char *execute_gist = N_("Execute a function or an external
command");
const char *pipe_gist =
N_("Pipe the current buffer (or marked region) to the command");
const char *convert_gist = N_("Do not convert from DOS/Mac format");
@@ -795,13 +795,13 @@ void shortcut_init(void)
N_("Paste"), WITHORSANS(paste_gist), BLANKAFTER, NOVIEW);
if (!ISSET(RESTRICTED)) {
+#ifndef NANO_TINY
+ add_to_funcs(do_execute, MMAIN,
+ N_("Execute"), WITHORSANS(execute_gist),
TOGETHER, NOVIEW);
+#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
- N_("Justify"), WITHORSANS(justify_gist),
TOGETHER, NOVIEW);
-#endif
-#ifdef ENABLE_SPELLER
- add_to_funcs(do_spell, MMAIN,
- N_("Spelling"), WITHORSANS(spell_gist),
BLANKAFTER, NOVIEW);
+ N_("Justify"), WITHORSANS(justify_gist),
BLANKAFTER, NOVIEW);
#endif
}
@@ -1037,17 +1037,21 @@ void shortcut_init(void)
add_to_funcs(zap_text, MMAIN,
N_("Zap"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
-#ifdef ENABLE_COLOR
if (!ISSET(RESTRICTED)) {
+#ifdef ENABLE_SPELLER
+ add_to_funcs(do_spell, MMAIN,
+ N_("Spelling"), WITHORSANS(spell_gist),
TOGETHER, NOVIEW);
+#endif
+#ifdef ENABLE_COLOR
add_to_funcs(do_linter, MMAIN,
N_("Linter"), WITHORSANS(lint_gist), TOGETHER,
NOVIEW);
#ifdef ENABLE_SPELLER
add_to_funcs(do_formatter, MMAIN,
N_("Formatter"), WITHORSANS(formatter_gist),
BLANKAFTER, NOVIEW);
-#endif
- }
#endif
#endif
+ }
+#endif /* NANO_TINY */
add_to_funcs(do_savefile, MMAIN,
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
@@ -1178,12 +1182,15 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMOST, "^K", 0, cut_text, 0);
add_to_sclist(MMOST, "^U", 0, paste_text, 0);
+#ifndef NANO_TINY
+ add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
+#endif
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
#endif
#ifdef ENABLE_SPELLER
- add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
+ add_to_sclist(MEXECUTE, "^T", 0, do_spell, 0);
#endif
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
diff --git a/src/proto.h b/src/proto.h
index afe1bc6a..ceb0d2ad 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -294,6 +294,9 @@ void read_file(FILE *f, int fd, const char *filename, bool
undoable);
int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
+#ifndef NANO_TINY
+void do_execute(void);
+#endif
char *get_full_path(const char *origpath);
char *safe_tempfile(FILE **f);
#ifdef ENABLE_OPERATINGDIR
--
2.25.4