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

Re: w3m-process-wait-discard-input



;; namazu.org の復旧に尽力してくださっているみなさん、ありがとう
;; ございます。何も力になれなくて申し訳無いです。

>>>>> In [emacs-w3m : No.06309] 白井秀行さん wrote:

土> w3m-process-wait-discard-input の用途は何なんでしょうか?

> 不具合を説明すると mew-shimbun で記事を fetch 中になにかしらのキー
> を押すと w3m-process-wait-process() がおかしくなり、タイムアウト
> でしか抜けなくなりました。async-exec 以前はたしか process 処理自
> 体はちゃんと継続していたと思います。

これに関連した話を Elips で続けていました。Gnus で複数の shimbun
グループの新着記事を調べているとき、Emacs 21.x のエコーエリアに
経過を報告するメッセージが現れない問題があります。

;; 応答が遅い新聞社のサーバーに接続しているときは、待っていると
;; きに Emacs にメッセージを出すくらいの芸をやっていて欲しい。:p

記事は以下の url にあります。ただし、これを書いている時点ではサー
バーが止まっているようですが。^^;;

http://heimat.jp/~nakaji/elips/20040526/5189.html
http://heimat.jp/~nakaji/elips/20040526/5190.html
http://heimat.jp/~nakaji/elips/20040526/5191.html
http://heimat.jp/~nakaji/elips/20040526/5194.html

> mew-shimbun で fetch 中はユーザはなにもできない(同期式と同等)
> ので、キー入力も無視してよかろうということで mew-shimbun から
> process を動かすときだけ w3m-process-wait-discard-input を t に
> 束縛してキー入力を捨てています。

キー入力を無視するのは同じなんですが、w3m-process-wait-process()
を書き換えてみました。いかがでしょう?

(defun w3m-process-wait-process (process seconds)
  "Wait for SECONDS seconds or until PROCESS will exit.
Returns the exit status of the PROCESS when it exit normally,
otherwise returns nil."
  (catch 'timeout
    (let ((start (current-time)))
      (while (or (and (prog2
			  (discard-input)
			  (not (sit-for 1))
			(discard-input))
		      ;; Some input is detected but it may be a key
		      ;; press event and should be ignored when the
		      ;; process is not running.
		      (memq (process-status process) '(open run)))
		 (memq (process-status process) '(open run stop)))
	(and seconds
	     (< seconds (w3m-time-lapse-seconds start (current-time)))
	     (throw 'timeout nil)))
      (process-exit-status process))))
-- 
Katsumi Yamaoka <yamaoka@jpl.org>