diff options
-rw-r--r-- | commands.c | 2 | ||||
-rw-r--r-- | enter.c | 18 | ||||
-rw-r--r-- | history.h | 1 | ||||
-rw-r--r-- | init.c | 49 | ||||
-rw-r--r-- | mutt.h | 1 | ||||
-rw-r--r-- | pattern.c | 4 | ||||
-rw-r--r-- | protos.h | 1 | ||||
-rw-r--r-- | recvattach.c | 4 |
8 files changed, 65 insertions, 15 deletions
@@ -293,7 +293,7 @@ int mutt_pipe_message (HEADER *h) pid_t thepid; buffer[0] = 0; - if (mutt_get_field ("Pipe to command: ", buffer, sizeof (buffer), 0) != 0 || + if (mutt_get_field ("Pipe to command: ", buffer, sizeof (buffer), M_CMD) != 0 || !buffer[0]) return 0; mutt_expand_path (buffer, sizeof (buffer)); @@ -65,14 +65,16 @@ int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x, char tempbuf[_POSIX_PATH_MAX] = ""; history_class_t hclass; - if(flags & (M_FILE | M_EFILE)) + if (flags & (M_FILE | M_EFILE)) hclass = HC_FILE; - else if(flags & M_CMD) + else if (flags & M_CMD) hclass = HC_CMD; - else if(flags & M_ALIAS) + else if (flags & M_ALIAS) hclass = HC_ALIAS; - else if(flags & M_COMMAND) + else if (flags & M_COMMAND) hclass = HC_COMMAND; + else if (flags & M_PATTERN) + hclass = HC_PATTERN; else hclass = HC_OTHER; @@ -347,7 +349,13 @@ int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x, else if (flags & M_COMMAND) { buf[curpos] = 0; - if (mutt_command_complete ((char *) buf, buflen, curpos)) + if (buf[lastchar - 1] == '=' && + mutt_string_var_complete ((char *) buf, buflen, curpos)) + { + redraw = M_REDRAW_INIT; + continue; + } + else if (mutt_command_complete ((char *) buf, buflen, curpos)) { redraw = M_REDRAW_INIT; continue; @@ -25,6 +25,7 @@ enum history_class HC_ALIAS, HC_COMMAND, HC_FILE, + HC_PATTERN, HC_OTHER, HC_LAST }; @@ -1187,6 +1187,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos) if (buffer[0] == 0) return 0; + SKIPWS (buffer); strncpy (cmd, buffer, pos); pt = cmd; pt[pos] = 0; @@ -1206,10 +1207,10 @@ int mutt_command_complete (char *buffer, size_t len, int pos) return 0; strncpy (buffer, completed, len); } - else if (!strcasecmp (cmd, "set") - || !strcasecmp (cmd, "unset") - || !strcasecmp (cmd, "reset") - || !strcasecmp (cmd, "toggle")) + else if (!strcmp (cmd, "set") + || !strcmp (cmd, "unset") + || !strcmp (cmd, "reset") + || !strcmp (cmd, "toggle")) { /* complete variables */ char *prefixes[] = { "no", "inv", "?", "&", 0 }; int prefix_index; @@ -1218,7 +1219,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos) /* remember if the command is set to decide whether we want to attempt the * prefixes */ - int cmd_is_set = !strcasecmp (cmd, "set"); + int cmd_is_set = !strcmp (cmd, "set"); pt++; if (*pt == 0) @@ -1255,6 +1256,44 @@ int mutt_command_complete (char *buffer, size_t len, int pos) return 1; } +int mutt_string_var_complete (char *buffer, size_t len, int pos) +{ + char cmd[STRING], *pt; + int i; + + if (buffer[0] == 0) + return 0; + SKIPWS (buffer); + strncpy (cmd, buffer, pos); + pt = cmd; + pt[pos] = 0; + while (!isspace ((unsigned char) *pt)) + pt++; + *pt = 0; + + pt = buffer + pos; + while ((pt > buffer) && !isspace ((unsigned char) *pt)) + pt--; + pt++; /* move past the space */ + if (*pt == '=') /* abort if no var before the '=' */ + return 0; + + if (strcmp (cmd, "set") == 0) + { + for (i = 0; MuttVars[i].option; i++) + if (DTYPE(MuttVars[i].type) == DT_STR && + /* ignore the trailing '=' when comparing */ + strncmp (MuttVars[i].option, pt, strlen (pt) - 1) == 0) + { + strncat (pt, "\"", buffer + len - pt); + strncat (pt, NONULL (*((char **) MuttVars[i].data)), buffer + len - pt); + strncat (pt, "\"", buffer + len - pt); + return 1; + } + } + return 0; +} + char *mutt_getnamebyvalue (int val, const struct mapping_t *map) { int i; @@ -71,6 +71,7 @@ #define M_PASS (1<<4) /* password mode (no echo) */ #define M_CLEAR (1<<5) /* clear input if printable character is pressed */ #define M_COMMAND (1<<6) /* do command completion */ +#define M_PATTERN (1<<7) /* pattern mode - only used for history classes */ /* flags for mutt_get_token() */ #define M_TOKEN_EQUAL 1 /* treat '=' as a special */ @@ -881,7 +881,7 @@ int mutt_pattern_func (int op, char *prompt) BUFFER err; int i; - if (mutt_get_field (prompt, buf, sizeof (buf), 0) != 0 || !buf[0]) + if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN) != 0 || !buf[0]) return (-1); mutt_message ("Compiling search pattern..."); @@ -994,7 +994,7 @@ int mutt_search_command (int cur, int op) { strfcpy (buf, LastSearch, sizeof (buf)); if (mutt_get_field ((op == OP_SEARCH) ? "Search for: " : "Reverse search for: ", - buf, sizeof (buf), M_CLEAR) != 0 || !buf[0]) + buf, sizeof (buf), M_CLEAR | M_PATTERN) != 0 || !buf[0]) return (-1); if (op == OP_SEARCH) @@ -212,6 +212,7 @@ int mutt_check_mime_type (const char *); int mutt_check_month (const char *); int mutt_check_overwrite (const char *, const char *, char *, size_t, int); int mutt_command_complete (char *, size_t, int); +int mutt_string_var_complete (char *, size_t, int); int mutt_complete (char *); int mutt_compose_attachment (BODY *a); int mutt_copy_bytes (FILE *, FILE *, size_t); diff --git a/recvattach.c b/recvattach.c index 4db824a1..b5d0f220 100644 --- a/recvattach.c +++ b/recvattach.c @@ -275,7 +275,7 @@ static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr) else buf[0] = 0; - if (mutt_get_field ("Save to file: ", buf, sizeof (buf), M_FILE | M_CLEAR) != 0 + if (mutt_get_field ("Save to file: ", buf, sizeof (buf), M_FILE | M_CLEAR) != 0 || !buf[0]) return -1; @@ -460,7 +460,7 @@ void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter) memset (&state, 0, sizeof (STATE)); if (mutt_get_field ((filter ? "Filter through: " : "Pipe to: "), - buf, sizeof (buf), 0) != 0 || !buf[0]) + buf, sizeof (buf), M_CMD) != 0 || !buf[0]) return; mutt_expand_path (buf, sizeof (buf)); |