1

If I type C-f paredit-forward-slurp-sexp, Emacs tells me the command is mapped to C-). Yet through C-h k I realized that both C-) and ) run evil-forward-sentence. If I do C-f evil-forward-sentence, Emacs tells me it is bound only to ).

If I evaluate (key-binding (kbd "C-)")) the result is paredit-forward-slurp-sexp. If I go through what describe-bindings prints, C-) is shown as associated with paredit-forward-slurp-sexp, There are other paredit associations in the listing, like M-<right arrow>, which works fine.

Why is this and how do I make the C-) behave the way I want.

user7610
  • 113
  • 5
  • 1
    On the topic of keyboard shortcuts in a terminal, see https://emacs.stackexchange.com/questions/5705/use-super-in-emacs-nw-in-linux and https://emacs.stackexchange.com/questions/977/shiftup-isnt-recognized-by-emacs-in-a-terminal – Gilles 'SO- stop being evil' Oct 16 '17 at 22:39

2 Answers2

4

Evil keymaps override the default global keymaps. To learn more, you may want to read:

If you want to override Evil keys, you'd need to do so to the Evil keymaps themselves:

(define-key evil-insert-state-map (kbd "C-)") #'paredit-forward-slurp-sexp)
(define-key evil-normal-state-map (kbd "C-)") #'paredit-forward-slurp-sexp)
(define-key evil-emacs-state-map (kbd "C-)") #'paredit-forward-slurp-sexp)
PythonNut
  • 10,243
  • 2
  • 29
  • 75
  • Evil does not define "C-)". It's that "C-)" gets interpreted the same way ")" does. I added more details to the question. – user7610 Mar 09 '15 at 12:26
  • @user7610 are you using Emacs in a terminal, or graphically? – PythonNut Mar 09 '15 at 16:57
  • You are right! C-) works in the GUI and not in terminal. Do you know why? – user7610 Mar 10 '15 at 09:51
  • 3
    @user7610 Yes. The short of it is that terminals have no way to express `C-)`. They lack the escape codes necessary to convey those keys to Emacs. You'll find that this is true of quite a few keybindings. Most `C-S-key` combos don't work. (Take `C-S-d`, which is passed as `C-d`). Long term, I'd recommend running the GUI version if you possibly can. Vim is a terminal editor that has a graphical mode. Currently, Emacs is a graphical editor that can run in a terminal. – PythonNut Mar 11 '15 at 02:16
0

As @PythonNut says in the comments below his or her answer, terminals don't have an escape code for C-). It is necessary to either remap to something like M-) or use Emacs GUI.

It can be quickly checked by pressing C-v (outside of Emacs) which makes the terminal print the escape sequence for the shortcut that follows. C-v C-) and C-v ) both print the same escape sequence, which happens to be a literal ).

user7610
  • 113
  • 5