help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to bind a key locally to a buffer (not mode!)


From: Stefan Monnier
Subject: Re: How to bind a key locally to a buffer (not mode!)
Date: Mon, 20 Oct 2014 07:40:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> I'd like to bind a key in /one buffer/ only, so that the rebinding does
> not affect other buffers in this mode.

As mentioned, you can use a minor mode for that (and only enable it in
the current buffer).  If you want this binding to have lower precedence
than the minor mode, you can use something like:

    (use-local-map (make-composed-keymap nil (current-local-map)))
    (local-set-key ...)

Where the first line changes the local map in the current buffer to use
a fresh new keymap which inherits from the previous one (the previous
one is assumed to be the one set by the major mode).


        Stefan




reply via email to

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