[Top][All Lists]

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

Re: Mysterious differences in nsselect.m

From: Jan Djärv
Subject: Re: Mysterious differences in nsselect.m
Date: Sun, 19 Oct 2014 10:13:44 +0200


> 19 okt 2014 kl. 00:16 skrev Stefan Monnier <address@hidden>:
> Could someone explain to me why we have both "ns-own-selection-internal"
> and "ns-store-selection-internal"?
> They both end up calling ns_string_to_pasteboard_internal, but one with
> a nil gtype and the other with a NSStringPboardType gtype, so it seems
> that in the case of ns-store-selection-internal we set the "pasteboard"
> for all selection types, where in the case of ns-own-selection-internal
> we only set the pasteboard for the NSStringPboardType type.

If you examine this, you see that "all selection types", i.e. ns_send_types is 
an array with one member, NSStringPboardType.  So both cases are in practice 
the same.  I don't know if the original author intended to add more pboard 
types.  Emacs could in principle send filenames or URL:s from a dired buffer.  
But for now Emacs only set strings.

> FWIW, I don't know what it means to set a pasteboard for a particular
> selection type, nor to set it for all selection types.

Its typed data.  You tell the the pasteboard what data to expect, i.e. 
NSFilenamesPboardType, NSURLPboardType and so on.

First you declare a pasteboard (ns_symbol_to_pb), like CLIPBOARD, PRIMARY.
Then you tell it what types of data to expect, [pb declareTypes: ns_send_types 
owner: NSApp];
Then actually transfer data,  [pb setString: nsStr forType: type];

> Would it be OK to drop ns-store-selection-internal and only use
> ns-own-selection-internal instead?

I guess so, but there are other differences.  ns-own-selection-internal runs 
Vns_sent_selection_hooks and store the selection in Vselection_alist.  
ns-store-selection-internal don't.  

It seems that ns-own-selection-internal is the way it is to go together with
ns-disown-selection-internal and ns-selection-owner-p.

Disown and owner-p does not really exist on NS, you just set data and that is 
own stores data in Vselection_alist so that disown and owner-p can emulate the X
versions.  Some experimentation shows that owner-p does not work well.
Ypu can select text in Emacs and owner-p return nil, even if 
x-get-selection-internal returns the very text you selected.

Maybe we should just make disown and owner-p always return nil and skip 
What parts of Emacs use owner-p?

        Jan D.

reply via email to

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