[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: start-process and set-process-filter sequence

From: Thien-Thi Nguyen
Subject: Re: start-process and set-process-filter sequence
Date: Thu, 14 Apr 2011 14:02:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

() William Xu <address@hidden>
() Thu, 14 Apr 2011 16:22:35 +0800

   if you try:

          (start-process "ls" "ls" "ls")
        (read-string "Mood: ")
        (set-process-filter (get-process "ls") 'foo)
        (setq a nil))

   There will still be a similar problem.  

Process output is distributed to filters when Emacs has nothing else
to do, such as when pausing for interaction (‘read-string’ et al).
(You can also explicitly request it via ‘accept-process-output’ but
that is not germane.)

So the best strategy is to not allow such pauses in the first place.
E.g., you could add an abstraction ‘start-filtered-process’ and make
sure you use ‘start-filtered-process’ everywhere you'd normally use
a naked ‘start-process’.

(defun start-filtered-process (filter &rest etc)
  "Like `start-process' with ETC, but associate FILTER as well.
Return the newly created process."
  (let ((proc (apply 'start-process etc)))
    ;; Note to programmer: Do NOT tickle Emacs I/O-wise, here.
    ;; [Insert ref to help-gnu-emacs thread, here.]
    (set-process-filter proc filter)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]