reddit / emacs

Issue with umlauts in macOS

sudeenhux · 2022-03-27 08:50
I had originally posted this on r/spacemacs, but someone mentioned that it might be better addressed here. Thanks in advance for any thoughts! \*\*\* I've been using Spacemacs for a month or so and am really enjoying the experience. I originally wanted to learn Emacs because of Org-Mode, but have since started doing most of my writing in a markdown buffer using writeroom-mode, where I previously just wrote with Vim in a terminal. I'm using a standard US keyboard on a 2013 Macbook Pro (still going strong), but I use ä ü ö ß all the time. The situation is basically exactly what is outlined [in this older post](https://www.reddit.com/r/spacemacs/comments/60fl2w/how_to_type_umlauts_in_emacs_osx_usansi/). I have had the same key combinations baked into my fingers for years and I'd like to keep it that way. Right now, I have this in my user-config: (setq ns-alternate-modifier 'none ns-right-alternate-modifier 'meta) It works wonderfully, all good, I thought. But now at some point the umlauts go haywire: for example, ä eventually becomes \\303\\244 and I'm not sure what could be triggering the change or how to fix it. I get that it's UTF-8, but why it ends up like that in the first place is beyond me. Is there an obvious fix here or something that I'm missing? Thanks in advance for any input. UPDATE: The link that u/graduale posted ended up being super helpful, as it was indeed some sort of encoding issue having something to do with the existence of the "null-bytes" as discussed in that thread. Found them with C-s C-q C-SPC, got rid of them and using `revert-buffer-with-coding-system` cleaned everything up after I selected the encoding. And the change seems to be holding after restarting emacs completely as well. Thanks for the help!
holgerschurig · 2022-03-27 09:44
The plural is "Umlaute" :-)
0xMii · 2022-03-27 10:00
Is this a Spacemacs related issue specifically? I use Emacs with my own config on macOS and use Cmd for Meta and unbind Opt so I get the OS-level functionality and inputting special characters works just fine. (when (eq system-type 'darwin) (setq mac-option-modifier nil mac-command-modifier 'meta)) Try using the emacs-mac or emacs-plus builds instead of the normal one (both on homebrew) as they have some macOS-specific optimizations baked in. That might help as well.
graduale · 2022-03-27 16:25
What seems to be going on is that something is changing the encoding on your file. I had a similar issue and [this comment](https://reddit.com/r/emacs/comments/s82oet/_/htfv64i/?context=1) in response to my post was very helpful as it helped me figured out what I was doing that led to the file’s encoding changing from utf-8. (To see if the encoding is the problem, you can try calling `revert-buffer-with-coding-system`  and select utf-8.)
sudeenhux · 2022-03-27 17:10
This is all extremely helpful - I'll definitely go have a look and see if I can't backtrack to where the encoding gets changed. Thanks!
sudeenhux · 2022-03-27 17:12
I don't believe it's a Spacemacs-specific issue, but then again I didn't know there were different emacs builds I could be using - seems very promising.
sudeenhux · 2022-03-27 17:16
Yea yea, inter-language plurals are tricky ; - ) Almost jokingly convinced a colleague once that they had been using the plural wrong their whole life and that it's actually "Umläute."