I was trying to write a keyboard macro that included using grep and the first hit that it found.  The problem was that I had to wait for the grep to finish.  I'm not sure why but (sit-for 1) didn't work.

I started looking for a built in way to wait for an asynchronous command to complete and discovered that I had written one long long time ago in a galaxy far far away.

(defun wait-for-async-process ( proc )
  "Wait for PROC to finish"
  (while (null (eq (process-status proc) 'exit))
    (accept-process-output)))

I went ahead and looked for something like it in the distribution but didn't see it.

I'm curious if I overlooked it.

pedz