From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: How to bind a key locally to a buffer (not mode!) Date: 19 Oct 2014 21:30:28 GMT Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1413754527 26337 80.91.229.3 (19 Oct 2014 21:35:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Oct 2014 21:35:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 19 23:35:20 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 1Xfy8E-0002Ec-PJ for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Oct 2014 23:35:18 +0200 Original-Received: from localhost ([::1]:41213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xfy8E-0002i9-Aj for geh-help-gnu-emacs@m.gmane.org; Sun, 19 Oct 2014 17:35:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-X-Trace: individual.net 0c1ymz2U1goz4E7XYLrLpwIog/9tHzSeycbtWXOv6kdvVZe6Lg Cancel-Lock: sha1:64fYbmd8ZRRUwBy85Soc+MzunJs= Mail-Copies-To: nobody X-Editor: Emacs of course! User-Agent: slrn/pre1.0.0-18 (Linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:208229 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:100505 Archived-At: 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 joostkremers@fastmail.fm Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9)