Function: tq-process-buffer

tq-process-buffer is a byte-compiled function defined in tq.el.gz.

Signature

(tq-process-buffer TQ)

Documentation

Check TQ's buffer for the regexp at the head of the queue.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/tq.el.gz
(defun tq-process-buffer (tq)
  "Check TQ's buffer for the regexp at the head of the queue."
  (let ((buffer (tq-buffer tq)))
    (when (buffer-live-p buffer)
      (set-buffer buffer)
      (if (= 0 (buffer-size)) ()
	(if (tq-queue-empty tq)
	    (let ((buf (generate-new-buffer "*spurious*")))
	      (copy-to-buffer buf (point-min) (point-max))
	      (delete-region (point-min) (point))
	      (pop-to-buffer buf nil)
	      (error "Spurious communication from process %s, see buffer %s"
		     (process-name (tq-process tq))
		     (buffer-name buf)))
	  (goto-char (point-min))
	  (if (re-search-forward (tq-queue-head-regexp tq) nil t)
	      (let ((answer (buffer-substring (point-min) (point)))
                    (fn (tq-queue-head-fn tq))
                    (closure (tq-queue-head-closure tq)))
		(delete-region (point-min) (point))
                ;; Pop the queue before calling the function because
                ;; the function may add new functions to the head of
                ;; the queue.
		(tq-queue-pop tq)
                (condition-case err
                    (funcall fn closure answer)
                  (error (message "Error while processing tq callback: %s"
                                  (error-message-string err))))
		(tq-process-buffer tq))))))))