unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 99c637499e: Only apply last change to the clipboard
       [not found] ` <20220201021359.C439EC40717@vcs2.savannah.gnu.org>
@ 2022-02-01  5:20   ` Stefan Monnier
  2022-02-01  5:24     ` Po Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2022-02-01  5:20 UTC (permalink / raw)
  To: emacs-devel; +Cc: Po Lu

> @@ -173,6 +173,7 @@ decoded.  If `gui-get-selection' signals an error, return nil."
>    (unless (and (memq window-system '(x haiku))
>                 ;; gui-backend-selection-p might be unreliable on other
>                 ;; window systems.
> +               (eq type 'CLIPBOARD)
>                 (gui-backend-selection-owner-p type))
>      (let ((request-type (if (memq window-system '(x pgtk))
>                              (or x-select-request-type

The comment is weird.  Is it meant to apply to the line of code *above* it?
If so, please move it since we follow the convention to put comments
*before* the code to which they apply.  Also I suspect that you meant to
say `gui-backend-selection-owner-p` rather than
`gui-backend-selection-p` in the comment, right?

BTW rather than use such tests we should probably change
`gui-backend-selection-owner-p` so it can return yes/no/dontknow.


        Stefan




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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  5:20   ` master 99c637499e: Only apply last change to the clipboard Stefan Monnier
@ 2022-02-01  5:24     ` Po Lu
  2022-02-01  5:28       ` Po Lu
  2022-02-01  5:35       ` Stefan Monnier
  0 siblings, 2 replies; 17+ messages in thread
From: Po Lu @ 2022-02-01  5:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> The comment is weird.  Is it meant to apply to the line of code
> *above* it?  If so, please move it since we follow the convention to
> put comments *before* the code to which they apply.

That will be fixed, thanks.

> Also I suspect that you meant to say `gui-backend-selection-owner-p`
> rather than `gui-backend-selection-p` in the comment, right?

Yes, thanks.

> BTW rather than use such tests we should probably change
> `gui-backend-selection-owner-p` so it can return yes/no/dontknow.

The problem is that I don't really know why it doesn't work on those
ports.  I just observed them returning nonsensical values.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  5:24     ` Po Lu
@ 2022-02-01  5:28       ` Po Lu
  2022-02-01 14:59         ` Eli Zaretskii
  2022-02-01  5:35       ` Stefan Monnier
  1 sibling, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-01  5:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Po Lu <luangruo@yahoo.com> writes:

> The problem is that I don't really know why it doesn't work on those
> ports.

"those ports" being PGTK and GNUstep.  Maybe it works correctly on
MS-Windows, so we could add `w32' to the list of window systems where it
does work.

Thanks.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  5:24     ` Po Lu
  2022-02-01  5:28       ` Po Lu
@ 2022-02-01  5:35       ` Stefan Monnier
  2022-02-01  7:40         ` Po Lu
  1 sibling, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2022-02-01  5:35 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

>> The comment is weird.  Is it meant to apply to the line of code
>> *above* it?  If so, please move it since we follow the convention to
>> put comments *before* the code to which they apply.
>
> That will be fixed, thanks.
>
>> Also I suspect that you meant to say `gui-backend-selection-owner-p`
>> rather than `gui-backend-selection-p` in the comment, right?
>
> Yes, thanks.

Thanks for confirming.

>> BTW rather than use such tests we should probably change
>> `gui-backend-selection-owner-p` so it can return yes/no/dontknow.
> The problem is that I don't really know why it doesn't work on those
> ports.  I just observed them returning nonsensical values.

Even if we don't know why, it'd be cleaner to put it there than here.


        Stefan




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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  5:35       ` Stefan Monnier
@ 2022-02-01  7:40         ` Po Lu
  2022-02-01 13:41           ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-01  7:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> The problem is that I don't really know why it doesn't work on those
>> ports.  I just observed them returning nonsensical values.
>
> Even if we don't know why, it'd be cleaner to put it there than here.

How would you know when it should return `dontknow', when there is no
way to determine if it's returning an incorrect value?



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  7:40         ` Po Lu
@ 2022-02-01 13:41           ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2022-02-01 13:41 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

Po Lu [2022-02-01 15:40:49] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> The problem is that I don't really know why it doesn't work on those
>>> ports.  I just observed them returning nonsensical values.
>> Even if we don't know why, it'd be cleaner to put it there than here.
> How would you know when it should return `dontknow', when there is no
> way to determine if it's returning an incorrect value?

Always?


        Stefan




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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01  5:28       ` Po Lu
@ 2022-02-01 14:59         ` Eli Zaretskii
  2022-02-02  0:58           ` Po Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-01 14:59 UTC (permalink / raw)
  To: Po Lu; +Cc: monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 01 Feb 2022 13:28:22 +0800
> 
> Po Lu <luangruo@yahoo.com> writes:
> 
> > The problem is that I don't really know why it doesn't work on those
> > ports.
> 
> "those ports" being PGTK and GNUstep.  Maybe it works correctly on
> MS-Windows, so we could add `w32' to the list of window systems where it
> does work.

The notion of "selection owner" doesn't exist on MS-Windows, so maybe
I misunderstand what you mean by "works".  In any case, if you show
some recipe to try, I could try it and report back.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-01 14:59         ` Eli Zaretskii
@ 2022-02-02  0:58           ` Po Lu
  2022-02-02  3:32             ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-02  0:58 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> The notion of "selection owner" doesn't exist on MS-Windows, so maybe
> I misunderstand what you mean by "works".  In any case, if you show
> some recipe to try, I could try it and report back.

Thanks, you can just try saving some text to the clipboard, and then
running:

  (gui-backend-selection-owner-p 'CLIPBOARD)

Which should return t.  Then cut some text from another application, and
it should return nil.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02  0:58           ` Po Lu
@ 2022-02-02  3:32             ` Eli Zaretskii
  2022-02-02  4:50               ` Po Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-02  3:32 UTC (permalink / raw)
  To: Po Lu; +Cc: monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org
> Date: Wed, 02 Feb 2022 08:58:29 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > The notion of "selection owner" doesn't exist on MS-Windows, so maybe
> > I misunderstand what you mean by "works".  In any case, if you show
> > some recipe to try, I could try it and report back.
> 
> Thanks, you can just try saving some text to the clipboard, and then
> running:
> 
>   (gui-backend-selection-owner-p 'CLIPBOARD)
> 
> Which should return t.  Then cut some text from another application, and
> it should return nil.

It returns nil here in both cases.  This is with today's master.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02  3:32             ` Eli Zaretskii
@ 2022-02-02  4:50               ` Po Lu
  2022-02-02 12:49                 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-02  4:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> It returns nil here in both cases.  This is with today's master.

Hmm, that means the result is not useful for `gui-selection-value'.
Would there be a way to implement that feature on MS-Windows?

The simplest way to implement it would be to return `t' if Emacs stored
the text currently in the clipboard.

Thanks.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02  4:50               ` Po Lu
@ 2022-02-02 12:49                 ` Eli Zaretskii
  2022-02-02 13:51                   ` Po Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-02 12:49 UTC (permalink / raw)
  To: Po Lu; +Cc: monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org
> Date: Wed, 02 Feb 2022 12:50:19 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > It returns nil here in both cases.  This is with today's master.
> 
> Hmm, that means the result is not useful for `gui-selection-value'.
> Would there be a way to implement that feature on MS-Windows?
> 
> The simplest way to implement it would be to return `t' if Emacs stored
> the text currently in the clipboard.

What would be the purpose of that?  What would you like to do with
"ownership" of the clipboard data, and why?

Emacs on Windows already tries internally to keep track of whether the
stuff in the clipboard was put there by the current session, so I'm
not sure why else would you need this.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02 12:49                 ` Eli Zaretskii
@ 2022-02-02 13:51                   ` Po Lu
  2022-02-02 14:44                     ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-02 13:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> Hmm, that means the result is not useful for `gui-selection-value'.
>> Would there be a way to implement that feature on MS-Windows?
>> 
>> The simplest way to implement it would be to return `t' if Emacs stored
>> the text currently in the clipboard.

> What would be the purpose of that?  What would you like to do with
> "ownership" of the clipboard data, and why?

That way, `gui-selection-value' can return nil if Emacs owns the
selection (per the doc string of `interprogram-paste-function') to avoid
fetching the selection in the common case where the user is yanking text
saved by Emacs.

> Emacs on Windows already tries internally to keep track of whether the
> stuff in the clipboard was put there by the current session, so I'm
> not sure why else would you need this.

See the doc string of `interprogram-paste-function':

  If no other program has provided text to paste, the function should
  return nil (in which case the caller, usually current-kill, should use
  the top of the Emacs kill ring)

Thanks.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02 13:51                   ` Po Lu
@ 2022-02-02 14:44                     ` Eli Zaretskii
  2022-02-03  1:11                       ` Po Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-02 14:44 UTC (permalink / raw)
  To: Po Lu; +Cc: monnier, emacs-devel

> From: Po Lu <luangruo@yahoo.com>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org
> Date: Wed, 02 Feb 2022 21:51:26 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Hmm, that means the result is not useful for `gui-selection-value'.
> >> Would there be a way to implement that feature on MS-Windows?
> >> 
> >> The simplest way to implement it would be to return `t' if Emacs stored
> >> the text currently in the clipboard.
> 
> > What would be the purpose of that?  What would you like to do with
> > "ownership" of the clipboard data, and why?
> 
> That way, `gui-selection-value' can return nil if Emacs owns the
> selection (per the doc string of `interprogram-paste-function') to avoid
> fetching the selection in the common case where the user is yanking text
> saved by Emacs.

But the Windows implementation of gui-selection-value already does
that.  Did you try it on Windows?

> > Emacs on Windows already tries internally to keep track of whether the
> > stuff in the clipboard was put there by the current session, so I'm
> > not sure why else would you need this.
> 
> See the doc string of `interprogram-paste-function':
> 
>   If no other program has provided text to paste, the function should
>   return nil (in which case the caller, usually current-kill, should use
>   the top of the Emacs kill ring)

The Windows build already lives up to that promise.  There's no need
for any additional code.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-02 14:44                     ` Eli Zaretskii
@ 2022-02-03  1:11                       ` Po Lu
  2022-02-03  4:01                         ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu @ 2022-02-03  1:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> But the Windows implementation of gui-selection-value already does
> that.  Did you try it on Windows?

No, I didn't know that.

> The Windows build already lives up to that promise.  There's no need
> for any additional code.

Thanks, then there's nothing to do here.



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-03  1:11                       ` Po Lu
@ 2022-02-03  4:01                         ` Stefan Monnier
  2022-02-03  7:48                           ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2022-02-03  4:01 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, emacs-devel

Po Lu [2022-02-03 09:11:15] wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
>> But the Windows implementation of gui-selection-value already does
>> that.  Did you try it on Windows?
> No, I didn't know that.
>> The Windows build already lives up to that promise.  There's no need
>> for any additional code.
> Thanks, then there's nothing to do here.

FWIW, when I worked on this gui-selection code, I found this part quite
unclear, and hence in need of clarification/simplification.


        Stefan




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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-03  4:01                         ` Stefan Monnier
@ 2022-02-03  7:48                           ` Eli Zaretskii
  2022-02-03 13:32                             ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2022-02-03  7:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: luangruo, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
> Date: Wed, 02 Feb 2022 23:01:53 -0500
> 
> Po Lu [2022-02-03 09:11:15] wrote:
> > Eli Zaretskii <eliz@gnu.org> writes:
> >> But the Windows implementation of gui-selection-value already does
> >> that.  Did you try it on Windows?
> > No, I didn't know that.
> >> The Windows build already lives up to that promise.  There's no need
> >> for any additional code.
> > Thanks, then there's nothing to do here.
> 
> FWIW, when I worked on this gui-selection code, I found this part quite
> unclear, and hence in need of clarification/simplification.

By "this part" do you mean how w32 works, or do you mean the
selection-owner stuff in general?



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

* Re: master 99c637499e: Only apply last change to the clipboard
  2022-02-03  7:48                           ` Eli Zaretskii
@ 2022-02-03 13:32                             ` Stefan Monnier
  0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2022-02-03 13:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, emacs-devel

>> FWIW, when I worked on this gui-selection code, I found this part quite
>> unclear, and hence in need of clarification/simplification.
> By "this part" do you mean how w32 works, or do you mean the
> selection-owner stuff in general?

I mean the selection-owner stuff.


        Stefan




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

end of thread, other threads:[~2022-02-03 13:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <164368163944.24305.8528536193885928245@vcs2.savannah.gnu.org>
     [not found] ` <20220201021359.C439EC40717@vcs2.savannah.gnu.org>
2022-02-01  5:20   ` master 99c637499e: Only apply last change to the clipboard Stefan Monnier
2022-02-01  5:24     ` Po Lu
2022-02-01  5:28       ` Po Lu
2022-02-01 14:59         ` Eli Zaretskii
2022-02-02  0:58           ` Po Lu
2022-02-02  3:32             ` Eli Zaretskii
2022-02-02  4:50               ` Po Lu
2022-02-02 12:49                 ` Eli Zaretskii
2022-02-02 13:51                   ` Po Lu
2022-02-02 14:44                     ` Eli Zaretskii
2022-02-03  1:11                       ` Po Lu
2022-02-03  4:01                         ` Stefan Monnier
2022-02-03  7:48                           ` Eli Zaretskii
2022-02-03 13:32                             ` Stefan Monnier
2022-02-01  5:35       ` Stefan Monnier
2022-02-01  7:40         ` Po Lu
2022-02-01 13:41           ` Stefan Monnier

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