Linux - GeneralThis forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Whenever I telnet or ssh to other computers on my lan, the backspace (left delete) key no longer works in emacs. Does anyone have any idea how I fix this?
I'm using OpenSSH_3.4p1 from the command line (protocols 1.5/2.0). I don't find any option which changes the mapping of the backspace key to anything in either the man pages, the info pages, or anywhere else I've looked. Anyway - it works from the commandline. Its only emacs which loses the backspace key across the ssh connection.
Thanks, I didn't know that one. But the terminal backspace is correct. Or at least, works correctly when operating the shell across ssh. What doesn't work right is the Backspace in Emacs operated across ssh on a remote machine. I don't see anything in the man pages which would remedy that.
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Thanked: 0
Right, the terminal accepts two commands as a "backspace", ^H or ^?. Emacs only accepts one. You can check which one emacs uses by hitting Ctrl-H or Ctrl-? while in emacs. One of them should act as a backspace. Use tset to set that command to be the backspace while you are logged in to the remote machine (that is, on the remote machine, run, for example, "tset -e ^H" ).
I had a similar problem where Perl would not accept the ^H (which is what the backspace key sends) as an erase character, but I could use the backspace key normally for most other uses. Using "tset -e ^H" solved that.
i had the same problem (backspace key works for the terminal session but not for emacs) and the tset -e fix didn't work for me, but I found a different workaround.
Adding this line to my .emacs, backspace does what it should w/in emacs:
(global-set-key "\C-h" 'backward-delete-char)
Anyway, hope that helps if there's anyone out there who ran into the same problem.
If, as mentioned in the post above, your backspace key is sending Ctl-?, rewrite the line as:
That might work. But the problem is with the Backspace key, not C-h. How do you designate the Backspace key in the lisp syntax? I tried [backspace] but it doesn't seem to like that.
i found that every time i used the backspace in emacs it brought up a help dialog saying "you've just hit control-h, etc." thus, i knew that in my case emacs was receiving backspace as control-h and so i just mapped backward-delete-char to that combination.
see what emacs says when you type backspace within it; that should give a clue to how your terminal is set up. whatever combination of keys emacs "receives" when you hit backspace (in my case control-h), map that to backward-delete-char and from then on backspace will behave properly in emacs.
the backspace key doesn't send a primitive "backspace", it send some combination of keystrokes that, for example, the terminal correctly interprets as "the command for backspace". if emacs isn't doing the same, that's probably because it's mapping the combination to some other command, like the worthless help dialog....
the nice thing about modifying your .emacs as a fix is you avoid introducing any weird side-effects outside of emacs. on the other hand it can seem kind of janky to use such a workaround. maybe fiddling w/ your terminal settings would be the cleaner solution. still, if you're impatient like me, the .emacs fix is very quick...
Thanks. I agree with sentiments about the solution being better localized to emacs. I'll give it a shot when I have access to the problem machine on monday. I don't have the problem here at home.
(defun fix-backspace ()
"Map control-h to work as backspace"
(interactive)
(keyboard-translate ?\C-h ?\C-?)
(global-set-key [(hyper h)] 'help-command))
This maps C-h to whatever C-? was already mapped to, so it plays nice with other customizations, and it gives you a new binding for help. Since some terminals give me trouble and some don't, I like having this as a callable command, rather than making it automatic.
Std. disclaimer: I don't think this was originally my idea, but I don't know where I got it from.
It happened to me a few days before. I use SecureCRT to SSH the server, but I found I chose Xterm in
Session Option > Terminal > Emulation. When I change it to VT100 and rerun it , it works normally.
I hope it's helpful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.