Get result back from comint-redirect-send-command

527 Views Asked by At

I want to read the output of a buffer after process started by comint finishes.

(comint-redirect-send-command-to-process 
                 command-string ;; tested to work in the commint buffer
                 output-buffer-name ;; random text
                 buffer-process ;; (get-buffer-process (current-buffer))
                 nil ;; don't echo input back
                 t) ;; don't show output buffer immediatly

This sexp is evaluated in a buffer running a comint process. I want to read all the text of output-buffer-name once the process has finished.

I have tried applying the solution posted to this question: sleep in emacs lisp by adding this below the process start command:

(defun on-status-change (process status)
        (message "status done"))

(set-process-sentinel buffer-process 'on-status-change)

This message does not appear in *Messages*.

There is no prompt in the output-buffer text, but I can write a function that returns t when the output is finished based on the full output text.

How can I react to the buffer finishing/changing, or how can I force comint to run this function synchronously.


The source for comint-redirect-send-command-to-process is here on line 3717

1

There are 1 best solutions below

1
On

If anyone else has a similar issue, I ended up "solving" this.

(while (not comint-redirect-completed)
  (sleep-for 0.01))

comint-redirect-completed’s value is nil

Documentation: Non-nil if redirection has completed in the current buffer.

Obviously not a great solution, but I couldn't get anything else working.