From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: saneman Newsgroups: gmane.emacs.help Subject: Re: Problems with 'd' and 'delete' key Date: Mon, 21 Apr 2008 09:25:32 +0200 Organization: SunSITE.dk - Supporting Open source Message-ID: <480c4125$0$90272$14726298@news.sunsite.dk> References: <480b5838$0$90267$14726298@news.sunsite.dk> <87ve2cwopo.fsf@hubble.informatimago.com> <480b6047$0$90263$14726298@news.sunsite.dk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1208763649 8472 80.91.229.12 (21 Apr 2008 07:40:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2008 07:40:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 21 09:41:21 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JnqeO-0003EI-EH for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2008 09:41:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jnqdj-0005S3-2X for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2008 03:40:39 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!goblin2!goblin.stu.neva.ru!news.net.uni-c.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail User-Agent: Thunderbird 2.0.0.12 (X11/20080227) Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 48 Original-NNTP-Posting-Host: 130.225.245.182 Original-X-Trace: news.sunsite.dk DXC=fGQV66ZSG2O3j@n`X75YjCYSB=nbEKnkKTekT_m2IJNJ?aXA8:Q5; kBS9o\hBcjVoOMSgY1MOWN]KWRJl7Q2_\KL]c]\NRZG[FD Original-X-Complaints-To: staff@sunsite.dk Original-Xref: shelby.stanford.edu gnu.emacs.help:158074 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:53440 Archived-At: djfiander wrote: > On Apr 20, 11:26 am, saneman wrote: >> Pascal Bourguignon wrote: >>> saneman writes: >>>> (global-set-key "\C-d" 'comment-dwim) >>>> (define-key function-key-map [delete] [deletechar]) >>>> But delete still inserts a comment instead of deleting a character. >>> That's strange. The doc of define-key doesn't mention vectors for >>> the def argument. > > Well, I just switched to Emacs and hit C-h k [delete] and was informed > that > > C-d (translated from ) runs the command delete-char > > (Personally, I also question the wisdom of remapping a very basic > control character, but let's leave that aside.) > > [delete] is translated to C-d by the function-key-map. See also the > comment in bindings.el: > > ;; Don't do this. We define in function-key-map instead. > ;(define-key global-map [delete] 'backward-delete-char) > > So, in order for everything to work the way you want, you need to put > this partially untested code in your .emacs file > > ;; define [delete] in global-map with what it would be if it weren't > being mapped by the function-key-map > (let ((delete-mapping (lookup-key function-key-map [delete]))) > (when delete-mapping > (define-key global-map [delete] (lookup-key (current-global-map) > delete-mapping)))) > > ;; Assuming you have the delete mapping defined above, you don't > really need to do this, it looks like > (define-key function-key-map [delete] nil) > > (global-set-key "\C-d" 'comment-dwim) > > But don't. Really. It almost seems to work. But when I press delete it works as backspace (deleting backward). Is there someway to get the normal delete key behavior where the cursor don't move but deletes characters in front? I think the command is called delete-char but where should it be added?