emacs-devel
[Top][All Lists]
Advanced

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

RE: ffap bindings suggestion


From: Drew Adams
Subject: RE: ffap bindings suggestion
Date: Sun, 12 Feb 2006 09:34:45 -0800

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

No.

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

Sounds logical. I'd be interested in hearing about some of them, to learn.

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

OK. Your example below says it all anyway, I suspect. If you don't think it
does, and if you think of any keywords that might help to find the
discussion, let me know.

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

Thanks very much. I have no experience with keymap inheritance, and when I
read the doc I couldn't imagine how it might help here, because I needed to
change an existing keymap. This makes it clear (simply setq the existing
map - duh!).

I would still be interested in learning about some of the alternatives and
their relative advantages. If others are also interested and think the topic
is appropriate, that could take place here; if not, off-list works.

Thx.







reply via email to

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