Hi!
This fixes the same sort of problem as did JWZ’s patches of the middle of
last year, but this time for copying text to other apps. The calls to
(encode-coding ... 'utf-8) don’t need to be conditionalised on 'mule for
21.5, because that coding system should always be available there.
Bye,
- Aidan
--
“Ah come on now Ted, a Volkswagen with a mind of its own, driving all over
the place and going mad, if that’s not scary I don’t know what is.”
Index: lisp/select.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/select.el,v
retrieving revision 1.13
diff -u -r1.13 select.el
--- lisp/select.el 2002/05/23 11:46:10 1.13
+++ lisp/select.el 2005/01/12 00:54:09
@@ -255,6 +255,8 @@
;; Given a selection, this makes an extent in the buffer which holds that
;; selection, for highlighting purposes. If the selection isn't associated
;; with a buffer, this does nothing.
+ ;;
+ ;; Something similar needs to be hooked into the rectangle functions.
(let ((buffer nil)
(valid (and (extentp previous-extent)
(extent-object previous-extent)
@@ -439,6 +441,35 @@
(buffer-substring (car value) (cdr value)))))
(t nil)))
+(defun select-convert-to-utf-8-string (selection type value)
+ (cond ((stringp value)
+ (cons 'UTF8_STRING (encode-coding-string value 'utf-8)))
+ ((extentp value)
+ (save-excursion
+ (set-buffer (extent-object value))
+ (save-restriction
+ (widen)
+ (cons 'UTF8_STRING
+ (encode-coding-string
+ (buffer-substring (extent-start-position value)
+ (extent-end-position value)) 'utf-8)))))
+ ((and (consp value)
+ (markerp (car value))
+ (markerp (cdr value)))
+ (or (eq (marker-buffer (car value)) (marker-buffer (cdr value)))
+ (signal 'error
+ (list "markers must be in the same buffer"
+ (car value) (cdr value))))
+ (save-excursion
+ (set-buffer (or (marker-buffer (car value))
+ (error "selection is in a killed buffer")))
+ (save-restriction
+ (widen)
+ (cons 'UTF8_STRING (encode-coding-string
+ (buffer-substring (car value) (cdr value))
+ 'utf-8)))))
+ (t nil)))
+
(defun select-coerce-to-text (selection type value)
(select-convert-to-text selection type value))
@@ -788,7 +819,8 @@
;; Types listed in here can be selections of XEmacs
(setq selection-converter-out-alist
- '((TEXT . select-convert-to-text)
+ '((UTF8_STRING . select-convert-to-utf-8-string)
+ (TEXT . select-convert-to-text)
(STRING . select-convert-to-string)
(COMPOUND_TEXT . select-convert-to-compound-text)
(TARGETS . select-convert-to-targets)