all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Artur Malabarba <bruce.connor.am@gmail.com>
To: Marcin Borkowski <mbork@wmi.amu.edu.pl>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to bind a key locally to a buffer (not mode!)
Date: Mon, 20 Oct 2014 11:43:01 +0100	[thread overview]
Message-ID: <CAAdUY-+wvMeq-oH7nwN5h21Kz97wFXdHKimOgo8MThnYcx4e5Q@mail.gmail.com> (raw)
In-Reply-To: <87iojfok99.fsf@wmi.amu.edu.pl>

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


  parent reply	other threads:[~2014-10-20 10:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19 20:52 How to bind a key locally to a buffer (not mode!) Marcin Borkowski
2014-10-19 21:12 ` John Mastro
2014-10-20 10:43 ` Artur Malabarba [this message]
2014-10-20 12:16   ` Artur Malabarba
2014-10-20 14:02     ` Marcin Borkowski
     [not found] ` <mailman.11555.1413801786.1147.help-gnu-emacs@gnu.org>
2014-10-20 11:36   ` Pascal J. Bourguignon
2014-10-20 11:40 ` Stefan Monnier
     [not found] <mailman.11531.1413752320.1147.help-gnu-emacs@gnu.org>
2014-10-19 21:30 ` Joost Kremers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAdUY-+wvMeq-oH7nwN5h21Kz97wFXdHKimOgo8MThnYcx4e5Q@mail.gmail.com \
    --to=bruce.connor.am@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mbork@wmi.amu.edu.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.