[Top][All Lists]

[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: Joost Kremers
Subject: Re: How to bind a key locally to a buffer (not mode!)
Date: 19 Oct 2014 21:30:28 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Marcin Borkowski wrote:
> 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?

Define a minor mode that binds that key and only activate it in the
buffer you want it in.

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

I don't see why that wouldn't be elegant. IMHO it's more elegant than
defining a special minor mode for the sole purpose of being able to
return to the correct base buffer.

BTW, are you aware of the function `buffer-base-buffer'? It tells you
what the base buffer of an indirect buffer is. No need to mess with
buffer-local key bindings or buffer names or what have you... :-)

Joost Kremers                         
Selbst in die Unterwelt dringt durch Spalten Licht

reply via email to

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