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

余生颓废 提交于 2019-12-07 01:25:26

问题


I've recently set up a Common Lisp programming environment in Mac OS X Leopard. One emacs module which I've found to be indispensable is paredit. Paredit is doing its part to help me wrangle my Lisp code more easily, but I've ran into a bit of a snare.

C-), bound to paredit-forward-slurp-sexp, is not forward slurping sexps but instead echoing the number 0. I'm using a Mac, alternating between iTerm and Terminal. The same problem is present in both apps.

I tried the same key combination in GNU Emacs' GUI version, and lo, it worked. Unfortunately the graphical version of Emacs does not satisfy my needs; I would like to keep using my iTerm based rig.

So I ask you, stackoverflow: what do I have to do to get the C-) combo to register with iTerm?


回答1:


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.




回答2:


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.




回答3:


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.



回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/6260754/just-getting-used-to-paredit-in-emacs-on-os-x-how-come-c-doesnt-work

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