--- dmenu-3.9/dmenu.c 2008-09-09 15:45:00.000000000 -0400 +++ dmenu-4.0/dmenu.c 2009-01-27 16:35:28.000000000 -0500 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,7 @@ static void initfont(const char *fontstr); static void kpress(XKeyEvent * e); static void match(char *pattern); +static void matchfile(char *filestart); static void readstdin(void); static void run(void); static void setup(Bool topbar); @@ -470,6 +472,10 @@ } break; case XK_Tab: + if( strchr(text, ' ')!=NULL ) { + matchfile( strchr(text, ' ')+1 ); + break; + } if(!sel) return; strncpy(text, sel->text, sizeof text); @@ -521,6 +527,35 @@ } void +matchfile(char *filestart) { + wordexp_t exp; + int i, j, k, p=strlen(filestart); + filestart[ p+1 ] = 0; + filestart[ p ] = '*'; + + wordexp(filestart, &exp, 0); + if( exp.we_wordc > 0 ) { + for(j=0,i=0; exp.we_wordv[0][i]!=0; i++,j++) { + if( exp.we_wordv[0][i]==' ' ) filestart[j++]='\\'; + filestart[j]=exp.we_wordv[0][i]; + } + filestart[j]=0; + + for(k=1; k