[Top][All Lists]

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

Re: Mysterious differences in nsselect.m

From: Adrian Robert
Subject: Re: Mysterious differences in nsselect.m
Date: Sun, 19 Oct 2014 12:59:07 +0300

Just to add something about the history that may or may not be informative, the 
"-store-selection-internal" version was originally part of a whole suite of 
functions pertaining to “cut buffers”, which appear to be an older X 
implementation of selection that emacs supported for a while.  I wanted to 
refactor them out a while back but could not figure out how to do it cleanly.  
Only ns-store-selection-internal and ns-get-selection-internal remain now.  If 
Emacs itself still has multiple selection implementations for X, then we need 
to keep these for parallelism, but if the older code is finally gone I would 
think this could be cleaned up too.


On 2014.10.19, at 11:13, Jan Djärv <address@hidden> wrote:

> Hi.
>> 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. 
> NSStringPboardType,
> 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 
> it.
> 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 
> Vselection_alist.
> What parts of Emacs use owner-p?
>       Jan D.

reply via email to

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