From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Peterson Newsgroups: gmane.emacs.help Subject: Re: How to toggle to buffer previously selected ? Date: Fri, 15 Feb 2008 05:32:22 -0800 Organization: University of California, Davis Message-ID: <877ih62vmh.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203084443 22974 80.91.229.12 (15 Feb 2008 14:07:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Feb 2008 14:07:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 15 15:07:46 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JQ1E7-0003mm-7P for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Feb 2008 15:07:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JQ1Dd-00072T-7J for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Feb 2008 09:07:13 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.news.ucla.edu!ucdavis!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: c-76-114-40-74.hsd1.ca.comcast.net Original-X-Trace: skeeter.ucdavis.edu 1203082288 26714 76.114.40.74 (15 Feb 2008 13:31:28 GMT) Original-X-Complaints-To: usenet@ucdavis.edu Original-NNTP-Posting-Date: Fri, 15 Feb 2008 13:31:28 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:4DOIyrxoaVxmhhDAwD6/f2O2Sdc= Original-Xref: shelby.stanford.edu gnu.emacs.help:156184 X-Mailman-Approved-At: Fri, 15 Feb 2008 09:06:58 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:51561 Archived-At: "Francis Moreau" on Thu, 7 Feb 2008 11:45:49 +0100 didst step forth and proclaim thus: > Hello all, > > I know 'C-x o' to select the next selected buffer but I'd like > to toggle between 2 buffers even if more than 2 buffers are > displayed. > > Thanks for your hints. > -- > Francis I think this *almost* does what you want. I think you may have trouble getting it to always swap between the last window you want, but experimenting with the code will likely prove fruitful. (defun go-back-window () (interactive) (if (boundp 'last-window) (progn (let ((mywindow last-window)) (setq last-window (selected-window)) (select-window mywindow))) (setq last-window (selected-window)) (select-window (next-window)))) (global-set-key "\C-cb" 'go-back-window) -- Sam Peterson peabodyenator@gmail.com "if programmers were paid to remove code instead of adding it, software would be much better" -- unknown