all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: djfiander <david@fiander.info>
To: help-gnu-emacs@gnu.org
Subject: Re: Problems with 'd' and 'delete' key
Date: Sun, 20 Apr 2008 10:22:36 -0700 (PDT)	[thread overview]
Message-ID: <e797ce75-1efe-474b-8780-ceb5c639f521@b1g2000hsg.googlegroups.com> (raw)
In-Reply-To: 480b6047$0$90263$14726298@news.sunsite.dk

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	other threads:[~2008-04-20 17:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-20 14:51 Problems with 'd' and 'delete' key saneman
2008-04-20 15:06 ` Pascal Bourguignon
2008-04-20 15:26   ` saneman
2008-04-20 17:22     ` djfiander [this message]
2008-04-21  7:25       ` saneman
2008-04-21  7:29         ` saneman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e797ce75-1efe-474b-8780-ceb5c639f521@b1g2000hsg.googlegroups.com \
    --to=david@fiander.info \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.