From: Thomas Roessler Date: Fri, 4 Jul 2003 16:57:56 +0000 (+0000) Subject: Add a ':' flag to % expandos. This will make sure that any X-Git-Tag: pre-type-punning-patch~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d69a66539b5dcdfc57e507e48ce96127fe7c36e4;p=mutt Add a ':' flag to % expandos. This will make sure that any dots are converted into underscores. (_ is already used for lowercasing the result of an expando.) --- diff --git a/init.h b/init.h index cf73f6bd..a0b43f78 100644 --- a/init.h +++ b/init.h @@ -2469,6 +2469,10 @@ struct option_t MuttVars[] = { ** (_) sign. For example, if you want to display the local hostname in ** lowercase, you would use: ** %_h + ** .pp + ** If you prefix the sequence character with a colon (:) character, mutt + ** will replace any dots in the expansion by underscores. This might be helpful + ** with IMAP folders that don't like dots in folder names. */ { "status_on_top", DT_BOOL, R_BOTH, OPTSTATUSONTOP, 0 }, /* diff --git a/muttlib.c b/muttlib.c index 05d80c21..7994c95d 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1023,11 +1023,16 @@ void mutt_FormatString (char *dest, /* output buffer */ else { short tolower = 0; + short nodots = 0; - if (ch == '_') + while (ch == '_' || ch == ':') { + if (ch == '_') + tolower = 1; + else if (ch == ':') + nodots = 1; + ch = *src++; - tolower = 1; } /* use callback function to handle this case */ @@ -1035,6 +1040,13 @@ void mutt_FormatString (char *dest, /* output buffer */ if (tolower) mutt_strlower (buf); + if (nodots) + { + char *p = buf; + for (; *p; p++) + if (*p == '.') + *p = '_'; + } if ((len = mutt_strlen (buf)) + wlen > destlen) len = (destlen - wlen > 0) ? (destlen - wlen) : 0;