\u30cd\u30bf というunicode escapeされた文字列がペーストされてしまう件をちょっと調べてみた。
Emacs21 なので mule-ucs も使ってるけど、どうも簡単な設定ではなさそう。
既に世の中 Emacs22 みたいなので、Emacs22 にしてみたら問題なく Copy & Paste できた。Emacs21->Emacs22では mule-ucs不要になったので、次のように
un-define しないようにする必要があったくらい。(when (<= emacs-major-version 21) (require 'un-define))ちょっと深追いしてみると Emacs21では term/x-win.el -> select.el の
x-get-selection がそういう文字列をかえしているみたいだった。
(x-get-selection 'PRIMARY 'STRING) "\\u30cd\\u30bf"そうこうしているうちに Iceweaselが死んでしまったので動かしなおしたら、Copy&Paste問題もなおってしまった。どうやら LANG=C でIceweaselを動かしていると駄目で、LANG=ja_JP.UTF-8 (or ja_JP.EUC-JP) で動かしているとよさそう。 Emacs22 はどちらでも問題ないので、Emacs21の問題といえば問題なのか。 こうやるとEmacs21でもよさげ
(defun unescape-x-text (str)
(replace-regexp-in-string
"\\\\u\\([0-9a-fA-F]\\{4,4\\}\\)"
(lambda (match-str)
(char-to-string (ucs-to-char
(read (concat "\?\\x" (substring match-str 2))))))
str))
(defun x-get-selection (&optional type data-type)
(unescape-x-text
(x-get-selection-internal (or type 'PRIMARY)
(or data-type 'STRING))))
No comments:
Post a Comment