]> git.eshelyaron.com Git - emacs.git/commitdiff
Tweak tq queue processing
authorAndreas Politz <politza@hochschule-trier.de>
Sat, 3 Aug 2019 14:33:06 +0000 (16:33 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 3 Aug 2019 14:33:06 +0000 (16:33 +0200)
* lisp/emacs-lisp/tq.el (tq-process-buffer): Pop the queue before
calling the function because the function may add new entries to
the queue (bug#19016).  Also report errors.

lisp/emacs-lisp/tq.el

index 4249305feee1ad2d104bc7be24a5766ada1dcab8..a8c7e892893f8a0e31136e3f29dca87c50fcf0eb 100644 (file)
@@ -153,15 +153,18 @@ This produces more reliable results with some processes."
                     (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))))
+             (let ((answer (buffer-substring (point-min) (point)))
+                    (fn (tq-queue-head-fn tq))
+                    (closure (tq-queue-head-closure tq)))
                (delete-region (point-min) (point))
-               (unwind-protect
-                   (condition-case nil
-                       (funcall (tq-queue-head-fn tq)
-                                (tq-queue-head-closure tq)
-                                answer)
-                     (error nil))
-                 (tq-queue-pop tq))
+                ;; 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))))))))
 
 (provide 'tq)