unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Sparse key maps garbage?
Date: Mon, 01 Sep 2008 09:34:29 +0200	[thread overview]
Message-ID: <48BB9B05.1000500@gmail.com> (raw)
In-Reply-To: <jwvd4joa81h.fsf-monnier+emacs@gnu.org>

Stefan Monnier wrote:
>>>>> Depends how you define "un define a key".  Binding it to nil is such
>>>>> a way.  Binding it to `undefined' is another.  Removing the binding from
>>>>> the keymap is yet another (one that does not come with a ready-to-use
>>>>> function for it).
>>>> I am thinking of the last case. Shouldn't there be one for this case?
>>>> Using exactly the same parameters as define-key (minus the binding)?
>>> What do you need it for?
> 
>> I have no need for it now.
> 
> Thought so.  That's the reason why it doesn't exist.
> 
>> It just came to my mind because Xah asked how
>> to undow a (define-key map [remap ...] ...) binding.
> 
> The answer is: (define-key map [remap ...] nil).
> 
> If you're worried that this will not quite undo it (i.e. in the case
> that map's parent already had a [remap ...] binding), then you need to
> do something like:
> 
>    (setq orig-map map)
>    (setq map (make-sparse-keymap))
>    (set-keymap-parent map orig-map)
>    (define-key map [remap ...] ...))
> 
> so that you can undo the binding(s) with
> 
>    (setq map orig-map)     

What Xah wanted was to remove some (define-key map [remap ...] ...)
bindings in an existing map. (Some map in cua-mode.)

This can not be done as above since you do not know for sure where that
keymap variable is used. You have to use your knowledge of the data
structures for sparse keymaps.

>> You can do that of course, but having an undefine-key make the data
>> abstraction (is it called so?) better.
> 
> `undo' is not the same as `undefine-key'.





  reply	other threads:[~2008-09-01  7:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30 23:44 Sparse key maps garbage? Lennart Borgman (gmail)
2008-08-31  6:18 ` Stefan Monnier
2008-08-31 12:17   ` Lennart Borgman (gmail)
2008-08-31 12:55     ` Stefan Monnier
2008-08-31 13:05       ` Lennart Borgman (gmail)
2008-08-31 18:19         ` Stefan Monnier
2008-08-31 20:09           ` Lennart Borgman (gmail)
2008-09-01  3:00             ` Stefan Monnier
2008-09-01  7:34               ` Lennart Borgman (gmail) [this message]
2008-09-01 18:25                 ` Stefan Monnier
2008-09-01 22:28                   ` Lennart Borgman (gmail)

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=48BB9B05.1000500@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).