2

A lot of times I have to change the input language of the keyboard (from English to a different one) causing the problem of the Emacs commands to not be recognized.

Normally when you press Ctrl+A you move to the beginning of the line. When I have a different language than English selected then it says "C-α undefined".

Is there a way to make them independent of the language selected? All editors support this by default so I am sure that there has to be a way.

I am using Ubuntu 16.04 and I installed Emacs through the terminal. It is the 24.5.1 version. I haven't configured the keyboard at all except having included one more language as a possible input.

Adam
  • 2,407
  • 2
  • 21
  • 38
  • 1
    It sounds like you are changing the keyboard layout *outside of Emacs* (ie, at the system level). If so, there's nothing Emacs can do about it, since it only sees the keys you send with the alternate layout. You can either redefine a lot of commands for both the English layout and whatever other layout you're using (miserable), or you can use Emacs's [input methods](https://www.gnu.org/software/emacs/manual/html_node/emacs/Input-Methods.html) like I'd suggested above. – Dan Mar 03 '17 at 22:24
  • @Dan Isn't this a little weird? Every editor understands the commands no matter which language the keyboard uses and the same goes for every program. It seems to me very peculiar that I have to do something like this. – Adam Mar 03 '17 at 22:26
  • I guess you expect key bindings to be on the same keys as if you were in a US layout? This is *not* obviously the right thing — for example, on an AZERTY or Dvorak keyboard, I would not expect Ctrl+key_right_of_caps_lock to go to the beginning of the line. For example, where would you type Alt+; — with the key right of Tab? with the key right of Λ? – Gilles 'SO- stop being evil' Mar 03 '17 at 22:29
  • No, I don't think it's weird. Emacs dates back to the 1970s, so there's a lot of functionality that differs from then up to now. It might be a different story if Emacs only had built-in keybindings, but since you can bind anything you want to almost any key combination you please, it's not obvious how to make that a seamless transition. From my experience, the input methods work quite well. I use it frequently, and don't have much cause to complain. (But then I live in Emacs, so I don't have to deal with any other program other than a web browser.) – Dan Mar 03 '17 at 22:35
  • @Gilles I get that but I don't understand why I have encountered this problem only on Emacs. It seems weird to not do automatically something that every program does by default. – Adam Mar 03 '17 at 22:35
  • @Dan I binded every command I needed from the start but then I worked on a new pc that didn't have my init file and wondered why I had to do something that no other program requires so I believed that I did something wrong myself. – Adam Mar 03 '17 at 22:38
  • By the way, your premise is false: *not* all editors pick up the change in keyboard layout at the system level. I just tried it with `nano` and `vim`. – Dan Mar 03 '17 at 22:39
  • @Dan Well I meant Atom, VS Code, Sublime, Notepad++, Gedit, etc. Also in my system nano recognizes the change in the keyboard and the commands work fine. – Adam Mar 03 '17 at 22:41
  • @Gilles The Ubuntu in the title I believe is misleading as I think the same happens on Windows too. The OS has nothing to do with this. – Adam Mar 03 '17 at 22:58
  • Different OSes handle keyboard shortcuts differently. Even if Emacs had a cross-OS solution, it would have to be implemented differently (unless the solution is an ad hoc mapping from Greek characters to Latin characters). Regarding other editors, nano does not translate key bindings, but probably the terminal emulator that it's running in does. – Gilles 'SO- stop being evil' Mar 03 '17 at 23:04

0 Answers0