int  cmd_is_set = !strncmp (buffer, "set", 3);
char *prefixes[] = { "no", "inv", "?", "&", 0 };
int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs){  char *pt;  int num;  SKIPWS (buffer);  pt = buffer + pos;  while ((pt > buffer) && !isspace ((unsigned char) *pt))    pt--;  if (pt == buffer) /* complete cmd */  {    /* 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; Commands[num].name; num++)	candidate (Completed, User_typed, Commands[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)      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]);    /* return the completed command */    strncpy (buffer, Completed, len);  }  else if (!strncmp (buffer, "set", 3)	   || !strncmp (buffer, "unset", 5)	   || !strncmp (buffer, "reset", 5)	   || !strncmp (buffer, "toggle", 6))  { 		/* complete variables */    /* remember if the command is set to decide whether we want to attempt the     * prefixes */    int  cmd_is_set = !strncmp (buffer, "set", 3);         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; MuttVars[num].option; num++)	candidate (Completed, User_typed, MuttVars[num].option, 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;    }    /* loop through all the possible prefixes (no, inv, ...) */    if (cmd_is_set)    {      char *prefixes[] = { "no", "inv", "?", "&", 0 };      int  prefix_index;      char tmpbuffer[SHORT_STRING];      int  prefix_len;      for ( prefix_index = 0; prefixes[prefix_index]; prefix_index++ )      {        prefix_len = strlen(prefixes[prefix_index]);        strfcpy (tmpbuffer, prefixes[prefix_index], sizeof (tmpbuffer));          /* if the current option is prepended with the prefix */        if ( !strncmp(pt, tmpbuffer, prefix_len ))	{	  /* Move past the prefix */	  pt += prefix_len;	  if (numtabs == 1)	  {	    Num_matched = 0;	    strfcpy (User_typed, pt, sizeof (User_typed));	    memset (Matches, 0, sizeof (Matches));	    for (num = 0; MuttVars[num].option; num++)	      candidate (Completed, User_typed, MuttVars[num].option, 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)      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);  }  else    return 0;  return 1;}