Don't write autocmd to command history.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 14 Jan 2015 12:48:05 +0000 (13:48 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 14 Jan 2015 12:48:05 +0000 (13:48 +0100)
src/autocmd.c
src/ex.c
src/ex.h
src/main.c

index 5b32f0b..e856a4c 100644 (file)
@@ -277,7 +277,8 @@ gboolean autocmd_run(AuEvent event, const char *uri, const char *group)
             }
             /* run the command */
             /* TODO shoult the result be tested for RESULT_COMPLETE? */
-            ex_run_string(cmd->excmd);
+            /* run command and make sure it's not writte to command history */
+            ex_run_string(cmd->excmd, false);
         }
     }
 
index e23929b..89d31a3 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -462,7 +462,7 @@ static void input_activate(void)
 
         case ':':
             mode_enter('n');
-            res = ex_run_string(cmd);
+            res = ex_run_string(cmd, true);
             if (!(res & VB_CMD_KEEPINPUT)) {
                 /* clear input on success if this is not explicit ommited */
                 vb_set_input_text("");
@@ -473,7 +473,7 @@ static void input_activate(void)
     g_free(text);
 }
 
-VbCmdResult ex_run_string(const char *input)
+VbCmdResult ex_run_string(const char *input, gboolean enable_history)
 {
     /* copy to have original command for history */
     const char *in  = input;
@@ -489,7 +489,7 @@ VbCmdResult ex_run_string(const char *input)
         }
     }
 
-    if (!nohist) {
+    if (enable_history && !nohist) {
         history_add(HISTORY_COMMAND, input, NULL);
         vb_register_add(':', input);
     }
index 95cf194..9b706e3 100644 (file)
--- a/src/ex.h
+++ b/src/ex.h
@@ -28,6 +28,6 @@ void ex_leave(void);
 VbResult ex_keypress(int key);
 void ex_input_changed(const char *text);
 gboolean ex_fill_completion(GtkListStore *store, const char *input);
-VbCmdResult ex_run_string(const char *input);
+VbCmdResult ex_run_string(const char *input, gboolean enable_history);
 
 #endif /* end of include guard: _EX_H */
index d76b0a9..9e2e1ed 100644 (file)
@@ -939,7 +939,7 @@ static void read_config(void)
             if (*line == '#') {
                 continue;
             }
-            if (ex_run_string(line) & VB_CMD_ERROR ) {
+            if (ex_run_string(line, false) & VB_CMD_ERROR ) {
                 g_warning("Invalid user config: '%s'", line);
             }
         }
@@ -1626,7 +1626,7 @@ int main(int argc, char *argv[])
 
     /* process the --cmd if this was given */
     for (GSList *l = vb.config.cmdargs; l; l = l->next) {
-        ex_run_string(l->data);
+        ex_run_string(l->data, false);
     }
 
     /* active the registers and writing of command history */