Just getting used to paredit in emacs on OS X - how come C-) doesn't work?

喜你入骨 提交于 2019-12-05 04:55:31

IIRC, the modifier combination of Control and Shift cannot be sent to Emacs in a terminal. C-) requires the shift key, so it's out of bounds. I'm not convinced that any amount of terminal tweaking will change this.

I believe paredit-forward-slurp-sexp also gets bound to C-<right> by default, which should work fine in a terminal, so perhaps you can train your fingers to use that key instead.

For what is worth, on my Mac C-<right> and C-<left> are bound to Mission Control and move to the right and left spaces.

Having said that, C-Shift-<right> and C-Shift-<left> seem to do the trick and I can slurp and barf nicely on emacs with paredit.

Based on Cosmin's blog I got this to work in iTerm2.

  1. Open Preferences > Profiles > Keys. (You may want to copy the default profile and change the copy.)
  2. Click the + under the Profile Shortcut Keys:.
  3. Type Ctrl+) (ctrl+shift+leftparen).
  4. For the Action select Send Escape Character and
  5. put [1;5C in the text-box.

I have a hunch your iTerm / Terminal programs are not actually able to send C-), because there is no such character in ASCII and I am pretty sure there is no sequence for it on the VT100.

You can verify this for yourself, though. Run emacs in your terminal emulator. Type C-). Then type C-h l ("view-lossage"). This will show you the last few hundred keys that Emacs saw you type. Try the same thing after typing a non-control ) to see if they are different. If not, you are out of luck unless you can configure iTerm / Terminal to send them to Emacs in distinct ways.

That said, you can always bind some other key to paredit-forward-slurp-sexp.

Ian

I was running into the same kind of trouble with paredit's alternate C-<right> binding, and found tmux was causing my trouble - basically tmux was subsuming the C- and just passing along a <right>.

I found the solution at https://unix.stackexchange.com/a/34484, and it comprised adding

set-window-option -g xterm-keys on

to my ~/.tmux.conf.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!