(tq-filter): Add unwind-protect and save-match-data.
authorRichard M. Stallman <rms@gnu.org>
Sun, 15 Sep 1996 18:38:49 +0000 (18:38 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 15 Sep 1996 18:38:49 +0000 (18:38 +0000)
lisp/emacs-lisp/tq.el

index 8654e76..e0524bb 100644 (file)
@@ -87,10 +87,14 @@ that's how we tell where the answer ends."
 
 (defun tq-filter (tq string)
   "Append STRING to the TQ's buffer; then process the new data."
-  (set-buffer (tq-buffer tq))
-  (goto-char (point-max))
-  (insert string)
-  (tq-process-buffer tq))
+  (let ((old-buffer (current-buffer)))
+    (unwind-protect
+       (save-match-data
+         (set-buffer (tq-buffer tq))
+         (goto-char (point-max))
+         (insert string)
+         (tq-process-buffer tq))
+      (set-buffer old-buffer))))
 
 (defun tq-process-buffer (tq)
   "Check TQ's buffer for the regexp at the head of the queue."