help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with 'd' and 'delete' key


From: saneman
Subject: Re: Problems with 'd' and 'delete' key
Date: Mon, 21 Apr 2008 09:25:32 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080227)

djfiander wrote:
On Apr 20, 11:26 am, saneman <d...@sdf.com> wrote:
Pascal Bourguignon wrote:
saneman <d...@sdf.com> 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 <delete>) 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 <delete> 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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]