Discussion:
Backspace problems in XTerm
Kumar Appaiah
2007-09-06 16:24:23 UTC
Permalink
Dear Mutt users,

Even after hours of Googling, I am unable to get this to work. So,
here's the deal:

1. Everything's fine, except that in the pager, if I press backspace,
it says key not bound. If I press Ctrl+H, it works as expected.
2. All other applications work fine; emacs -nw, vim etc.
3. So, in Mutt, I wish to bind my previous-line to Ctrl+H in the
pager. However, when I add bind \008 to previous-line, it still
doesn't work. When doing a "?", the binding displays as "^H" all
right, but below, it says <BackSpace> again, and my binding has no
effect.

Can you suggest an effective workaround? Using XTerm's "Backarrow Key"
fixes this, but it breaks all other apps, like emacs -nw, break.

Thanks!

Kumar
--
Kumar Appaiah,
458, Jamuna Hostel,
Indian Institute of Technology Madras,
Chennai - 600 036
Kyle Wheeler
2007-09-06 17:08:20 UTC
Permalink
Post by Kumar Appaiah
1. Everything's fine, except that in the pager, if I press backspace,
it says key not bound. If I press Ctrl+H, it works as expected.
Okay... all that means is that (probably) your backspace key isn't
emitting a ^H but is instead emitting a ^?. Some terminals do one
while some do the other. Xterm is convenient in that its easy to tell
it which one to emit. You can verify this by, in the shell (or
anywhere else) typing control-V and then pressing the backspace key.
Post by Kumar Appaiah
2. All other applications work fine; emacs -nw, vim etc.
Of course; probably because your stty settings define ^? to be the
"erase" character. In most cases, this is enough.
Post by Kumar Appaiah
3. So, in Mutt, I wish to bind my previous-line to Ctrl+H in the
pager. However, when I add bind \008 to previous-line, it still
doesn't work. When doing a "?", the binding displays as "^H" all
right, but below, it says <BackSpace> again, and my binding has no
effect.
This config line:

bind pager \008 previous-line

Binds the key sequence backslash-zero-zero-eight to previous-line. It
does not bind the key hexadecimal-eight to previous-line.

When you bind things, though, mutt ignores the terminal settings and
does exactly what you tell it to. In other words:

bind pager ^H previous-line

Will only bind ^H and not whatever your backspace key happens to be
emitting. If your backspace key is emitting ^?, then it's pretty
obvious why this command does not bind previous-line to the backspace
key.

Irritatingly, while the following *should* make mutt use whatever
character is currently the "erase" character, it doesn't. Sadly, it's
equivalent to the previous example:

bind pager <BackSpace> previous-line # this syntax should work
Post by Kumar Appaiah
Can you suggest an effective workaround? Using XTerm's "Backarrow Key"
fixes this, but it breaks all other apps, like emacs -nw, break.
The obvious workaround is to bind whatever your backspace key IS
emitting. E.g. this:

bind pager ^? previous-line

(note that you have to enter that in your muttrc by making sure the ^?
is not the two-letter sequence carrot-questionmark, but is the
single-character sequence that your delete key is emitting.)

~Kyle
- --
A wise man changes his mind, a fool never.
-- Spanish proverb
Kumar Appaiah
2007-09-06 17:37:09 UTC
Permalink
Post by Kyle Wheeler
Post by Kumar Appaiah
Can you suggest an effective workaround? Using XTerm's "Backarrow Key"
fixes this, but it breaks all other apps, like emacs -nw, break.
The obvious workaround is to bind whatever your backspace key IS
bind pager ^? previous-line
(note that you have to enter that in your muttrc by making sure the ^?
is not the two-letter sequence carrot-questionmark, but is the
single-character sequence that your delete key is emitting.)
Many thanks for the detailed response, and yes, your suggestion
handles my problem perfectly! :-)

Is there a way of directly entering ^? in an editor? Right now, I did
echo <Ctrl+V><BackSpace> > outfile, and copy pasted the contents of
outfile from emacs into my muttrc. Is there a better way?

Thanks again!

Kumar
--
Kumar Appaiah,
458, Jamuna Hostel,
Indian Institute of Technology Madras,
Chennai - 600 036
Kyle Wheeler
2007-09-06 17:36:23 UTC
Permalink
Post by Kumar Appaiah
Many thanks for the detailed response, and yes, your suggestion
handles my problem perfectly! :-)
Excellent!
Post by Kumar Appaiah
Is there a way of directly entering ^? in an editor? Right now, I did
echo <Ctrl+V><BackSpace> > outfile, and copy pasted the contents of
outfile from emacs into my muttrc. Is there a better way?
Of course! In most decent editors (including vim, which is the *most*
decent editor ;) ), you can do the same thing. In insert mode, type
<Ctrl+V><BackSpace>!

Hmmm, I wonder if that gets through email well... 

~Kyle
- --
We all grow up with the weight of history on us. Our ancestors dwell
in the attics of our brains as they do in the spiraling chains of
knowledge hidden in every cell of our bodies.
-- Shirley Abbott
Kumar Appaiah
2007-09-06 18:15:45 UTC
Permalink
Post by Kyle Wheeler
Of course! In most decent editors (including vim, which is the *most*
decent editor ;) ), you can do the same thing. In insert mode, type
<Ctrl+V><BackSpace>!
OK, so in GNU Emacs, you can do Ctrl+q Ctrl+?, i.e. C-q C-?.

Here is is: 

:-)

Kumar
--
Kumar Appaiah,
458, Jamuna Hostel,
Indian Institute of Technology Madras,
Chennai - 600 036
Nicolas Rachinsky
2007-09-06 21:50:37 UTC
Permalink
Post by Kyle Wheeler
Post by Kumar Appaiah
1. Everything's fine, except that in the pager, if I press backspace,
it says key not bound. If I press Ctrl+H, it works as expected.
Okay... all that means is that (probably) your backspace key isn't
emitting a ^H but is instead emitting a ^?. Some terminals do one
while some do the other. Xterm is convenient in that its easy to tell
it which one to emit. You can verify this by, in the shell (or
anywhere else) typing control-V and then pressing the backspace key.
Or by using <what-key> in mutt. AFAIK this is not bound by default,
but you can call it via
:exec what-key
in the index.

Nicolas
--
http://www.rachinsky.de/nicolas
Continue reading on narkive:
Search results for 'Backspace problems in XTerm' (Questions and Answers)
10
replies
What is AIX Box?
started 2006-05-08 15:58:44 UTC
hardware
Loading...