-1

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.

3
  • 1
    What 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. Nov 16 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 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.
    – Roger
    Nov 16 at 22:06

2 Answers 2

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.

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))
2
  • 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.
    – Roger
    Nov 17 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 at 5:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.