--- a/complete.c Mon Jul 16 10:46:49 2007 -0700 +++ b/complete.c Thu Nov 15 00:18:21 2007 -0500 @@ -186,10 +186,22 @@ int mutt_complete (char *s, size_t slen) if (dirpart[0]) { + char buf[_POSIX_PATH_MAX]; + struct stat st; + strfcpy (s, dirpart, slen); if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') strfcpy (s + strlen (s), "/", slen - strlen (s)); strfcpy (s + strlen (s), filepart, slen - strlen (s)); + + /* complete to xxx.sbd instead of xxx if it exists and is a directory */ + strfcpy (buf, exp_dirpart, sizeof (buf)); + strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf)); + strfcpy (buf + strlen (buf), filepart, sizeof(buf) - strlen (buf)); + strfcpy (buf + strlen (buf), ".sbd", sizeof (buf) - strlen (buf)); + if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) + strfcpy (s + strlen (s), ".sbd/", slen - strlen (s)); + } else strfcpy (s, filepart, slen);