1
votes

I have configured Emacs to save my desktop when I close it, so that when I open it next all my buffers are reopened.

However my init.el splits the frame into three windows at startup, so I can view three buffers on the screen at the same time. The first window already shows the buffer I was last editing, but I would like the other two windows to show the second and third last files I was editing too.

I thought this would be possible using something like this:

;; Split into three equally sized windows
(split-window-horizontally)
(split-window-horizontally)
(balance-windows)

;; Load some buffers into the new windows
(other-window 1)
(next-buffer)                ; Shows *Messages* in both windows
;(previous-buffer)           ; same
;(switch-to-buffer 'nil t)   ; Shows same buffer in both windows
(other-window 1)
(next-buffer)
(previous-multiframe-window)
(previous-multiframe-window)

Unfortunately I can't find a command to select the buffer I want in each window. If I manually type C-x b RET in each window then it selects exactly the buffers I want (and they are different in each window), but I can't figure out how to replicate that behaviour as a command in init.el.

What am I doing wrong?

1

1 Answers

2
votes

If the window is selected then you can use

  (set-window-buffer (selected-window) "name of buffer")