From 1f3162e8070ff73b0fe9ca37ab71a2164153d1d8 Mon Sep 17 00:00:00 2001 From: Austin Ray Date: Fri, 12 Oct 2018 12:15:22 -0400 Subject: [PATCH] browser: `%i` - folder_format description expando `%i` will display the description for a folder and fallback to the folder's name if a description does not exist. --- browser.c | 30 ++++++++++++++++++++++++++---- init.h | 1 + 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/browser.c b/browser.c index 110dbc77b..e6b7a0c7a 100644 --- a/browser.c +++ b/browser.c @@ -352,6 +352,7 @@ static bool link_is_dir(const char *folder, const char *path) * | \%F | File permissions * | \%f | Filename (with suffix '/', '@' or '*') * | \%g | Group name (or numeric gid, if missing) + * | \%i | Description of the folder * | \%l | Number of hard links * | \%m | Number of messages in the mailbox * * | \%N | N if mailbox has new mail, blank otherwise @@ -492,6 +493,27 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c mutt_format_s(buf, buflen, prec, ""); break; + case 'i': + { + char *s = NULL; + if (folder->ff->desc) + s = folder->ff->desc; + else + s = folder->ff->name; + + snprintf(fn, sizeof(fn), "%s%s", s, + folder->ff->local ? + (S_ISLNK(folder->ff->mode) ? + "@" : + (S_ISDIR(folder->ff->mode) ? + "/" : + ((folder->ff->mode & S_IXUSR) != 0 ? "*" : ""))) : + ""); + + mutt_format_s(buf, buflen, prec, fn); + break; + } + case 'l': if (folder->ff->local) { @@ -986,21 +1008,21 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) #ifdef USE_IMAP if (imap_path_probe(np->m->path, NULL) == MUTT_IMAP) { - add_folder(menu, state, buffer, NULL, NULL, np->m, NULL); + add_folder(menu, state, buffer, np->m->desc, NULL, np->m, NULL); continue; } #endif #ifdef USE_POP if (pop_path_probe(np->m->path, NULL) == MUTT_POP) { - add_folder(menu, state, buffer, NULL, NULL, np->m, NULL); + add_folder(menu, state, buffer, np->m->desc, NULL, np->m, NULL); continue; } #endif #ifdef USE_NNTP if (nntp_path_probe(np->m->path, NULL) == MUTT_NNTP) { - add_folder(menu, state, np->m->path, NULL, NULL, np->m, NULL); + add_folder(menu, state, np->m->path, np->m->desc, NULL, np->m, NULL); continue; } #endif @@ -1025,7 +1047,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) s.st_mtime = st2.st_mtime; } - add_folder(menu, state, buffer, NULL, &s, np->m, NULL); + add_folder(menu, state, buffer, np->m->desc, &s, np->m, NULL); } } browser_sort(state); diff --git a/init.h b/init.h index 39fe61b4a..ead1a5605 100644 --- a/init.h +++ b/init.h @@ -995,6 +995,7 @@ struct ConfigDef MuttVars[] = { ** ``@'' to symbolic links and ``*'' to executable files) ** .dt %F .dd File permissions ** .dt %g .dd Group name (or numeric gid, if missing) + ** .dt %i .dd Description of the folder ** .dt %l .dd Number of hard links ** .dt %m .dd Number of messages in the mailbox * ** .dt %n .dd Number of unread messages in the mailbox * -- 2.40.0