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

Re: cannot cut&paste links anymore!



This Japanese discussion might not be directly connected to the
problem that Clemens Fischer brought up.  Hiroshi Fujishima
brought up another problem which seemed to be similar to the
original matter.  That problem is that the activated region is
deactivated when the cursor moves into the link.  The patch for
the trial is attached below.  I think we need to further discuss
it, though.

たぶん土屋さんや藤島さん、それに多くの人もそうなんじゃないかと思
いますが、この問題は以前からときどき気になっていました。

>>>>> In [emacs-w3m : No.08262] 山岡 wrote:

> w3m-message が呼んでいる message が原因なんです。現在 print 系の
> 関数でエコーエリアに表示する方法の実験中。

すみません、勘違いでした。

もっと奥の、w3m-url-readable-string が呼ぶ w3m-url-decode-string
で使われている insert が原因のような気がします。例えばこれを

(defun w3m-url-decode-string (str &optional coding)
  (with-temp-buffer
    (insert "foo")
    )
  str)

と、思いっ切り簡単にしても問題が発生しました。

ここで insert の行をコメントアウトすると問題は解消します。また
Emacs 21 ではだめですが、Emacs 22 では (insert "") としても効き
ます。 (princ "string" (current-buffer)) で置き換えても効果が無
く、どうやら Emacs の根幹に問題がありそうです。ちなみに XEmacs
では同様の問題はありません。

そこで、この処理の前後で region を save する対策を行ってみました。
具体的には w3m-url-readable-string を呼ぶ前に marker が active
だったら、その位置を覚えておき、後で再び activate するというもの
です。ところがここにも伏兵がいて、せっかく activate し直した
marker が、post-command-hook の実行終了とともに deactivate され
てしまうのです。

したがって marker を activate し直すのは post-command-hook の実
行終了後でなければならないので、post-post-command-hook のような
ものが必要です。実際にはそんなものは無いので、代わりにタイマーに
処理を引き継がせてみたところ、うまくいきました。しかし、かなりな
トンデモ対策なので、採用するには抵抗があります。どんなもんでしょ
う?
--- w3m.el~	2005-07-05 23:52:27 +0000
+++ w3m.el	2005-07-07 08:10:18 +0000
@@ -5782,7 +5782,14 @@
     (when (or url interactive-p)
       (and url interactive-p (kill-new url))
       (w3m-message "%s"
-		   (or (w3m-url-readable-string url)
+		   (or (let ((mk (w3m-static-unless (featurep 'xemacs)
+				   (when (and transient-mark-mode mark-active)
+				     (mark)))))
+			 (prog1
+			     (w3m-url-readable-string url)
+			   (when mk
+			     (run-at-time 1e-9 nil
+					  #'push-mark mk t t))))
 		       (and (w3m-action) "There is a form")
 		       "There is no url")))))