The problem: When I type a non-ascii character, the character is not wrote and instead a weird key combination is performed, depending on which character I have typed, as if it didn't support utf-8. This strange behavior is true whether I:
- input non-ascii characters directly from my keyboard (such as the french letter
- create them with XCompose (such as
- input them using a different keyboard layout (I tried a chinese keyboard)
However, this only occurs when I use emacsclient in a terminal. If I start a fresh new emacs program, no problem. If I use emacsclient with GUI, no problem.
Restarting the emacs server doesn't change anything.
Besides that, emacsclient has no problem in reading or showing non-ascii characters (eg. I can open files that contain utf-8 characters and edit them).
What I tried: I tried setting
utf-8 from within an emacsclient session, and it works until I leave it. If I close the session, and open it again, it quits working, even though the server hasn't stopped.
I tried saving it into emacs' configuration via
customize, but it doesn't work: each time I close and re-open emacsclient, it comes back to
utf-8-unix, saying that it has been changed outside
customize (even though in
init.el the value is set to
I tried the same thing with emacs, and the same thing happens: I can change temporally the value, but when I restart it comes back to the original value. However, I am positively sure I don't overwrite
keyboard-coding-system in my configuration. To rule that out, I started emacs with
-q (which tells emacs not to read any configuration file, just start as-is), but it still had the value
CHANGED outside Customize.
To recap: changing
keyboard-coding-system temporarily solves the issue for emacsclient, but I can't make it definitive. And, I have no problem neither in emacs nor in emacsclient GUI with the default value for
This is especially problematic since my keyboard is full of non-ascii keys and each time I press them by mistake emacs runs commands (depending on which key I have pressed) which is very annoying.
Technical details: I have the same problem on several Linux distros, including a Debian which has emacs 26.1 and NixOS which has the latest stable emacs.
EDIT 1: A comment asked what
locale returned in the terminal in which I start emacsclient.
$ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME=fr_FR.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER=fr_FR.UTF-8 LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=