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: djfiander
Subject: Re: Problems with 'd' and 'delete' key
Date: Sun, 20 Apr 2008 10:22:36 -0700 (PDT)
User-agent: G2/1.0

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.


reply via email to

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