unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch for selection in Carbon Emacs
@ 2005-04-11 10:46 YAMAMOTO Mitsuharu
  2005-04-14 10:14 ` YAMAMOTO Mitsuharu
  2005-04-18  8:44 ` YAMAMOTO Mitsuharu
  0 siblings, 2 replies; 4+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-04-11 10:46 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

The attached is a patch for selection/clipboard in Carbon Emacs.

  * Addresses the following bugs:

    [Emacs/Carbon/Mac OS X] clipboard-coding-system affects internal kill&yank
    http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-03/msg00133.html

    [osx] edit/paste menu item always disabled
    http://lists.gnu.org/archive/html/emacs-devel/2004-10/msg00101.html

  * Supports Unicode data in clipboard

    Selection-coding-system also affects pasting Unicode data from the
    clipboard.  First, the clipboard data is converted to the data
    encoded in selection-coding-system *using the converter provided
    by the system*, and then Emacs decodes its result with
    selection-coding-system.  If the first conversion failed, then
    Emacs decodes the original clipboard data as UTF-16 data.  I did
    so in order to avoid subtle difference between Unicode mappings.

As in other platforms, selection names are specified by Lisp symbols.
But unlike X11, not all selection names take part in interapplication
communication.  If a selection name has a string value for the
property `mac-scrap-name', then the data exchange with the selection
becomes that with the scrap (an interapplication storage in Mac) whose
name is the string.  For example, mac-win.el has the following line:

  (put 'CLIPBOARD 'mac-scrap-name "com.apple.scrap.clipboard")

and thus the selection CLIPBOARD corresponds to the standard
clipboard, which is a scrap named "com.apple.scrap.clipboard".

Neither PRIMARY nor SECONDARY is associated with a scrap by default,
so they are used inside Emacs only.

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")

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

[-- Attachment #2: diff-selection.gz --]
[-- Type: application/octet-stream, Size: 11062 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for selection in Carbon Emacs
  2005-04-11 10:46 Patch for selection in Carbon Emacs YAMAMOTO Mitsuharu
@ 2005-04-14 10:14 ` YAMAMOTO Mitsuharu
  2005-04-18  8:44 ` YAMAMOTO Mitsuharu
  1 sibling, 0 replies; 4+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-04-14 10:14 UTC (permalink / raw)


>>>>> On Mon, 11 Apr 2005 19:46:26 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 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
				mituharu@math.s.chiba-u.ac.jp

(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))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for selection in Carbon Emacs
  2005-04-11 10:46 Patch for selection in Carbon Emacs YAMAMOTO Mitsuharu
  2005-04-14 10:14 ` YAMAMOTO Mitsuharu
@ 2005-04-18  8:44 ` YAMAMOTO Mitsuharu
  2005-04-18  9:32   ` Miles Bader
  1 sibling, 1 reply; 4+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-04-18  8:44 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

>>>>> On Mon, 11 Apr 2005 19:46:26 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:

> The attached is a patch for selection/clipboard in Carbon Emacs.

The revised one is attached.  The Services menu works with selections
now.  For example, you can insert a grabbed image to a buffer by
selecting Emacs -> Services -> Grab -> Selection and specifying a
rectangle to grab.  But `Import Image' in the Services menu may cause
Emacs hang or crash intermittently for unknown reasons.

This is a rather big change about clipboard management, so please test
it if works especially for usual copy&paste operations.

By the way, do I need to do something special about arch-tags when
adding a new file (macselect.c, in this case) to CVS?

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

[-- Attachment #2: diff-selection2.gz --]
[-- Type: application/octet-stream, Size: 18425 bytes --]

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for selection in Carbon Emacs
  2005-04-18  8:44 ` YAMAMOTO Mitsuharu
@ 2005-04-18  9:32   ` Miles Bader
  0 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2005-04-18  9:32 UTC (permalink / raw)
  Cc: emacs-devel

On 4/18/05, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> wrote:
> By the way, do I need to do something special about arch-tags when
> adding a new file (macselect.c, in this case) to CVS?

No.  In general, just don't think about them at all.

[In particular, don't make an _empty_ arch-tag: line, that just
confuses things.  For some reason people often seem to do this.]

-Miles
-- 
Do not taunt Happy Fun Ball.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-18  9:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-11 10:46 Patch for selection in Carbon Emacs YAMAMOTO Mitsuharu
2005-04-14 10:14 ` YAMAMOTO Mitsuharu
2005-04-18  8:44 ` YAMAMOTO Mitsuharu
2005-04-18  9:32   ` Miles Bader

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).