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: Artur Malabarba
Subject: Re: How to bind a key locally to a buffer (not mode!)
Date: Mon, 20 Oct 2014 11:43:01 +0100

> Hi all,
>
> (global-set-key ...)
>
> binds a key globally.
>
> (local-set-key ...)
>
> binds a key locally, i.e., in the current major mode.
>
> I'd like to bind a key in /one buffer/ only, so that the rebinding does
> not affect other buffers in this mode.  I could probably do it by
> defining a minor mode, which rebinds this key to a function, which runs
> a function set by a buffer-local variable, but this seems rather
> convoluted.  Is there a simpler way to achieve this?

There is, I used to do this in one of my org buffers. I forget the exact
code now, but I'll look for it.

You essentially split the current buffer's keymap from its major mode, and
then call local set key.


reply via email to

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