[Top][All Lists]

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

Re: Sparse key maps garbage?

From: Stefan Monnier
Subject: Re: Sparse key maps garbage?
Date: Sun, 31 Aug 2008 23:00:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>>>> 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)     

> 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 via email to

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