NTEmacsのbatch/scriptモードでは、set-process-filterなどの非同期通信処理ができないみたい
WindowsでCaskが動作しないという問題を調査中に発見しました。
以下の内容をbatch-test.elとして保存し、
(defvar now-waiting nil) (defun test-proc-filter (proc res) (message "Catch Response!") (setq now-waiting nil)) (defun proc-tester () (message "Start Process!") (let ((proc (start-process-shell-command "*test*" nil "sleep 5; ls -l"))) (setq now-waiting t) (set-process-filter proc 'test-proc-filter) (while now-waiting (sit-for 1) (message "Wait!")))) (defun proc-tester2 () (message "Start Process!") (let ((proc (start-process-shell-command "*test*" nil "sleep 5; ls -l"))) (setq now-waiting t) (set-process-sentinel proc 'test-proc-filter) (while now-waiting (sit-for 1) (message "Wait!"))))
Ubuntuで実行すると、
~$ emacs -Q --batch -l batch-test.el -f proc-tester Start Process! Wait! Wait! Wait! Wait! Wait! Catch Response! Catch Response! Wait! ~$ emacs -Q --batch -l batch-test.el -f proc-tester2 Start Process! Wait! Wait! Wait! Wait! Wait! Catch Response! Wait! ~$
と期待通りの動作をしますが、
Windowsだと、 Catch Response! は出力されず Wait! が延々と出力され続けます。
困ります。何かご存知の方、情報プリーズです。
※ Emacsは GNU Emacs 24.2.1 (i386-mingw-nt5.1.2600) of 2012-12-08 on GNUPACK です。
※ Cygwinのシェルでもコマンドプロンプトでも同じでした。
※ scriptオプションでも同じでした。
※ 通常に起動させた後であれば、期待通りの動作をします。