diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1998-10-05 18:24:42 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1998-10-05 18:24:42 +0000 |
commit | f9fb45338e02ec7171f58b91ba89554f3ea57098 (patch) | |
tree | deac7277476c9626dca43c485d6458574a2b674e /init.c | |
parent | ee4d0e3176cd0cb6778ce9fbd4ce2b7d8123fe2e (diff) |
Vikas' macro_function patch.
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -21,6 +21,7 @@ #include "mutt_curses.h" #include "mutt_regex.h" #include "history.h" +#include "keymap.h" #ifdef _PGPPATH @@ -1306,6 +1307,52 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) strncpy (pt, Completed, buffer + len - pt - spaces); } + else if (!strncmp (buffer, "exec", 4)) + { + struct binding_t *menu = km_get_table (CurrentMenu); + + if (!menu && CurrentMenu != MENU_PAGER) + menu = OpGeneric; + + pt++; + /* first TAB. Collect all the matches */ + if (numtabs == 1) + { + Num_matched = 0; + strfcpy (User_typed, pt, sizeof (User_typed)); + memset (Matches, 0, sizeof (Matches)); + memset (Completed, 0, sizeof (Completed)); + for (num = 0; menu[num].name; num++) + candidate (Completed, User_typed, menu[num].name, sizeof (Completed)); + /* try the generic menu */ + if (Completed[0] == 0 && CurrentMenu != MENU_PAGER) + { + menu = OpGeneric; + for (num = 0; menu[num].name; num++) + candidate (Completed, User_typed, menu[num].name, sizeof (Completed)); + } + Matches[Num_matched++] = User_typed; + + /* All matches are stored. Longest non-ambiguous string is "" + * i.e. dont change 'buffer'. Fake successful return this time */ + if (User_typed[0] == 0) + return 1; + } + + if (Completed[0] == 0 && User_typed[0]) + return 0; + + /* Num_matched will _always_ be atleast 1 since the initial + * user-typed string is always stored */ + if (numtabs == 1 && Num_matched == 2) + snprintf(Completed, sizeof(Completed),"%s", Matches[0]); + else if (numtabs > 1 && Num_matched > 2) + /* cycle thru all the matches */ + snprintf(Completed, sizeof(Completed), "%s", + Matches[(numtabs - 2) % Num_matched]); + + strncpy (pt, Completed, buffer + len - pt - spaces); + } else return 0; @@ -1600,6 +1647,8 @@ void mutt_init (int skip_sys_rc, LIST *commands) for (i = 0; MuttVars[i].option; i++) mutt_restore_default (&MuttVars[i]); + CurrentMenu = MENU_MAIN; + #ifndef LOCALES_HACK /* Do we have a locale definition? */ if (((p = getenv ("LC_ALL")) != NULL && p[0]) || |