diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1998-09-12 19:41:02 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1998-09-12 19:41:02 +0000 |
commit | 3d99b5254b7a81d4ce32663c53291ab66e406212 (patch) | |
tree | 8ffcc4b5256752e3f90cae65fbfe099ff4474629 /init.c | |
parent | bc42769b83cc62cd98a81792a6d6068ce14ce649 (diff) |
When entering a 'set' command on the command-line,
pressing TAB after string_var= will insert the current
value of that variable. Note that this works only for
variables of type 'string'.
Also fixes the following buglets in command-completion:
1. doesnt work if you started the command-line with
whitespace
2. Seems to think that 'Set', 'ReSeT', etc are valid
commands (since it checks for 'strcasecmp' instead of
'strcmp' when completing the variable names Also fixes
the following buglets in command-completion:
(From: Vikas Agnihotri <VikasA@att.com>)
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 49 |
1 files changed, 44 insertions, 5 deletions
@@ -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; |