Emacs Ctrl modifiers don't work in console

后端 未结 3 1201
栀梦
栀梦 2021-01-19 14:21

I have 2 hotkeys for dired, that work in GUI mode in Emacs:

(add-hook \'dired-mode-hook
  (lambda ()
        (define-key dired-mode-map (kbd \"C-\"         


        
3条回答
  •  天命终不由人
    2021-01-19 14:48

    Your terminal likely doesn't produce different escape sequences for CTRL-right‬ versus just right.

    You can easily verify this by typing CTRL-v CTRL-right‬ and CTRL-v right‬. Here, CTRL-v tells the terminal to print the escape sequence for the key that follows. If these two produce the same sequences then your terminal sends the exact same information to Emacs whether you press CTRL or not.

    For instance, if I type these shortcuts in a Gnome terminal, I get:

    • ^[[C for CTRL-v right‬
    • ^[[1;5C for CTRL-v CTRL-right‬

    When I do the same on one of the Linux consoles, I get:

    • ^[[C for CTRL-v right‬
    • ^[[C for CTRL-v CTRL-right‬

    As you can see, in the latter case it's exactly the same result for both key sequences, hence there's no way Emacs can distinguish the two.

    The only way to fix this is to convince your terminal to send a different sequence when you hold down the CTRL key - see this question for more information.

    An easier work-around would be to simply use different key bindings in Emacs.

提交回复
热议问题