开发者

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

开发者 https://www.devze.com 2023-03-11 17:36 出处:网络
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 c

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. Unfo开发者_运维技巧rtunately 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?


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消