unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* switch/selecting buffers in frames/windows.
@ 2014-09-15  7:22 Eric Abrahamsen
  0 siblings, 0 replies; only message in thread
From: Eric Abrahamsen @ 2014-09-15  7:22 UTC (permalink / raw)
  To: help-gnu-emacs

Turns out buffer switching is hard...

First of all, I'm on 24.4 -- it looks like things have changed since
24.3.

When opening a Gnus link from Org, I'm trying to keep things a little
cleaner in terms of frame/window re-usage. I almost always have the Gnus
*Group* buffer already visible in one of my frames, and don't need to
re-display it in a new window. Additionally I have noticed weirdness if
I open a link to a message that's in a group whose *Summary* buffer is
already visible.

I'm falling down a bit with the difference between displaying and
selecting buffers. Here's my code as it stands. ('messages' is a list of
org links to Gnus messages. The links look like
GnusGroupName#Message-ID):

(let* ((link (org-link-unescape (car messages)))
	     (group (car (org-split-string link "#")))
	     (id (second (org-split-string link "#")))
	     (sum-buffer (gnus-summary-buffer-name group)))
	(if (gnus-buffer-exists-p sum-buffer)
	    (progn
	      (display-buffer sum-buffer nil t)
	      (gnus-summary-goto-article id nil t))
	  (when (gnus-buffer-exists-p gnus-group-buffer)
	    (display-buffer gnus-group-buffer nil t))
	  (org-gnus-open link))
          ;; Do things...
)

Hopefully the logic of what I'm after is clear from that.

This displays buffers correctly, but does not select them. That means
that, in the branches that include a call to `display-buffer', the code
immediately following is still executed in the frame that was originally
selected. 

The whole thing is hard to follow. There doesn't seem to be a
one-stop-shop that both displays and selects a buffer across frames, and
I suspect best practices are also an issue here -- I'd like to do this
right. `switch-to-buffer' would be the right thing, but it doesn't
appear to work across frames.

Can someone show me how to DTRT? This is actually Gnorb code that I
would like to work on both 24.3 and 24.4, so bonus extra gratitude to
anyone who can give me equivalent solutions for both versions...

Thanks!
Eric




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-15  7:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-15  7:22 switch/selecting buffers in frames/windows Eric Abrahamsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).