From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#39248: format-time-string ignores user's preferred locale Date: Thu, 23 Jan 2020 23:35:20 -0800 Organization: UCLA Computer Science Department Message-ID: References: <68077D50-2E85-4FB7-92EF-96C636D6DE6E@paulwrankin.com> <837e1it5el.fsf@gnu.org> <3ov9p1j0c4.fsf@fencepost.gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------9B8BB86E35BCD34A1C2EEB38" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="11055"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: 39248@debbugs.gnu.org, Alan Third To: "Paul W. Rankin" , Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 24 08:36:18 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iutVq-0002pb-EE for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 08:36:18 +0100 Original-Received: from localhost ([::1]:38338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iutVp-00025y-J8 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 02:36:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45430) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iutVb-00025o-M5 for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 02:36:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iutVa-0002qZ-IK for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 02:36:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iutVa-0002qF-Eh for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 02:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iutVa-0007W6-9x for bug-gnu-emacs@gnu.org; Fri, 24 Jan 2020 02:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Jan 2020 07:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39248 X-GNU-PR-Package: emacs Original-Received: via spool by 39248-submit@debbugs.gnu.org id=B39248.157985133428861 (code B ref 39248); Fri, 24 Jan 2020 07:36:02 +0000 Original-Received: (at 39248) by debbugs.gnu.org; 24 Jan 2020 07:35:34 +0000 Original-Received: from localhost ([127.0.0.1]:53436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iutV7-0007VR-J4 for submit@debbugs.gnu.org; Fri, 24 Jan 2020 02:35:33 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39016) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iutV4-0007VC-QJ for 39248@debbugs.gnu.org; Fri, 24 Jan 2020 02:35:32 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 35149160071; Thu, 23 Jan 2020 23:35:25 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id F_5YkA2I1cFZ; Thu, 23 Jan 2020 23:35:24 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 24D0D160086; Thu, 23 Jan 2020 23:35:24 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Bv1sQcm6Z3rS; Thu, 23 Jan 2020 23:35:24 -0800 (PST) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E4F7B160071; Thu, 23 Jan 2020 23:35:23 -0800 (PST) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175205 Archived-At: This is a multi-part message in MIME format. --------------9B8BB86E35BCD34A1C2EEB38 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 1/23/20 7:17 PM, Paul W. Rankin wrote: > The relationship doesn't appear as the same as on GNU/Linux. It's similar, in that one can launch apps in various ways (e.g., via Gnome) without involving shell environment variables. Looking into this a bit more, I see that Alan Third wrote a fix for this problem (which is apparently quite a zoo in macOS, as Apple keeps changing how to set environment variables!) into Emacs in master commit 2016-02-11T02:26:50Z!alan@idiocy.org. However, Emacs currently sets the LANG environment variable in ns_init_locale *after* Emacs uses LANG to set the LC_TIME locale, which is not what is wanted here. So, please try the attached patch to master. You'll need to grab the latest master as I recently installed a locale cleanup patch while looking into this mess. If this patch doesn't work for you, perhaps you can write a small variant of it that does work. --------------9B8BB86E35BCD34A1C2EEB38 Content-Type: text/x-patch; charset=UTF-8; name="0001-Propagate-NSLocale-into-Emacs-better.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Propagate-NSLocale-into-Emacs-better.patch" >From 82821adea730dab5a42d24e49675ade1c2f5c1f3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 23 Jan 2020 23:16:47 -0800 Subject: [PATCH] Propagate NSLocale into Emacs better * src/emacs.c (main): Call ns_init_locale before using the environment variable that ns_init_locale sets up (Bug#39248). --- src/emacs.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 4b5d00a0e8..c170333e60 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1242,6 +1242,9 @@ main (int argc, char **argv) char *lc_all = getenv ("LC_ALL"); if (! (lc_all && strcmp (lc_all, "C") == 0)) { + #ifdef HAVE_NS + ns_init_locale (); + #endif setlocale (LC_ALL, ""); fixup_locale (); } @@ -1610,10 +1613,6 @@ main (int argc, char **argv) #ifdef HAVE_NS ns_pool = ns_alloc_autorelease_pool (); -#ifdef NS_IMPL_GNUSTEP - /* GNUstep stupidly resets our locale settings after we made them. */ - fixup_locale (); -#endif if (!noninteractive) { @@ -1724,11 +1723,6 @@ main (int argc, char **argv) globals_of_gfilenotify (); #endif -#ifdef HAVE_NS - /* Initialize the locale from user defaults. */ - ns_init_locale (); -#endif - /* Initialize and GC-protect Vinitial_environment and Vprocess_environment before set_initial_environment fills them in. */ -- 2.24.1 --------------9B8BB86E35BCD34A1C2EEB38--