はやみずです > twittering-show-minibuffer-length()がpost-command-hook経由で > 呼び出されるようになってから、tweet編集時のminibufferで > set-mark-command()によるmark有効化が働かなくなっていました。 > transient-mark-modeにしてもテキストを反転選択できません。
バグフィックスどうもありがとうございます。マージしました。Emacs23では発 生しないバグのようで、気が付いていませんでした。minibuffer-message が Emacs23 になったときにCからelispへと実装が変わっているので、振舞いも完 全には再現されていないようですね。 原因のほうはまだ完全に理解した気分にはなれていないのですが、 post-command-hook で (setq deactivate-mark t) するような処理 (minibuffer-message)を呼び出すと、なんか良くないことが起こる、というこ とですね。 で、良くないこととしては 1. deactivate-mark が毎回 t にされたらmarkを有効化できない 2. deactivateされるタイミングがずれる の2つが発生して、それぞれ 1. letで束縛して変更を局所化する 2. 自前で deactivate-mark を呼び出す として解決している、ということで正しいでしょうか。 # ミニバッファ周りの挙動は全然把握していないというか、ちゃんとやろうとす # ると面倒そうで避けてきたので、、 ---- Yuto Hayamizu Master's degree student at Kitsuregawa Laboratory Department of Information and Communication Engineering Graduate School of Information Science and Technology University of Tokyo From: Tadashi MATSUO <[email protected]> Subject: [twmode-users] tweet編集用minibuffer上でのmark有効化 Date: Mon, 28 Dec 2009 00:24:54 +0900 (JST) > 松尾です。 > > twittering-show-minibuffer-length()がpost-command-hook経由で > 呼び出されるようになってから、tweet編集時のminibufferで > set-mark-command()によるmark有効化が働かなくなっていました。 > transient-mark-modeにしてもテキストを反転選択できません。 > > http://github.com/cvmat/twittering-mode/commits/fix-show-minibuffer-length > にこれを解決する修正をcommitしました。 > > Debian 5.0.3上のGNU Emacs 21.4.1とGNU Emacs 22.2.1で動作を > 確認しています。問題なければmergeをお願いします。 > > > 原因は以下のようです。 > > A.twittering-show-minibuffer-length()で呼び出されている > minibuffer-message()がglobal変数deactivate-markにtを設定する > > B.Emacsはpost-command-hookが実行される前にdeactivate-markを > 参照してnon-nilであればmarkを無効化(deactivate)する > > 変数deactivate-markは、コマンド実行後command-loopに戻ったときに > markをdeactivateするべきかどうかを指定するための変数です。 > カーソル移動ならdeactivateせず、文字挿入ならdeactivateする、 > などを関数の方で設定できます。 > > post-command-hook中でこの値をtにしてしまうとユーザの操作で > markをactivateすることができなくなってしまいます。 > > 対処法は変数deactivate-markをletでの束縛に置き換えてglobalな > 値が変更されないようにすれば良いです。 > > "#3350 - 23.0.93; Deactivation of region by the insert function - Emacs bug > report logs" > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3350 > > letでglobalな束縛を隠してしまえば、minibuffer-message()内で > deactivate-markが変更されても影響はなくなります。 > > しかし、B.の振舞いのためにpost-command-hook後にdeactivate-markの > 効果が現れるのは次にコマンドを実行した後になります。 > > 例えば、 > > 1. 1文字入力 > ↓ > 2. set-mark-command() > ↓ > 3. カーソル移動 > ↓ > 4. 1文字入力 > ↓ > 5. 1文字入力 > > の順で操作を行うと、本来は4.の操作の直後にdeactivateされるはず > なのですが、post-command-hookを設定している状態では > deactivate-markの振舞いが通常とは異なるようです。 > > 振舞いを見ると、次のような流れになっているようです。 > > 1a. deactivate-markを参照。markがactivateされていないので効果無し > 1b. 1文字入力 > 1c. (setq deactivate-mark t) > ↓ > 2a. deactivate-markを参照。markがactivateされていないので効果無し > 2b. set-mark-command()呼び出し。markがactivateされる。 > 2c. (setq deactivate-mark nil) > ↓ > 3a. deactivate-markを参照。nilなのでdeactivateしない。 > 3b. カーソル移動 > 3c. (setq deactivate-mark nil) > ↓ > 4a. deactivate-markを参照。nilなのでdeactivateしない。 > 4b. 1文字入力 > 4c. (setq deactivate-mark t) > ↓ > 5a. deactivate-markを参照。tなのでdeactivateする。 > 5b. 1文字入力 > 5c. (setq deactivate-mark t) > > 5.の操作を行わないとdeactivateされず、他のbufferでの振舞いと > 違ってしまっています。 > "flash-paren.el" > http://www.splode.com/~friedman/software/emacs-lisp/src/flash-paren.el > のflash-paren-do-flash-with-buffer-modification()のコメントに > > ;; Deactivate the mark now if not using idle timers and deactivate-mark > ;; is set in transient mark mode. Normally the command loop does this > ;; itself, but if this function is run from post-command-hook, > ;; deactivation is delayed and causes noticable, undesirable effects on > ;; the display. The only time I've noticed this to be of consequence is > ;; when point is right before a sexp and you insert a character. > > とあるのですが、これと同じ状況と思います。 > twittering-show-minibuffer-length()内で自前で > 関数deactivate-mark()を呼び出せば解決するようです。 > > --- > 松尾 直志 <[email protected]> > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > twmode-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/twmode-users ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ twmode-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/twmode-users
