From owner-freebsd-questions@FreeBSD.ORG Thu Mar 24 21:55:50 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2F46106566B for ; Thu, 24 Mar 2011 21:55:50 +0000 (UTC) (envelope-from nlandys@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 7AC478FC15 for ; Thu, 24 Mar 2011 21:55:50 +0000 (UTC) Received: by qwc9 with SMTP id 9so316696qwc.13 for ; Thu, 24 Mar 2011 14:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=slhLHe4Zs56qkvA4MZRb3/6CJMfzDouLB4hv72hjVqw=; b=nN8PvcS1SN+8N3NdSDhyBSQVkFwE+j8XZNA6m5oeKQ9lRm6h1ll9L3UqsRD/6ePXO3 VFfuznZw7qNaLEF+OGLQ28ufhLFSsTPM47fCHd556dGnmQmsntPRmY5Glvp/n6KAkyWy I/uKQh5NX5jjd6zjVgHQH/Ugsl5eztMbV150w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=KoXbxNRlu1LseQvZmFq+9SOdGKb0RX/8vZAVSaXIJoG7O9XoIFfe3aNIupTyVSHSfV XLaUbGg2ZylLuh+OEHaWdpMTfd2eQweAVEDln0XpbB+TNadqtmzg8m3l0WHKVfkwQQ7O Epq/A1JCyXsvJkbNH0ffM6fhYDdOFoEe6UBE4= MIME-Version: 1.0 Received: by 10.224.126.221 with SMTP id d29mr9594qas.201.1301003749564; Thu, 24 Mar 2011 14:55:49 -0700 (PDT) Received: by 10.224.37.66 with HTTP; Thu, 24 Mar 2011 14:55:49 -0700 (PDT) In-Reply-To: <4D8BB0F9.4080601@gmail.com> References: <4D8BB0F9.4080601@gmail.com> Date: Thu, 24 Mar 2011 14:55:49 -0700 Message-ID: From: Nerius Landys To: Matthew Morgan Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: emacs backspace question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2011 21:55:50 -0000 > 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. =A0Everything in emacs works great except= the > backspace key, which deletes forward instead of back like it should. =A0I= '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 > =A0 =A0- I started out using us.iso.kbd (which exhibits the backspace iss= ue, but > other keys are right) > =A0 =A0- I tried us.emacs.kbd - backspace works right, but many other key= s are > mapped wrong (even letters and numbers) > =A0 =A0- I tried us.unix.kbd - backspace doesn't work right and neither d= o my > control keys > > I also just noticed that when on the command line itself (outside of emac= s) > 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. 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 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=3Dcons25 "\x7f": delete-char $else $if term=3Dxterm "\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 $endif $endif "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?) 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 =3D "`whoami`@`/bin/hostname -s`> " set filec set history =3D 2000 set savehist =3D 2000 set mail =3D (/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" =3D=3D "cons25") then bindkey "^?" delete-char else if ("$TERM" =3D=3D "linux") then bindkey "^[[3~" delete-char else if ("$TERM" =3D=3D "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 endif endif endif 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. Also, if you are looking for a superior shell from ports you might try zsh. It's the best in my opinion.