emacs-devel
[Top][All Lists]
Advanced

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

Re: ffap bindings suggestion


From: Stefan Monnier
Subject: Re: ffap bindings suggestion
Date: Sun, 12 Feb 2006 12:15:55 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> When minor mode is turned on:

>   (substitute-key-definition 'scroll-up 'foobar-cmd
>                              minibuffer-local-completion-map
>                              global-map)

> When it is turned off:

>   (substitute-key-definition 'scroll-up nil
>                              minibuffer-local-completion-map
>                              global-map)

> That's what I do: bind keys that are bound globally to `scroll-up' to
> `foobar-cmd' in minibuffer-local-completion-map. Then restore those
> keys to their original bindings in minibuffer-local-completion-map.

That looks OK.  Have you found a problem with it?

> I'm asking for a recommended way to accomplish this.

There are several ways to do it, each with some minor (dis)advantages, so
none of them are particularly more recommended.

>   I think you've already seen here some example code that modifies a
>   keymap and then restores the original one, using inheritance (so the
>   "save" and the "restore" of changed key-bindings are done in one
>   step each).
    
> Could you please point to that information (discussion). I searched
> for "inherit" + "map", but I didn't notice it.

Can't find it right now.  It was within last year.

> Again, the need is to modify an existing keymap (such as
> minibuffer-local-completion-map), not to use another keymap.
> Existing code expects to use the existing map.

Turn the mode on:

  (defvar orig-map nil)
  ...
  (let ((map (make-spare-keymap)))
    (set-keymap-parent map (set (make-local-variable 'orig-map)
                                minibuffer-local-completion-map))
    (substitute-key-definition 'scroll-up 'foobar-cmd map global-map)
    (setq minibuffer-local-completion-map map))

Turn it off:

  (setq minibuffer-local-completion-map orig-map)


-- Stefan




reply via email to

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