@mathias Thanks for the link, I'm still confused, but it clarified a bit.
Do I understand correctly that the problem is you cannot refer to AltGr in emacs config? Or is AltGr always interpreted as Alt?
Yuri's response from that thread seems reasonable -- switching keyboard layouts should probably happen at the DM level, so the problem would be rather be that emacs is not suited to working with non-US keyboard layouts, right?
How do you work with this in vim? Do you just always keep one keyboard layout and everything works, or do you switch them?