emacs backspace question
atcs.matthew at gmail.com
Fri Mar 25 12:47:50 UTC 2011
On 03/24/2011 05:55 PM, Nerius Landys wrote:
>> I've read a lot on the internet regarding the use of the backspace key in
>> emacs, but the proposed solutions don't seem to be working for me.
>> I just installed FreeBSD 8.1 in Virtualbox and installed emacs 23.2.1 by
>> means of the package installer. Everything in emacs works great except the
>> backspace key, which deletes forward instead of back like it should. I've
>> found a lot of different things on the internet about it:
>> * switched to bash instead of csh - didn't fix it, but I like bash better
>> * M-x normal-erase-is-backspace-mode -toggling it once makes my backspace
>> bring up the "help" command; toggling it again changes it back
>> * different keymaps
>> - I started out using us.iso.kbd (which exhibits the backspace issue, but
>> other keys are right)
>> - I tried us.emacs.kbd - backspace works right, but many other keys are
>> mapped wrong (even letters and numbers)
>> - I tried us.unix.kbd - backspace doesn't work right and neither do my
>> control keys
>> I also just noticed that when on the command line itself (outside of emacs)
>> backspace deletes backward as it should, but so does delete!
>> Is this something weird with virtualbox, or am I doing something wrong?
> You have just discovered what is in my opinion a can of worms with no
> clear solution. I have struggled with issues such as these before,
> and I've managed to solve them more or less.
> Are you using emacs in a terminal window? (As opposed to with an X
> server.) I'm assuming yes.
In a terminal window, yes. I don't have X installed yet.
> Are you accessing your computer directly through the console or
> through an xterm and SSH, for example? Questions such as those are
> important to fully diagnose and fix the problem. You want to do an
> "echo $TERM" before you start diagnosing problems such as these.
If I ssh in, I don't have a problem. The only time I have a problem is
when I'm logging in directly; in that instance, my $TERM is "cons25".
> If you are using bash, you can do a "man bash" and look at the part
> that describes ~/.inputrc and/or READLINE. You may want to create an
> ~/.inputrc file and add stuff to it to resolve the backspace/delete
> issues that you are having. For example, I have the following in my
> ~/.inputrc because I do use bash occasionally:
> $if term=cons25
> "\x7f": delete-char
> $if term=xterm
> "\x1b\x5b\x35\x43": forward-word
> "\x1b\x5b\x31\x3b\x35\x43": forward-word
> "\x1b\x5b\x35\x44": backward-word
> "\x1b\x5b\x31\x3b\x35\x44": backward-word
I tried these values, but they didn't work for me. I'm installing vim
as we speak so I can use xxd as you indicated below to check what my
keys are putting out; I'll post back with my findings.
> "cons25" is the native FreeBSD console (like when you're physically at
> the computer console) and xterm is of course xterm. (Side note: Why
> in the heck on my 9.0-CURRENT system the system console says the TERM
> is xterm?)
That is odd indeed! It must have come in the xterm-nox11 port. ;)
> As far as how I came up with the strings such as "\x1b\x5b\x35\x43",
> you can use a command such as "xxd" which comes with the vim
> package/port to tell you what bytes are being sent when you press a
> certain key.
> If you want to fix your csh shell too, you may consider editing your
> ~/.cshrc file. Here is my complete ~/.cshrc, and note the stuff at
> the bottom with the key bindings:
> setenv EDITOR vi
> setenv PAGER less
> if ($?prompt) then
> # An interactive shell -- set some stuff up
> set prompt = "`whoami`@`/bin/hostname -s`> "
> set filec
> set history = 2000
> set savehist = 2000
> set mail = (/var/mail/$USER)
> if ( $?tcsh ) then
> bindkey "^W" backward-delete-word
> bindkey -k up history-search-backward
> bindkey -k down history-search-forward
> if ("$TERM" == "cons25") then
> bindkey "^?" delete-char
> else if ("$TERM" == "linux") then
> bindkey "^[[3~" delete-char
> else if ("$TERM" == "xterm") then
> bindkey "^[[3~" delete-char
> bindkey "^[[5C" forward-word
> bindkey "^[[1;5C" forward-word
> bindkey "^[[5D" backward-word
> bindkey "^[[1;5D" backward-word
> bindkey "\303\277" backward-delete-word
> By the way I have a 9.0 CURRENT box here at my desk, and I've compiled
> emacs-nox11 port, and I'm at the system console (meaning I'm
> physically at the console). I am using /bin/tcsh as my shell. I have
> no modifications to any of my dotfiles, they are all stock. In emacs,
> I'm able to use Backspace and Delete just as expected.
> Maybe you should try setting your default shell to /bin/tcsh, if it
> isn't already. If you're on a mission critical system you want your
> default shell to be part of the base system (as opposed to being a
> port), and the only clear choice for that is /bin/tcsh. Besides it's
> the default root shell too.
I tried /bin/tcsh to no avail, sadly.
> Also, if you are looking for a superior shell from ports you might try
> zsh. It's the best in my opinion.
I might give that a look!
More information about the freebsd-questions