I have been using Emacs on a NixOS (Linux) machine running GNOME as a Desktop Environment. The hardware interface of this system is an American keyboard. Since I am Brazilian, it was necessary for me to have a Brazilian Portuguese input provided by GNOME.
Now, I have a new Macbook Air M1 which is a macOS machine also built with an American keyboard as hardware. After some hassles, I managed to find a way to generate Brazilian Portuguese characters, such as ç
, exactly, in the same way, concerning the keybindings on both the macOS and the NixOS machine. See more details here with my question and answer on the topic to illustrate what I mean.
Things have been working well. Exceptionally for some keys in Emacs. This is especially painful because I am a heavy user of Emacs.
Also, I have been using Emacs on both machines with the same configuration file.
One of my frustrations happens when I am typing things like "/". To generate this in an American keyboard with Brazilian Portuguese input, I need to press the right Option key (or the right Alt key in a non-apple keyboard) and the letter "q" on the keyboard.
(i) This keybinding works perfectly on NixOS outside of Emacs;
(ii) This keybinding works perfectly on NixOS also inside of Emacs with this Emacs init file;
(iii) This keybinding works perfectly on macOS outside of Emacs;
Unfortunately, this keybinding does not work on macOS inside of Emacs - even though the config file is the same!
After executing the describe-binding
(C-h k
) in Emacs, the mini-buffer asks for a binding: "Press key".
After replying with: "right-alt"-q
, I was expecting nothing to be returned, since letters and normal characters such as bar /
, vertical bar |
are not commands to be described. Unfortunately, I received:
paredit-reindent-defun is an interactive and byte-compiled function defined in paredit.el
This is not an isolated problem. It happens in other situations too. When trying to get the question mark ?
.
I am able to generate it in macOS outside of Emacs with Alt-right-w
. If I type the same thing in macOS inside of Emacs, the keybinding is associated with a command kill-ring-save
and not to the character question mark.
Some people suggested using this approach. It did not work out. Actually, it made several things stop working.
I must also highlight that I have started using a program called Karabiner-elements (before that I was using macOS to change a small subset of key modifiers, such as control<>caps_lock). This is my config file.
Is there a way to solve this?
How can I have the same Emacs in macOS with Portuguese input that I have in NixOS?
M-q
andM-w
. I think you need to read the Emacs manual where it talks about how Meta is assigned to a key on OSX. Incidentally, every “normal” key is bound to the commandself-insert-command
which inserts the character you typed into the buffer.self-insert-command
does not work for me to get/
and?
. The only way I could achieved was with my hack posted as a solution.