help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to switch to last visited buffer in other window ?


From: Ben Barrowes
Subject: how to switch to last visited buffer in other window ?
Date: Wed, 26 Jan 2005 15:24:07 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]