You can't bind arbitrary key strings at the moment and it wouldn't work anyway because:
- The program must tell xterm to send these and tmux doesn't do this. - emacs only accepts the keys when TERM=xterm, not when TERM=screen. There has been some talk of supporting xterm modifyOtherKeys but so far nobody has done it. This diff will send the sequence to turn on modifyOtherKeys and pass C-Enter through which should be enough for you if you can persuade emacs to accept it inside tmux. However I'm not going to commit it as it is, because I think we need to a) support all the keys modifyOtherKeys affects, not just Enter b) only send them through to the terminal inside if the application has requested them with CSI 4;1m or CSI 4;2m and the xterm-keys option is enabled. If you feel like picking it up that would be great otherwise it'll have to wait til I get the time and inclination to finish it :-). diff --git a/input-keys.c b/input-keys.c index 0953ce7..1d75809 100644 --- a/input-keys.c +++ b/input-keys.c @@ -130,6 +130,9 @@ const struct input_key_ent input_keys[] = { { KEYC_KP_ENTER, "\n", 0 }, { KEYC_KP_ZERO, "0", 0 }, { KEYC_KP_PERIOD, ".", 0 }, + + /* xterm modifyOtherKeys keys. */ + { '\r'|KEYC_CTRL, "\033[27;5;13~", 0 }, }; /* Translate a key code into an output key sequence. */ diff --git a/key-string.c b/key-string.c index df17739..d646136 100644 --- a/key-string.c +++ b/key-string.c @@ -170,7 +170,7 @@ key_string_lookup_string(const char *string) } /* Convert the standard control keys. */ - if (key < KEYC_BASE && (modifiers & KEYC_CTRL)) { + if (key < KEYC_BASE && key != '\r' && (modifiers & KEYC_CTRL)) { if (key >= 97 && key <= 122) key -= 96; else if (key >= 64 && key <= 95) diff --git a/tty-keys.c b/tty-keys.c index 681f31b..08d846d 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -186,6 +186,9 @@ const struct tty_key_ent tty_keys[] = { { 0, "\033[6@", KEYC_NPAGE|KEYC_CTRL|KEYC_SHIFT,TTYKEY_RAW }, { 0, "\033[5@", KEYC_PPAGE|KEYC_CTRL|KEYC_SHIFT,TTYKEY_RAW }, + /* xterm modifyOtherKeys keys. */ + { 0, "\033[27;5;13~", '\r'|KEYC_CTRL, TTYKEY_RAW }, + /* terminfo lookups below this line so they can override raw keys. */ /* Function keys. */ diff --git a/tty.c b/tty.c index e810f36..49a469c 100644 --- a/tty.c +++ b/tty.c @@ -223,7 +223,7 @@ tty_start_tty(struct tty *tty) tty_puts(tty, "\033[?1000l"); if (tty_term_has(tty->term, TTYC_XT)) - tty_puts(tty, "\033[c"); + tty_puts(tty, "\033[c\033[>4;1m"); tty->cx = UINT_MAX; tty->cy = UINT_MAX; @@ -287,6 +287,9 @@ tty_stop_tty(struct tty *tty) if (tty_term_has(tty->term, TTYC_KMOUS)) tty_raw(tty, "\033[?1000l"); + if (tty_term_has(tty->term, TTYC_XT)) + tty_puts(tty, "\033[>4m"); + tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); } On Thu, Feb 14, 2013 at 10:50:11PM +0100, Csaba Andras wrote: > I use xterm. Without tmux emacs is able to tell the difference between > Enter and C-Enter. > > I couldn't use "cat" as you described to find out the code because cat > interpreted it as a line end. > > However I could figure out what is given to emacs by xterm with > "strace -v -e trace=read" > > Enter sends: read(3, "\r", 1) = 1 > C-Enter sends: read(3, "\33[27;5;13~", 10) = 10 > > This is not the only key combination which gets eaten by tmux. > I would prefer if tmux would send every sequence through if it was not > meant for tmux control. > If that's not possible do I have a chance to whitelist the sequences I > want to allow? > > Thx, > Csaba > > On Thu, Feb 14, 2013 at 11:47 AM, Nicholas Marriott > <nicholas.marri...@gmail.com> wrote: > > > > C-Enter doesn't send anything unique in most terminals, what does it > > send in yours outside tmux? Run "cat" then press C-Enter and tell me > > what you see. > > > > Also tell me what terminal you are using. > > > > > > On Tue, Feb 12, 2013 at 01:34:55AM +0100, Csaba Andras wrote: > > > Hi > > > Tmux doesn't forward a few keyboard combinations that I need for > > > org-mode > > > in emacs. > > > The first one is C-Enter (org-insert-heading-respect-content). > > > I've tried Bindkey :send-keys C-Enter but that doesn't work. > > > It seems to me that it is intentionally stopped. See this change > > > by*Micah > > > Cowan: > > > [1]http://sourceforge.net/mailarchive/message.php?msg_id=25446931 > > > Is there a workaround for me to get C-Enter working? > > > Cheers, > > > Csaba > > > > > > References > > > > > > Visible links > > > 1. http://sourceforge.net/mailarchive/message.php?msg_id=25446931 > > > > > ------------------------------------------------------------------------------ > > > Free Next-Gen Firewall Hardware Offer > > > Buy your Sophos next-gen firewall before the end March 2013 > > > and get the hardware for free! Learn more. > > > http://p.sf.net/sfu/sophos-d2d-feb > > > > > _______________________________________________ > > > tmux-users mailing list > > > tmux-users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/tmux-users > > ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users