I run Emacs on a Linux (actually Xubuntu 19.04) machine and my localization settings call for an Italian locale.

When generating timestamp, however, I'd like to have English months and weekday names. A quick look to the documentation gives the answer to this: set system-time-locale to "C" and that's all.

So I did and put

(setq-default system-time-locale "C")

in my ~/.emacs.d/init.el and everything worked, until I tried to run emacs as a daemon.

If I start emacs in daemon mode (either starting it from the command line or using systemd) and then connect to the server with emacsclient, the above setting is not taken into account: if I ask the value of the variable I get "C", sure enough, but if I try

(format-time-string "%Y-%m-%d %a %H:%M")

I get the weekday in Italian (as per the LC_TIME environment variable) If I then set system-time-locale to the value it apparently already holds by:

(setq-default system-time-locale "C")

then (format-time-string "%Y-%m-%d %a %H:%M") prints the weekday in English as expected.

What is even more weird, at least for me, is that once I did the above call to setq-default it start using the right locale in all the client frames. either existing or created afterward.

It should be noted too that if I start the server from a running emacs instance (by M-x server-start) then everything works fine so my problem do really appears to be connected with frame creation.

I solved my problem, sort of, by adding something like this

(lambda (&optional frame) (setq-default system-time-locale "C"))

to after-make-frame-functions but I don't really like this solution; among other things because the above code doesn't need to be called at each frame creation: doing it once would be enough.

So, where is the question in all this? There are two, in fact:

  1. why does the system-time-locale behave differently in server mode?
  2. Is there a better or best-practice way to set this variable when emacs run as a daemon?
  • I suggest you report this to M-x report-emacs-bug. – Stefan Jun 18 '19 at 12:46
  • Have you tried setting system-time-locale in your site-start.el file? This should be read at daemon start up. – nega Jun 24 '19 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.