Re: bind a complex key sequence?



"Cory T. Echols" <ctechols mindspring com> writes:

> On Fri, 02 Sep 2005 14:21:24 +0800, William XWL wrote:
>> I'm tring to bind key sequences like "C-c b", e.g,
>>
>>     (bind-keys global-keymap "C-c b" 'sawfish-ui)
>>
>> But apparently it doesn't work...
>
> You have to nest keymaps to create chained keybindings:
>
> (define example-keymap (make-keymap))
> (bind-keys example-keymap "b" 'sawfish-ui)
> (bind-keys global-keymap "C-c" example-keymap)
>
> The above is untested, but based on working code I have in my
> sawfishrc.  It would probably be simple enough to create a function that
> would handle nesting the keymaps for you, so that chained bindings could
> be defined like you want, but I've never gotten around to it.

Thanks. Yup, it does work. Seems my previous e.g. is not a good one. A
correct one:

(setq my-ctrl-c-keymap (make-keymap))
(bind-keys my-ctrl-c-keymap "b" 'maximize-window-fullscreen-toggle)
(bind-keys global-keymap "C-c" my-ctrl-c-keymap)

BUT ! Then i lose "C-c" prefix in Emacs ! sigh, i've to give up. 

-- 
William



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