Taking advice from the manual as per this link:
I've created a filter for a process I'm running under emacs.
(defun ordinary-insertion-filter (proc string) (when (buffer-live-p (process-buffer proc)) (with-current-buffer (process-buffer proc) (let ((moving (= (point) (process-mark proc)))) (save-excursion ;; Insert the text, advancing the process marker. (goto-char (process-mark proc)) (insert string) (set-marker (process-mark proc) (point))) (if moving (goto-char (process-mark proc)))))))
When I run my process, by default it scrolls to fill the buffer and then continues to fill the buffer without tracking the end of the text.
If I make the process buffer my current buffer and then manually move the point to the end of the buffer then it does correctly track the text.
As per advice in the manual if I remove the
moving variable, then it will track the end of the buffer no matter what.
Ideally what I'd like is by default at the start it will track the buffer no matter what (just like removing
moving), and only if I move the point within the process buffer should it stop tracking. This is typical on other applications.
Logically I kinda expected the code to already do that. From initial conditions it looks like the point and the mark do not match in the buffer at the outset so I have to move to the buffer and force the point to the end to make this happen.
I've tried explicitly setting the marker and point outside the filter on process creation on the hope that would bring them into sync, but this doesn't work either
(set-marker (process-mark proc) (point)).
My original plan was to actually write some header text to the the process buffer before the process output - which may complicate matters further as then I've changed the mark value. However even without this complication the problem persists, so there must be something more fundamental I'm missing.
I'm using Emacs 26.2 in console mode.
My process is spawned over tramp using