New trailing
[claws.git] / src / prefs_actions.c
index 5d247e958a320d85a74a36e8f02f3370fb7c31e8..a36963262398c1b01b9a507e9d93b102636964ed 100644 (file)
@@ -62,7 +62,8 @@ typedef enum
        ACTION_ASYNC    = 1 << 5,
        ACTION_OPEN_IN  = 1 << 6,
        ACTION_HIDE_IN  = 1 << 7,
-       ACTION_ERROR    = 1 << 8,
+       ACTION_INSERT   = 1 << 8,
+       ACTION_ERROR    = 1 << 9,
 } ActionType;
 
 static struct Actions
@@ -342,6 +343,7 @@ static void prefs_actions_create(MainWindow *mainwin)
                   "   * to send user provided hidden text to command\n"
                   " End with:\n"
                   "   | to replace message body or selection with command output\n"
+                  "   > to insert command's output without replacing old text\n"
                   "   & to run command asynchronously\n"
                   " Use %f for message file name\n"
                   "   %F for the list of the file names of selected messages\n"
@@ -568,6 +570,9 @@ static guint get_action_type(gchar *action)
                } else if (p[0] == '|') {
                        if (p[1] == 0x00)
                                action_type |= ACTION_PIPE_OUT;
+               } else if (p[0] == '>') {
+                       if (p[1] == 0x00)
+                               action_type |= ACTION_INSERT;
                } else if (p[0] == '&') {
                        if (p[1] == 0x00)
                                action_type |= ACTION_ASYNC;
@@ -595,7 +600,8 @@ static gchar *parse_action_cmd(gchar *action, MsgInfo *msginfo,
 
        cmd = g_string_sized_new(strlen(action));
 
-       while (p[0] && !(p[0] == '|' && !p[1]) && p[0] != '&') {
+       while (p[0] &&
+              !((p[0] == '|' || p[0] == '>' || p[0] == '&') && !p[1])) {
                if (p[0] == '%' && p[1]) {
                        switch (p[1]) {
                        case 'f':
@@ -1169,7 +1175,7 @@ static gboolean execute_actions(gchar *action, GtkWidget *window,
                selection_len = g_list_length(selection);
        }
 
-       if (action_type & (ACTION_PIPE_OUT | ACTION_PIPE_IN)) {
+       if (action_type & (ACTION_PIPE_OUT | ACTION_PIPE_IN | ACTION_INSERT)) {
                if (ctree && selection_len > 1)
                        return FALSE; /* ERR: pipe + multiple selection */
                if (!text)
@@ -1394,7 +1400,7 @@ ChildInfo *fork_child(gchar *cmd, gint action_type, GtkWidget *text,
        child_info->tag_err     = gdk_input_add(chld_err[0], GDK_INPUT_READ,
                                                catch_output, child_info);
 
-       if (!(action_type & (ACTION_PIPE_IN | ACTION_PIPE_OUT)))
+       if (!(action_type & (ACTION_PIPE_IN | ACTION_PIPE_OUT | ACTION_INSERT)))
                return child_info;
 
        child_info->text        = text;
@@ -1753,7 +1759,7 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond)
        gchar buf[PREFSBUFSIZE];
 
        debug_print("Catching grand child's output.\n");
-       if (child_info->type & ACTION_PIPE_OUT
+       if (child_info->type & (ACTION_PIPE_OUT | ACTION_INSERT)
            && source == child_info->chld_out) {
                gboolean is_selection = FALSE;
                GtkWidget *text = child_info->text;