Discussion:
tmux and emacs
Leigh Stoller
2014-10-18 00:25:45 UTC
Permalink
Hi there, I have a tmux+emacs problem. Two really. The first is the ^H vs
^? issue. I understand that I can bind erase to ^? on all my machines
(many, many), but I am curious as to why tmux generates ^D when I press the
delete key (bound to ^H). It is kinda strange since in this respect, the
xterm and screen terminfos look the same, I think.

The other is ^b in emacs; only every other ^b registers, the other is
ignored. Any ideas on this one?

Thanks very much!
Leigh
Balazs Kezes
2014-10-18 09:36:34 UTC
Permalink
Post by Leigh Stoller
Hi there, I have a tmux+emacs problem. Two really. The first is the ^H
vs ^? issue. I understand that I can bind erase to ^? on all my
machines (many, many), but I am curious as to why tmux generates ^D
when I press the delete key (bound to ^H). It is kinda strange since
in this respect, the xterm and screen terminfos look the same, I
think.
Hmm, that's interesting. I assume you are using xterm then? Have you
rebound any buttons via stty or xterm overrides?

For example I have the following xterm overrides in my .Xdefaults and
then customize each of my applications accordingly:

XTerm*VT100.translations: #override \n\
Ctrl<Key>BackSpace: string(0x08) \n\
Alt<Key>BackSpace: string("") \n\
<Key>BackSpace: string(0x7f) \n\
...

Maybe you could also customize your translations so that the keys
generate the sequences you want?

Also, what happens if you run "cat", press ^V Backspace, and then press
^V Delete. What codes were generated outside tmux and what inside tmux?
Post by Leigh Stoller
The other is ^b in emacs; only every other ^b registers, the other is
ignored. Any ideas on this one?
^b is the default prefix. All default tmux keybindings start with
pressing ^b first. You can change this to another button via the prefix
setting to something like ^a which is screen's default.
--
Balazs
Leigh Stoller
2014-10-18 14:38:36 UTC
Permalink
Post by Balazs Kezes
Hmm, that's interesting. I assume you are using xterm then? Have you
rebound any buttons via stty or xterm overrides?
Hi. I am not running X, it appears to be iterm2 default terminal
emulation. xterm-256color. So no xterm or X key binding overrides, and I
have not done any stty rebinds.
Post by Balazs Kezes
Also, what happens if you run "cat", press ^V Backspace, and then press
^V Delete. What codes were generated outside tmux and what inside tmux?
Outside both say ^H but inside both say ^?
Inside emacs, I get ^D for both. Really strange!
Outside emacs works fine.

stty key bindings:

discard dsusp eof eol eol2 erase erase2 intr kill
^O ^Y ^D <undef> <undef> ^H ^H ^C ^U
lnext min quit reprint start status stop susp time
^V 1 ^\ ^R ^Q ^T ^S ^Z 0
Post by Balazs Kezes
Post by Leigh Stoller
The other is ^b in emacs; only every other ^b registers, the other is
ignored. Any ideas on this one?
^b is the default prefix. All default tmux keybindings start with
pressing ^b first. You can change this to another button via the prefix
setting to something like ^a which is screen's default.
Ah, thanks.

I've been using X for about 30 years, but trying to convert to iterm2 and
tmux (but not with iterm2 tmux integration, I did not like that). But emacs
is essential, and I am very resistant to having to changes my stty keys or
termcap across many dozens of machines.

Version 2.0 of iterm2, 1.9a of tmux, OSX Mavericks, Freebsd running tmux.

Thanks for your help!
Leigh
Balazs Kezes
2014-10-19 18:50:16 UTC
Permalink
Post by Leigh Stoller
Post by Balazs Kezes
Also, what happens if you run "cat", press ^V Backspace, and then
press ^V Delete. What codes were generated outside tmux and what
inside tmux?
Outside both say ^H but inside both say ^?
Outside ^H and inside ^? sounds fine but it's bad if both backspace and
delete generate the same sequence because then the applications can't
distinguish them, right? For me in xterm the delete key generates
"^[[3~" which is what
infocmp xterm-256color | grep 'kbs\|kdch1'
would suggest. Do you happen to have a misconfigured iterm2? [1]
suggests that there is a "Delete sends Control-H" option. Try disabling
that.
Post by Leigh Stoller
Inside emacs, I get ^D for both. Really strange!
Outside emacs works fine.
I'm not familiar with emacs so I have not sure what went wrong there.
I think if whatever key you get for backspace matches up with what stty
reports for erase then that's rather an emacs bug if it can't parse it.
In any case try tweaking your emacs settings[2].
Post by Leigh Stoller
discard dsusp eof eol eol2 erase erase2 intr kill
^O ^Y ^D <undef> <undef> ^H ^H ^C ^U
lnext min quit reprint start status stop susp time
^V 1 ^\ ^R ^Q ^T ^S ^Z 0
Is this inside or outside tmux? If this is reported from inside then
something is wrong. Do you have any stty overrides in one of your shell
rc files somewhere?

[1] https://stackoverflow.com/questions/13017392/how-to-make-iterm2-send-control-h-for-backspace-so-it-works-for-all-linux-shells
[2] http://www.emacswiki.org/emacs/BackspaceKey
--
Balazs
Christian Ebert
2014-10-20 09:03:39 UTC
Permalink
* Leigh Stoller on Friday, October 17, 2014 at 17:25:45 -0700
Post by Leigh Stoller
Hi there, I have a tmux+emacs problem. Two really. The first is the ^H vs
^? issue. I understand that I can bind erase to ^? on all my machines
(many, many), but I am curious as to why tmux generates ^D when I press the
delete key (bound to ^H). It is kinda strange since in this respect, the
xterm and screen terminfos look the same, I think.
The other is ^b in emacs; only every other ^b registers, the other is
ignored. Any ideas on this one?
Related to
http://sourceforge.net/p/tmux/mailman/message/31923537/
ff.

I'd say; comes up now and then.
--
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions
Loading...