emacs-devel
[Top][All Lists]
Advanced

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

Re: Sparse key maps garbage?


From: Lennart Borgman (gmail)
Subject: Re: Sparse key maps garbage?
Date: Mon, 01 Sep 2008 09:34:29 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666

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

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