emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch for selection in Carbon Emacs


From: YAMAMOTO Mitsuharu
Subject: Re: Patch for selection in Carbon Emacs
Date: Thu, 14 Apr 2005 19:14:37 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Mon, 11 Apr 2005 19:46:26 +0900, YAMAMOTO Mitsuharu <address@hidden> 
>>>>> said:

> Selection data types and scrap flavor types are related in a similar
> way:

>   (put 'mac-TEXT 'mac-scrap-flavor-type "TEXT")
>   (put 'mac-UNICODE 'mac-scrap-flavor-type "utxt")

On second thought, I think I'd like to use UTIs (Uniform Type
Identifiers, http://developer.apple.com/qa/qa2005/qa1406.html) rather
than inventing new names.

  (put 'com.apple.traditional-mac-plain-text 'mac-scrap-flavor-type "TEXT")
  (put 'public.utf16-plain-text 'mac-scrap-flavor-type "utxt")

But it may not be good to use `.' as a part of a Lisp symbol name (its
printed representation prepends `\'), so I'd like to ask opinions
about that.  I personally don't care that much.

By the way, TIFF images can be pasted from the clipboard using the
code below :-)  (with the previously posted patch, of course)

                                     YAMAMOTO Mitsuharu
                                address@hidden

(put 'com.apple.traditional-mac-plain-text 'mac-scrap-flavor-type "TEXT")
(put 'public.utf16-plain-text 'mac-scrap-flavor-type "utxt")
(put 'public.tiff 'mac-scrap-flavor-type "TIFF")

(setq selection-converter-alist
      (nconc
       '((public.utf16-plain-text . mac-select-convert-to-string)
         (com.apple.traditional-mac-plain-text . mac-select-convert-to-string)
         (public.tiff . ignore))
       selection-converter-alist))

(defun x-selection-value (type)
  (let (text tiff-image)
    (setq text (condition-case nil
                   (x-get-selection type 'public.utf16-plain-text)
                 (error nil)))
    (if (not text)
        (setq text (condition-case nil
                       (x-get-selection type
                                        'com.apple.traditional-mac-plain-text)
                     (error nil))))
    (if text
        (remove-text-properties 0 (length text) '(foreign-selection nil) text))
    (setq tiff-image (condition-case nil
                         (x-get-selection type 'public.tiff)
                       (error nil)))
    (when tiff-image
      (remove-text-properties 0 (length tiff-image)
                              '(foreign-selection nil) tiff-image)
      (setq tiff-image (create-image tiff-image 'tiff t))
      (or text (setq text " "))
      (put-text-property 0 (length text) 'display tiff-image text))
    text))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]