# HG changeset patch # User Miles Bader # Date 1156675360 0 # Node ID e5542d6aad7fcb2c8f8c64faaa7a3bb09e542840 # Parent 98899ee691775035f038c0d799336c9f8441e23a Miscellaneous tq-related fixes. * lisp/emacs-lisp/tq.el: Small grammar fix in comments. (tq-enqueue): Check for existence of queue rather than the head queue item's question, which was a no-op. (tq-filter, tq-process-buffer): Make sure the process buffer exists before making it the current buffer. * lispref/processes.texi (Transaction Queues): Remove stray quote character. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-411 Creator: Michael Olson diff -r 98899ee69177 -r e5542d6aad7f lisp/ChangeLog --- a/lisp/ChangeLog Sun Aug 27 07:10:26 2006 +0000 +++ b/lisp/ChangeLog Sun Aug 27 10:42:40 2006 +0000 @@ -1,3 +1,11 @@ +2006-08-27 Michael Olson + + * emacs-lisp/tq.el: Small grammar fix in comments. + (tq-enqueue): Check for existence of queue rather than the + head queue item's question, which was a no-op. + (tq-filter, tq-process-buffer): Make sure the process buffer + exists before making it the current buffer. + 2006-08-27 YAMAMOTO Mitsuharu * term/mac-win.el (mac-apple-event-map): Rename hicommand to hi-command. diff -r 98899ee69177 -r e5542d6aad7f lisp/emacs-lisp/tq.el --- a/lisp/emacs-lisp/tq.el Sun Aug 27 07:10:26 2006 +0000 +++ b/lisp/emacs-lisp/tq.el Sun Aug 27 10:42:40 2006 +0000 @@ -66,7 +66,7 @@ ;; regexp: regular expression that matches the end of a response from ;; the process (defun tq-queue-head-regexp (tq) (car (cdr (car (tq-queue tq))))) -;; closure: additional data to pass to function +;; closure: additional data to pass to the function (defun tq-queue-head-closure (tq) (car (cdr (cdr (car (tq-queue tq)))))) ;; fn: function to call upon receiving a complete response from the ;; process @@ -119,7 +119,7 @@ the process has finished replying to any previous questions. This produces more reliable results with some processes." (let ((sendp (or (not delay-question) - (not (tq-queue-head-question tq))))) + (not (tq-queue tq))))) (tq-queue-add tq (unless sendp question) regexp closure fn) (when sendp (process-send-string (tq-process tq) question)))) @@ -131,35 +131,39 @@ (defun tq-filter (tq string) "Append STRING to the TQ's buffer; then process the new data." - (with-current-buffer (tq-buffer tq) - (goto-char (point-max)) - (insert string) - (tq-process-buffer tq))) + (let ((buffer (tq-buffer tq))) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (goto-char (point-max)) + (insert string) + (tq-process-buffer tq))))) (defun tq-process-buffer (tq) "Check TQ's buffer for the regexp at the head of the queue." - (set-buffer (tq-buffer tq)) - (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)))) - (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)) - (tq-process-buffer tq)))))) + (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)))) + (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)) + (tq-process-buffer tq)))))))) (provide 'tq) diff -r 98899ee69177 -r e5542d6aad7f lispref/ChangeLog --- a/lispref/ChangeLog Sun Aug 27 07:10:26 2006 +0000 +++ b/lispref/ChangeLog Sun Aug 27 10:42:40 2006 +0000 @@ -1,3 +1,8 @@ +2006-08-27 Michael Olson + + * processes.texi (Transaction Queues): Remove stray quote + character. + 2006-08-25 Richard Stallman * os.texi (Idle Timers): run-with-idle-timer allows Lisp time value. diff -r 98899ee69177 -r e5542d6aad7f lispref/processes.texi --- a/lispref/processes.texi Sun Aug 27 07:10:26 2006 +0000 +++ b/lispref/processes.texi Sun Aug 27 10:42:40 2006 +0000 @@ -1520,7 +1520,7 @@ If the argument @var{delay-question} is non-nil, delay sending this question until the process has finished replying to any previous -questions. This produces more reliable results with some processes." +questions. This produces more reliable results with some processes. The return value of @code{tq-enqueue} itself is not meaningful. @end defun