Re: Проблема с X clipboard

Yuri Karaban <[email protected]> Tue, 28 Sep 2004 00:11:14 +0300
Newsgroups gmane.emacs.xemacs.user.russian
Message-ID <[email protected]>
>>>>> "AS" == Andrey Slusar <[email protected]> writes:

Вобщем написал по своему (гораздо компактнее и без setcdr-ов), декодер
сегментов нестандартных charset-ов в compound text. Пока только это,
но планирую сделать полноценный декодер compound text-а.

--------------------------[Cut]--------------------------------------------------------
(defun decode-ctext (selection type text)
  (cond
   ((string-match "\x1b\x25\x2f\x31\\(.\\)\\(.\\)\\(.*?\\)\x02" text)
    (let
	((len (+ (* (- (char-to-int (string-to-char (match-string 1 text))) 128) 128)
		 (- (char-to-int (string-to-char (match-string 2 text))) 128))))
      (let
	  ((seq-beg (match-beginning 0))
	   (data-beg (match-end 0))
	   (data-end (+ len (match-beginning 3)))
	   (text-len (length text))
	   (cs (find-coding-system (intern (match-string 3 text)))))
	(if (or (> data-end text-len) (not cs)) text ; incorrect coding system or length
	  (concat (substring text 0 seq-beg)
		  (decode-coding-string (substring text data-beg data-end) cs)
		  (decode-ctext selection type (substring text data-end)))))))
   (t text)))

(setq selection-converter-in-alist
      (mapcar
       (lambda (arg)
	 (cond
	  ((or (eq (car arg) 'COMPOUND_TEXT) (eq (car arg) 'TEXT)) (cons (car arg) 'decode-ctext))
	  (t arg)))
       selection-converter-in-alist))
--------------------------[Cut]--------------------------------------------------------


    AS>> Пофиг, это - родовая травма xemacs.

    >> При попытке сделать Copy (например из мозиллы) & Paste в
    >> xemacs.  Текст попадает в виде ctext.
    AS>> [...]
    >> Помогите пожалуйста, заранее спасибо !

    AS>> Stephen J. Turnbull когда-то показал хук, который правит
    AS>> вставку текста из мозиллы:

    AS>> http://santinel.bas-net.by/files/stephen-ctext-hack.el

    AS>> Делаешь (require 'stephen-ctext-hack) перед выставлением
    AS>> дефолтных енвиропментов.