twmode で (setq twittering-use-master-password t) として master
password を使っている皆さん。emacs を起動して最初の M-x twit で、認証デー
タを読み込んだ後に無限ループに入ってしまうという方はいらっしゃるでしょう
か。私はしょっちゅう起こっています。
無限ループになっても、C-g で中断すると認証済み情報がセットされて、もう
一度 M-x twit とすると問題なく使えるので、実用上は困ってなくてこれまでそ
うやって利用していたのですが、昨日業を煮やして調べてみたところ、一応ある
程度の原因はわかって修正もできたので、情報共有のため報告します。これが正
しい対処法なのかどうかもよくわかってないので、詳しい方からのご意見やご指
摘が頂けましたら幸いです。
(1) 無限ループは twittering-verify-credentials の中の
;; wait for verification to finish.
(twittering-wait-while nil 0.1
(and
(twittering-account-authorization-queried-p)
(twittering-process-alive-p proc)))
の箇所で起こっている。
(2) ここに debug code を挿入して、twittering-debug-mode をオンにして試し
てみたところ、無限ループの最中は (input-pending-p t) が t を返す状態
が続いていることがわかった。
(3) このためマクロ twittering-wait-while の展開結果に現れる sit-for が入
力待ちにならずに直ちに帰っている。その結果、バックグラウンドで呼んだ
curl の出力を emacs が受け取れる状態にならない(ここは推測。elisp
reference の「Output from Processes」の節に
Output from a subprocess can arrive only while Emacs is waiting: when
reading terminal input ... in `sit-for' and `sleep-for' ..., and in
`accept-process-output' (*note Accepting Output::).
とあることと、sit-for の実装を見ると (input-pending-p t) が non-nil
を返す時は実際に入力待ちを担っているらしき read-event まで処理が回ら
ずに終了してしまう所から見て、process の出力を受け取れる状態にならな
いまま sit-for が終わってしまっているっぽい)。
(4) そのため、curl が取得した認証確認情報が処理されたり、curl の process
が終了して status が変化するタイミングがないので、終了条件がみたされ
ずに無限ループとなる。
そこで、添付 patch のように、twittering-wait-while 中の sit-for を
sleep-forに置き換えて確実に待機を起こすようにしてみると、どうやらこちら
では問題はなく動作するようになりました(patch 中のもう1点の修正は、事情
がよく解ってなかった頃この辺りの処理を追っていて、「ここ無条件で認証成功
の結果を返しちゃまずいんじゃないの?」と思ってついでに入れたものです。何
か思い違いをしていたらすみません)。
ただ、「(input-pending-p t) がずっと t を返す状態になる」というのが正
しい動作なのかどうかはよくわかりません。ひょっとしたら emacs の bug だっ
たりコンパイルに失敗していたりするのかもしれず、そこら辺は判断できる知識
がないので、この sit-for→sleep-for という置き換えが本当に正しい処置なの
かどうかはイマイチ自信が持てない所です。
井汲 景太
--- twittering-mode.el-old 2014-04-22 16:42:24.000000000 +0900
+++ twittering-mode.el 2014-11-26 22:30:57.000000000 +0900
@@ -683,7 +683,7 @@
(current 0.0))
(while (and ,@(when timeout '((< current timeout)))
,condition)
- (sit-for interval)
+ (sleep-for interval)
(setq current (+ current interval)))
,(when (or form timeout-forms)
(if (null timeout)
@@ -6512,7 +6512,7 @@
10 0.1
(twittering-account-authorization-queried-p)
;; Succeeded in authorizing the account.
- t
+ (twittering-account-authorized-p)
;; Display a message.
(message
"Status of Authorization process is `%s'. Type M-x twit to retry."
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
twmode-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/twmode-users