From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Ben Barrowes Newsgroups: gmane.emacs.help Subject: how to switch to last visited buffer in other window ? Date: Wed, 26 Jan 2005 15:24:07 -0700 Message-ID: <41f81888$1_2@news3.es.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1106778895 26367 80.91.229.6 (26 Jan 2005 22:34:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Jan 2005 22:34:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 26 23:34:30 2005 Return-path: Original-Received: from mail-relay.eunet.no ([193.71.71.242]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ctvk5-0008Lt-00 for ; Wed, 26 Jan 2005 23:34:30 +0100 Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by mail-relay.eunet.no (8.13.1/8.13.1/GN) with ESMTP id j0QMYLda011703 for ; Wed, 26 Jan 2005 23:34:28 +0100 (CET) (envelope-from help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org) Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CtvsN-0004xR-Gt for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Jan 2005 17:43:03 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help Original-NNTP-Posting-Host: barrowes.lanl.gov Original-X-Trace: news3.es.net 1106778248 128.165.205.14 (26 Jan 2005 14:24:08 -0800) Original-Lines: 37 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!mpls-transit-01.news.qwest.net!feed.news.qwest.net!news3.es.net!not-for-mail Original-Xref: shelby.stanford.edu gnu.emacs.help:128167 Original-To: help-gnu-emacs@gnu.org 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: main.gmane.org gmane.emacs.help:23664 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:23664 When using emacs, I typically have 5 or so windows open in the same session. Is there any way to save the current buffer name into a register? or somewhere where I can get it back? At times, I would like to switch to a certain buffer with a name I know, say "*terminal*" or something, yank, and then return to the last visited buffer in the original buffer's window. The problem is, I don't specifically know the name of the original buffer... it could be any of the other 4 buffers I have open. I thought about saving the name of the buffer in the buffer-name-history and then return to the last visited: (lambda () (add-to-list 'buffer-name-history (abbreviate-file-name (buffer-name)))) ans call it whenever I (other-window 1), but this breaks down when I have visited a buffer more than once as (apparently) emacs won't insert the buffer-name into a list that contains that exact entry earlier in the list. Therefore, I can't return to the last visited buffer because that name is not necessarily the last in the list. Is there some excursion-type command I could use? My workaround at the moment is, in the original buffer to switch-to-buffer *terminal* (so that I have 2 windows pointing to the same buffer), yank into *terminal*, then bury-buffer. This seems inelegant. Any other way to do it? Thanks, Ben Barrowes