ergoemacs / ergoemacs-mode

ergoemacs-mode
ergoemacs.github.io/
GNU General Public License v3.0
293 stars 35 forks source link

Arrow keys return A B C D #280

Closed rainbyte closed 10 years ago

rainbyte commented 10 years ago

Hi.

I've installed ergoemacs-mode and arrow keys suddenly stopped working. They return characters A B C and D when are pressed.

Tested with konsole and gnome-terminal, on Arch Linux. I'm using emacs 24.3 with ergoemacs-mode 5.17.7.2.

mattfidler commented 10 years ago

Unfortunately, I can't test this. However, I belive I know the solution.

If you go to the *scratch* buffer and paste in the following:

(define-key ergoemacs-read-input-keymap (read-kbd-macro "M-O" t) 'ergoemacs-read-key-default)
(define-key ergoemacs-read-input-keymap (read-kbd-macro "M-[" t) 'ergoemacs-read-key-default)
(setq ergoemacs-read-emulation-mode-map-alist `((ergoemacs-read-input-keys ,@ergoemacs-read-input-keymap))

And then type QWERTY Alt+a eb Enter do the arrow keys work. If so, I will release a new version with the fix in place...

mattfidler commented 10 years ago

This should not occur unless you are running emacs in a terminal.

For your information, some of the ergoemacs-mode keys are masked by the terminal because the terminal cannot distingish them. (Ctrl+c and Ctrl+Shift+c are exactly the same in the terminal).

rainbyte commented 10 years ago

I've tested that piece of code, and now arrows are working fine. Can I set this on init.el? Or is better to wait for a new version?

Should I test other key combination?

rainbyte commented 10 years ago

As you said both, Ctrl+c and Ctrl+Shift+c, behave as Ctrl+c

mattfidler commented 10 years ago

I uploaded a new version to elpa, I will wait for the code review/scripts to run before 5.17.7.3 will be posted.

Terminals behave quite differently than GUI emacs:

http://ergoemacs.org/emacs/keyboard_shortcuts.html

In short any key in a terminal may misbehave if you define Alt+Shift+o or Alt+o or Alt+[ because terminals send ESC O or ESC [ for many many keys. ESC O is equavalent to Alt+Shift+O. Hence when pressing the arrow keys (which are ESC O A), emacs ran the key for Alt+O and then inserted A B or C D.

For a full list you could see something like xterm.el which shows the translations. You can see from the file that all the function keys use this as well.

;; xterm from X.org 6.8.2 uses these key definitions.
    (define-key map "\eOP" [f1])
    (define-key map "\eOQ" [f2])
    (define-key map "\eOR" [f3])
    (define-key map "\eOS" [f4])
    (define-key map "\e[15~" [f5])
    (define-key map "\e[17~" [f6])
    (define-key map "\e[18~" [f7])
    (define-key map "\e[19~" [f8])
    (define-key map "\e[20~" [f9])
    (define-key map "\e[21~" [f10])
    (define-key map "\e[23~" [f11])
    (define-key map "\e[24~" [f12])
mattfidler commented 10 years ago

So if you wish to test other keys, you could test the function keys.

Note that the ergoemacs-mode solution to this problem may cause slow connections like PuTTY to misbehave. Its based on a timer to distingush between the user pressing Alt+O or anything else.

balsoft commented 5 years ago

@mattfidler this happens for me with emacs 26.3 and ergoemacs 20181127.1330 . The snippet above doesn't seem to work.