@@ -147,11 +147,30 @@ HPTYPE is the result of calling `'haskell-process-type`' function."
147147 (replace-regexp-in-string " \4 " " " response))))))
148148
149149(defun haskell-process-log (msg )
150- " Write MSG to the process log (if enabled)."
150+ " Effective append MSG to the process log (if enabled)."
151151 (when haskell-process-log
152- (with-current-buffer (get-buffer-create " *haskell-process-log*" )
153- (goto-char (point-max ))
154- (insert msg " \n " ))))
152+ (let* ((append-to (get-buffer-create " *haskell-process-log*" ))
153+ (windows (get-buffer-window-list append-to t t ))
154+ move-point-in-windows)
155+ (with-current-buffer append-to
156+ (setq buffer-read-only nil )
157+ ; ; record in which windows we should keep point at eob.
158+ (dolist (window windows)
159+ (when (= (window-point window) (point-max ))
160+ (push window move-point-in-windows)))
161+ (let (return-to-position)
162+ ; ; decide whether we should reset point to return-to-position
163+ ; ; or leave it at eob.
164+ (unless (= (point ) (point-max ))
165+ (setq return-to-position (point ))
166+ (goto-char (point-max )))
167+ (insert " \n " msg " \n " )
168+ (when return-to-position
169+ (goto-char return-to-position)))
170+ ; ; advance to point-max in windows where it is needed
171+ (dolist (window move-point-in-windows)
172+ (set-window-point window (point-max )))
173+ (setq buffer-read-only t )))))
155174
156175(defun haskell-process-project-by-proc (proc )
157176 " Find project by process."
0 commit comments