From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.help Subject: Re: How to bind a key locally to a buffer (not mode!) Date: Mon, 20 Oct 2014 11:43:01 +0100 Message-ID: References: <87iojfok99.fsf@wmi.amu.edu.pl> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1413801800 29200 80.91.229.3 (20 Oct 2014 10:43:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Oct 2014 10:43:20 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 20 12:43:19 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XgAQp-00053R-8T for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Oct 2014 12:43:19 +0200 Original-Received: from localhost ([::1]:43882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgAQo-0005yW-UH for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Oct 2014 06:43:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgAQa-0005wX-6h for help-gnu-emacs@gnu.org; Mon, 20 Oct 2014 06:43:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgAQY-0006ob-3y for help-gnu-emacs@gnu.org; Mon, 20 Oct 2014 06:43:04 -0400 Original-Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:56318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgAQX-0006oB-Ri for help-gnu-emacs@gnu.org; Mon, 20 Oct 2014 06:43:02 -0400 Original-Received: by mail-oi0-f53.google.com with SMTP id v63so3391554oia.40 for ; Mon, 20 Oct 2014 03:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=O5Kcs90U+74dqpTBRRoOZfenXJgtfEVpw81I+0o6/Tw=; b=mR2j8uvmhYu5lApXY6lCkLwUjkt9vbKrtDBNn5Up9uH31QvRtILjgTAvDgCY6nuH3q kjU5qxOxpnj4erQr2yZ1hSKu5GZj6uAwA2QV49rSKtjh8O8rtuQwK3o93Hq/O9wJvgjJ qBABfHtx/bZ947wWrK6dlSOtLNhZZWVlmG3wg2vv54FLhLPqz71ypwybI4oSueYGVL4p 7krqIvGTzASw4fPd85rDf4mCyiO4RkXaKkwB7fpj38G8UxYDsNI3I9w0kyc2t1b+Lr5x RWjn4Oe3a9juk1ogTYj2Qg5+MzIyO8at0RHMXocN68cNwlbChTS4vgcakLrxMiaN0UAo nAPw== X-Received: by 10.60.244.227 with SMTP id xj3mr1356997oec.46.1413801781149; Mon, 20 Oct 2014 03:43:01 -0700 (PDT) Original-Received: by 10.76.1.137 with HTTP; Mon, 20 Oct 2014 03:43:01 -0700 (PDT) Original-Received: by 10.76.1.137 with HTTP; Mon, 20 Oct 2014 03:43:01 -0700 (PDT) In-Reply-To: <87iojfok99.fsf@wmi.amu.edu.pl> X-Google-Sender-Auth: pSXNGIAPHxFCwJaUK2fNu8HWPh8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::235 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100508 Archived-At: > 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.