Hi I'd like to change the key mappings slightly in xfce4-terminal - or any terminal running under xfce4 X environment.
In particular, I want to make ctrl-backspace and meta-backspace delete the last word, and ctrl-delete and meta-delete delete the next word.
Progress so far: I'm using bash, and bash uses the the readline library and a bash built-in function, "bind," to map key sequences to readline functions. The functions I need turn out to be "shell-kill-word" and "shell-backward-kill-word." In principle, I should be able to do something like this:
"\C-Rubout":shell-backward-kill-word
"\C-Delete":shell-kill-word
"\M-Rubout":shell-backward-kill-word
"\M-Delete":shell-kill-word
However, the xfce4-terminal emulator, or some component higher upstream in the process (could it be the window manager, xfwm4, the Xorg program itself?) is not cooperating. In general, the meta key is translated to an Escape character, for example this works:
"\ey":shell-kill-word <-- Meta + y kills next word
but with the the backspace and delete keys I'm out of luck. I tested the keycodes from two terminal emulators, xfce4-terminal and xterm, generated by backspace and delete and control-key combinations on my keyboard. Here they are, as reported by emacs's C-h C-l command:
xterm:
backspace: DEL
delete: \e[3~
\C-backspace: \C-h
\C-delete: \e[3;5~
\M-backspace: y-umlaut (y with two dots over it)
\M-delete: nothing
xfce4-terminal:
backspace: DEL
delete: \e[3~
\C-backspace: DEL
\C-delete: \e[3;5~
\M-backspace: \e DEL
\M-delete: nothing
In particular, in xfce4-terminal it is impossible to bind \C-backspace to shell-backword-kill-word because it sends the exact same keycode as a regular backspace. And it's impossible to bind \M-delete to shell-kill-word because it doesn't send a keycode at all.
Unfortunately I am not an expert on the X windowing system. Can someone with more knowledge of the Xorg ecosystem point me in the right direction? Perhaps there is an alternative terminal emulator that does this better? I am running a current Debian distribution which has the xfce4 window manager and Xorg.
I find it almost inconceivable that getting this behavior would not be possible with the latest Linux software and a typical, modern computer setup. Is it really the case?
Final piece of info: running emacs in an X window, it gets all but one of the keycodes correctly:
backspace: <backspace>
delete: <delete>
\C-backspace: <C-backspace>
\C-delete: <C-delete>
\M-backspace: <M-backspace>
\M-delete: nothing
Well, I had to ditch xfce4-terminal, because keybindings were a nightmare, and go back to xterm. I actually prefer having several windows to tabs anyway, it turns out. Here is what I did for keybindings for xterm<-->bash
The only one I'm missing is meta-delete... what can you do.