unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Adrian Robert <Adrian.B.Robert@gmail.com>, emacs-devel@gnu.org
Subject: Re: Mysterious differences in nsselect.m
Date: Sun, 19 Oct 2014 10:13:44 +0200	[thread overview]
Message-ID: <2B06B631-0098-48DF-9307-CD8A328E972F@swipnet.se> (raw)
In-Reply-To: <jwv8ukdf2uq.fsf-monnier+emacs@gnu.org>

Hi.

> 19 okt 2014 kl. 00:16 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> 
> 
> 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	other threads:[~2014-10-19  8:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-18 22:16 Mysterious differences in nsselect.m Stefan Monnier
2014-10-19  8:13 ` Jan Djärv [this message]
2014-10-19  9:59   ` Adrian Robert
2014-10-21 13:28   ` Stefan Monnier
2014-10-21 19:01     ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2B06B631-0098-48DF-9307-CD8A328E972F@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=Adrian.B.Robert@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).