[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to bind a key locally to a buffer (not mode!)
From: |
Marcin Borkowski |
Subject: |
How to bind a key locally to a buffer (not mode!) |
Date: |
Sun, 19 Oct 2014 22:52:02 +0200 |
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?
The rationale is that I'd like to have a command which makes an indirect
buffer of the current buffer and sets it into another mode; I'd like to
have then a command (bound to some key) which would kill that buffer
and select the base one back. I /could/ also make this command
determine the base buffer based on the indirect buffer name (which I
derive from the bas buffer name by means of something like
(concat (buffer-name (current-buffer)) "-some-postfix")
but this doesn't seem too elegant.
Any hints?
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University