nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] new feature: option -e, for specifying commands to


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] new feature: option -e, for specifying commands to execute at startup
Date: Sun, 19 Aug 2018 12:39:47 +0200

The commands should be given in a string, just like when binding a key
to a string.

This fulfills https://savannah.gnu.org/bugs/?54535.
Requested-by: Derek Wolfe <address@hidden>
---
 src/nano.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 0e7f4bab..e50bad4c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1953,6 +1953,8 @@ void do_output(char *output, size_t output_len, bool 
allow_cntrls)
 int main(int argc, char **argv)
 {
        int stdin_flags, optchr;
+       char *commands = NULL;
+               /* The commands specified on the command line, if any. */
 #if defined(ENABLED_WRAPORJUSTIFY) && defined(ENABLE_NANORC)
        bool fill_used = FALSE;
                /* Was the fill option used on the command line? */
@@ -1987,6 +1989,7 @@ int main(int argc, char **argv)
 #endif
                {"constantshow", 0, NULL, 'c'},
                {"rebinddelete", 0, NULL, 'd'},
+               {"execute", 1, NULL, 'e'},
 #ifdef ENABLE_BROWSER
                {"showcursor", 0, NULL, 'g'},
 #endif
@@ -2091,7 +2094,7 @@ int main(int argc, char **argv)
 
        while ((optchr =
                getopt_long(argc, argv,
-                               
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxyz$",
+                               
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcde:fghijklmno:pqr:s:tuvwxyz$",
                                long_options, NULL)) != -1) {
                switch (optchr) {
 #ifndef NANO_TINY
@@ -2207,6 +2210,9 @@ int main(int argc, char **argv)
                        case 'd':
                                SET(REBIND_DELETE);
                                break;
+                       case 'e':
+                               commands = mallocstrcpy(commands, optarg);
+                               break;
                        case 'g':
                                SET(SHOW_CURSOR);
                                break;
@@ -2302,7 +2308,6 @@ int main(int argc, char **argv)
                                break;
 #endif
                        case 'b':  /* Pico compatibility flags. */
-                       case 'e':
                        case 'f':
                        case 'j':
                                break;
@@ -2607,6 +2612,10 @@ int main(int argc, char **argv)
        set_escdelay(50);
 #endif
 
+       /* If --execute was specified, insert its argument into the key buffer. 
*/
+       if (commands)
+               implant(commands);
+
 #ifdef DEBUG
        fprintf(stderr, "Main: open file\n");
 #endif
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]