changeset: 6768:d1ddea6099cd
user: Kevin McCarthy <[email protected]>
date: Mon Aug 22 20:04:52 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/d1ddea6099cd
Remove the $locale configuration variable.
$locale was only used to set the LC_TIME locale. Unfortunately, Mutt
previously defaulted to using "C". This overrode the user's locale
setting and forced them to re-specify their locale inside their
.muttrc.
Remove $locale and instead use the locale specified by the
environment. Mutt still allows "C locale" dates by using a leading
"!" in $date_format, ${}, etc.
Another use of $locale was to customize attribution dates using hooks.
The next commit will introduce $attribution_locale, which can be used
for this instead.
Thanks to Derek Martin for the original patch!
changeset: 6769:0ae083fb719c
user: Kevin McCarthy <[email protected]>
date: Mon Aug 22 20:04:59 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/0ae083fb719c
Add $attribution_locale configuration variable.
$attribution_locale replaces the just removed $locale, but is only
used for customizing the LC_TIME locale used for dates in
$attribution.
This could be useful in conjunction with folder or send-hooks for
recipients in different locales.
diffs (279 lines):
diff -r e5fcfc5f9c2e -r 0ae083fb719c browser.c
--- a/browser.c Wed Aug 17 20:14:07 2016 -0700
+++ b/browser.c Mon Aug 22 20:04:59 2016 -0700
@@ -176,11 +176,12 @@
tnow = time (NULL);
t_fmt = tnow - folder->ff->mtime < 31536000 ? "%b %d %H:%M" : "%b %d
%Y";
}
- if (do_locales)
- setlocale(LC_TIME, NONULL (Locale)); /* use environment if $locale is
not set */
- else
- setlocale(LC_TIME, "C");
- strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
+
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+ strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
+ if (!do_locales)
+ setlocale (LC_TIME, "");
mutt_format_s (dest, destlen, fmt, date);
}
diff -r e5fcfc5f9c2e -r 0ae083fb719c crypt-gpgme.c
--- a/crypt-gpgme.c Wed Aug 17 20:14:07 2016 -0700
+++ b/crypt-gpgme.c Mon Aug 22 20:04:59 2016 -0700
@@ -869,13 +869,11 @@
{
char p[STRING];
- setlocale (LC_TIME, "");
#ifdef HAVE_LANGINFO_D_T_FMT
strftime (p, sizeof (p), nl_langinfo (D_T_FMT), localtime (&t));
#else
strftime (p, sizeof (p), "%c", localtime (&t));
#endif
- setlocale (LC_TIME, "C");
state_attach_puts (p, s);
}
@@ -2815,9 +2813,6 @@
}
*p = 0;
- if (do_locales && Locale)
- setlocale (LC_TIME, Locale);
-
{
time_t tt = 0;
@@ -2826,11 +2821,13 @@
tm = localtime (&tt);
}
- strftime (buf2, sizeof (buf2), dest, tm);
-
- if (do_locales)
- setlocale (LC_TIME, "C");
-
+
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+ strftime (buf2, sizeof (buf2), dest, tm);
+ if (!do_locales)
+ setlocale (LC_TIME, "");
+
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
snprintf (dest, destlen, fmt, buf2);
if (len > 0)
@@ -3371,9 +3368,6 @@
int i;
gpgme_user_id_t uid = NULL;
- if (Locale)
- setlocale (LC_TIME, Locale);
-
is_pgp = key->protocol == GPGME_PROTOCOL_OpenPGP;
for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next)
@@ -3613,9 +3607,6 @@
putc ('\n', fp);
}
}
-
- if (Locale)
- setlocale (LC_TIME, "C");
}
diff -r e5fcfc5f9c2e -r 0ae083fb719c crypt.c
--- a/crypt.c Wed Aug 17 20:14:07 2016 -0700
+++ b/crypt.c Mon Aug 22 20:04:59 2016 -0700
@@ -64,9 +64,7 @@
if (option (OPTCRYPTTIMESTAMP))
{
t = time(NULL);
- setlocale (LC_TIME, "");
strftime (p, sizeof (p), _(" (current time: %c)"), localtime (&t));
- setlocale (LC_TIME, "C");
}
else
*p = '\0';
diff -r e5fcfc5f9c2e -r 0ae083fb719c doc/manual.xml.head
--- a/doc/manual.xml.head Wed Aug 17 20:14:07 2016 -0700
+++ b/doc/manual.xml.head Mon Aug 22 20:04:59 2016 -0700
@@ -3624,8 +3624,8 @@
<para>
Another typical use for this command is to change the values of the
<link linkend="attribution">$attribution</link>, <link
-linkend="signature">$signature</link> and <link
-linkend="locale">$locale</link> variables in order to change the
+linkend="attribution-locale">$attribution_locale</link>, and <link
+linkend="signature">$signature</link> variables in order to change the
language of the attributions and signatures based upon the recipients.
</para>
diff -r e5fcfc5f9c2e -r 0ae083fb719c edit.c
--- a/edit.c Wed Aug 17 20:14:07 2016 -0700
+++ b/edit.c Mon Aug 22 20:04:59 2016 -0700
@@ -160,7 +160,9 @@
/* add the attribution */
if (Attribution)
{
+ setlocale (LC_TIME, NONULL (AttributionLocale));
mutt_make_string (tmp, sizeof (tmp) - 1, Attribution, Context,
Context->hdrs[n]);
+ setlocale (LC_TIME, "");
strcat (tmp, "\n"); /* __STRCAT_CHECKED__ */
}
diff -r e5fcfc5f9c2e -r 0ae083fb719c globals.h
--- a/globals.h Wed Aug 17 20:14:07 2016 -0700
+++ b/globals.h Mon Aug 22 20:04:59 2016 -0700
@@ -36,6 +36,7 @@
WHERE char *AssumedCharset;
WHERE char *AttachSep;
WHERE char *Attribution;
+WHERE char *AttributionLocale;
WHERE char *AttachCharset;
WHERE char *AttachFormat;
WHERE char *Charset;
@@ -66,7 +67,6 @@
#endif
WHERE char *Inbox;
WHERE char *Ispell;
-WHERE char *Locale;
WHERE char *MailcapPath;
WHERE char *Maildir;
#if defined(USE_IMAP) || defined(USE_POP)
diff -r e5fcfc5f9c2e -r 0ae083fb719c hdrline.c
--- a/hdrline.c Wed Aug 17 20:14:07 2016 -0700
+++ b/hdrline.c Mon Aug 22 20:04:59 2016 -0700
@@ -383,9 +383,6 @@
}
*p = 0;
- if (do_locales && Locale)
- setlocale (LC_TIME, Locale);
-
if (op == '[' || op == 'D')
tm = localtime (&hdr->date_sent);
else if (op == '(')
@@ -406,10 +403,11 @@
tm = gmtime (&T);
}
- strftime (buf2, sizeof (buf2), dest, tm);
-
- if (do_locales)
- setlocale (LC_TIME, "C");
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+ strftime (buf2, sizeof (buf2), dest, tm);
+ if (!do_locales)
+ setlocale (LC_TIME, "");
mutt_format_s (dest, destlen, prefix, buf2);
if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
diff -r e5fcfc5f9c2e -r 0ae083fb719c init.h
--- a/init.h Wed Aug 17 20:14:07 2016 -0700
+++ b/init.h Mon Aug 22 20:04:59 2016 -0700
@@ -266,6 +266,18 @@
** in a reply. For a full listing of defined \fCprintf(3)\fP-like sequences
see
** the section on $$index_format.
*/
+ { "attribution_locale", DT_STR, R_NONE, UL &AttributionLocale, UL "" },
+ /*
+ ** .pp
+ ** The locale used by \fCstrftime(3)\fP to format dates in the
+ ** $attribution string. Legal values are the strings your system
+ ** accepts for the locale environment variable \fC$$$LC_TIME\fP.
+ ** .pp
+ ** This variable is to allow the attribution date format to be
+ ** customized by recipient or folder using hooks. By default, Mutt
+ ** will use your locale environment, so there is no need to set
+ ** this except to override that default.
+ */
{ "auto_tag", DT_BOOL, R_NONE, OPTAUTOTAG, 0 },
/*
** .pp
@@ -599,8 +611,8 @@
** function to process the date, see the man page for the proper syntax.
** .pp
** Unless the first character in the string is a bang (``!''), the month
- ** and week day names are expanded according to the locale specified in
- ** the variable $$locale. If the first character in the string is a
+ ** and week day names are expanded according to the locale.
+ ** If the first character in the string is a
** bang, the bang is discarded, and the month and week day names in the
** rest of the string are expanded in the \fIC\fP locale (that is in US
** English).
@@ -1395,12 +1407,6 @@
** from your spool mailbox to your $$mbox mailbox, or as a result of
** a ``$mbox-hook'' command.
*/
- { "locale", DT_STR, R_BOTH, UL &Locale, UL "C" },
- /*
- ** .pp
- ** The locale used by \fCstrftime(3)\fP to format dates. Legal values are
- ** the strings your system accepts for the locale environment variable
\fC$$$LC_TIME\fP.
- */
{ "mail_check", DT_NUM, R_NONE, UL &BuffyTimeout, 5 },
/*
** .pp
diff -r e5fcfc5f9c2e -r 0ae083fb719c main.c
--- a/main.c Wed Aug 17 20:14:07 2016 -0700
+++ b/main.c Mon Aug 22 20:04:59 2016 -0700
@@ -597,15 +597,14 @@
exit(1);
}
+ setlocale (LC_ALL, "");
+
#ifdef ENABLE_NLS
/* FIXME what about init.c:1439 ? */
- setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, MUTTLOCALEDIR);
textdomain (PACKAGE);
#endif
- setlocale (LC_CTYPE, "");
-
mutt_error = mutt_nocurses_error;
mutt_message = mutt_nocurses_error;
SRAND (time (NULL));
diff -r e5fcfc5f9c2e -r 0ae083fb719c pgpkey.c
--- a/pgpkey.c Wed Aug 17 20:14:07 2016 -0700
+++ b/pgpkey.c Mon Aug 22 20:04:59 2016 -0700
@@ -195,15 +195,14 @@
}
*p = 0;
- if (do_locales && Locale)
- setlocale (LC_TIME, Locale);
tm = localtime (&key->gen_time);
- strftime (buf2, sizeof (buf2), dest, tm);
-
- if (do_locales)
- setlocale (LC_TIME, "C");
+ if (!do_locales)
+ setlocale (LC_TIME, "C");
+ strftime (buf2, sizeof (buf2), dest, tm);
+ if (!do_locales)
+ setlocale (LC_TIME, "");
snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
snprintf (dest, destlen, fmt, buf2);
diff -r e5fcfc5f9c2e -r 0ae083fb719c send.c
--- a/send.c Wed Aug 17 20:14:07 2016 -0700
+++ b/send.c Mon Aug 22 20:04:59 2016 -0700
@@ -401,7 +401,9 @@
char buffer[LONG_STRING];
if (Attribution)
{
+ setlocale (LC_TIME, NONULL (AttributionLocale));
mutt_make_string (buffer, sizeof (buffer), Attribution, ctx, cur);
+ setlocale (LC_TIME, "");
fputs (buffer, out);
fputc ('\n', out);
}