diff -ur joe-3.1/path.c joe-3.1_work/path.c --- joe-3.1/path.c 2004-05-28 18:36:15.000000000 +0200 +++ joe-3.1_work/path.c 2004-10-29 14:54:02.567239008 +0200 @@ -357,6 +357,37 @@ } return lst; } + +unsigned char **rexpnd_tags(unsigned char *word) +{ + unsigned char buf[512]; + unsigned char tag[512]; + int i,pos; + FILE *f; + unsigned char **lst = NULL; + + f = fopen("tags", "r"); + if (f) { + while (fgets((char *)buf, 512, f)) { + pos = 0; + for (i=0; i<512; i++) { + if (buf[i] == ' ' || buf[i] == '\t') { + pos = i; + i = 512; + } + } + if (pos > 0) { + strncpy(tag, buf, pos); + tag[pos] = '\0'; + } + if (rmatch(word, tag)) { + lst = vaadd(lst, vsncpy(NULL, 0, sz(tag))); + } + } + fclose(f); + } + return lst; +} /********************************************************************/ int chpwd(unsigned char *path) { diff -ur joe-3.1/tab.c joe-3.1_work/tab.c --- joe-3.1/tab.c 2004-05-07 21:32:05.000000000 +0200 +++ joe-3.1_work/tab.c 2004-10-29 14:25:07.796964176 +0200 @@ -58,7 +58,7 @@ * type is set with the file types */ -static int get_entries(TAB *tab, int prv) +static int get_entries_files(TAB *tab, int prv) { int a; int which = 0; @@ -101,6 +101,32 @@ return which; } +static int get_entries_tags(TAB *tab, int prv) +{ + unsigned char **tags; + int a; + + tags = (unsigned char **)rexpnd_tags(tab->pattern); + if (!tags) { + return -1; + } + if (!aLEN(tags)) { + return -1; + } + tab->len = aLEN(tags); + varm(tab->files); + tab->files = tags; + + if (tab->type) { + joe_free(tab->type); + } + tab->type = (unsigned char *) joe_malloc(tab->len); + for (a=0; alen; a++) { + tab->type[a] = F_NORMAL; + } + return 0; +} + static void insnam(BW *bw, unsigned char *path, unsigned char *nam, int dir, int ofst) { P *p = pdup(bw->cursor); @@ -144,13 +170,23 @@ int which; struct stat buf; - if ((which = get_entries(tab, tab->prv)) < 0) - return 0; - if (tab->path && tab->path[0]) - stat((char *)tab->path, &buf); - else - stat(".", &buf); - tab->prv = buf.st_ino; + /* + * Base type of entries on bw->parent->huh + * default to file + */ + if (bw->parent && bw->parent->huh && strlen(bw->parent->huh) >= 4 && strncmp(bw->parent->huh, "Tags", 4) == 0) { + if ((which = get_entries_tags(tab, tab->prv)) < 0) + return 0; + } else { + if ((which = get_entries_files(tab, tab->prv)) < 0) + return 0; + if (tab->path && tab->path[0]) + stat((char *)tab->path, &buf); + else + stat(".", &buf); + tab->prv = buf.st_ino; + } + if (!flg) which = 0; diff -ur joe-3.1/utag.c joe-3.1_work/utag.c --- joe-3.1/utag.c 2004-05-04 18:00:38.000000000 +0200 +++ joe-3.1_work/utag.c 2004-10-29 14:28:36.466241624 +0200 @@ -132,7 +132,7 @@ { BW *pbw; - pbw = wmkpw(bw->parent, US "Tag search: ", &taghist, dotag, NULL, NULL, cmplt, NULL, NULL, locale_map); + pbw = wmkpw(bw->parent, US "Tag search: ", &taghist, dotag, US "Tags", NULL, cmplt, NULL, NULL, locale_map); if (pbw && joe_isalnum_(bw->b->o.charmap,brch(bw->cursor))) { P *p = pdup(bw->cursor); P *q = pdup(p);