I am using (display-buffer buffer)
and (pop-to-buffer buffer)
. The latter puts the cursor in the buffer. Although I want to show the buffer, I want to stay in the buffer I am working on rather than have pop-to-buffer
switch to another buffer.
Asked
Active
Viewed 40 times
-1
-
1What do you want to do with `pop-to-buffer` that `display-buffer` doesn't do? Most of the work of `pop-to-buffer` is to select the window that `display-buffer` found or created. – Gilles 'SO- stop being evil' Nov 16 '22 at 21:40
-
`(display-buffer buffer)` does what you requested: it displays `buffer` without selecting its window. But presumably you meant something else - unclear question. – Drew Nov 16 '22 at 21:44
-
The problem occurs when starting emacs. I get the scratch buffer, but the additional buffer does not show up below the scratch buffer. – Dilna Nov 16 '22 at 22:06
2 Answers
1
The problem occurs when starting emacs. I get the scratch buffer...
Use emacs-startup-hook
to run code after other startup activities (such as displaying the scratch buffer) have completed.

phils
- 48,657
- 3
- 76
- 115
0
Are you saying you have two windows open, and you're looking to change the buffer displayed in the inactive window?
This will do that:
(let ((original-window (selected-window))
(next-window (next-window)))
(select-window next-window)
(switch-to-buffer "new-buffer")
(select-window original-window))

zck
- 8,984
- 2
- 31
- 65
-
Because I call the function in my init file, I end up with emacs showing the created buffer. Would like that the scratch buffer shows up as the current buffer. Beneath it I get the new buffer. But control is still on the scratch buffer. – Dilna Nov 17 '22 at 11:41
-
I'm not especially sure what you're looking for. Can you give some more detail as to what's going on, and what you want? – zck Nov 18 '22 at 05:29