diff --git a/src/files.c b/src/files.c index 4fb61185..b1674e95 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 5834ec66..277a69f5 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"); @@ -793,13 +793,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 } @@ -1035,8 +1035,12 @@ 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_("Spell Check"), WITHORSANS(spell_gist), TOGETHER, NOVIEW); +#endif +#ifdef ENABLE_COLOR add_to_funcs(do_linter, MMAIN, N_("Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW); add_to_funcs(do_formatter, MMAIN, @@ -1174,12 +1178,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 b0ab673c..9bf0cd80 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