Window scrolling after start-process and pop-to-buffer

Viewed 168

I'm trying to write a function that compiles some code, and if the compilation succeeds, it spawns the process and opens its output in a new window. The compilation bit works fine, but there's something weird going on with the second part. I wrote some code that looks like this:

(defun test-function ()
  (with-current-buffer (get-buffer-create "*output*")
    (erase-buffer)
    (start-process "echo" (current-buffer) "echo" "hi")
    (pop-to-buffer (current-buffer))))

This code almost works, but when it runs, the top of the screen seems to sit right below the actual output of the program. So, once echo quits, the screen looks like


Process echo finished

And scrolling up one line gives (the expected)

blah

Process echo finished

Is there a way to get it to start at the actual top of the buffer? I've tried things like scroll-up and goto-char before and after starting the process, but they don't seem to affect anything. From some other sources, it seems like I could attach a sentinel to the process and have it scroll up when there's output, but that seems like overkill just to scroll up at the beginning.

3 Answers
Related