all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* x-clipboard-yank insert kill-ring entry instead of primary selection
@ 2020-02-28  8:31 mickbert
  2020-02-28 12:45 ` Stefan Monnier
  2020-02-28 12:47 ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: mickbert @ 2020-02-28  8:31 UTC (permalink / raw)
  To: help-gnu-emacs

Hello.
I am using GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 
3.22.30) of 2018-09-12 on x86-039.build.eng.bos.redhat.com (but the same 
happen with the latest version compiled by me from sources) in an X 
frame

Note that the middle button of mouse, bound to 'mouse-yank-primary, 
works correctly. Instead the command 'x-clipboard-yank (which I bound to 
"<S-ins>", "<S-insert>", "<S-insertchar>" just as experiments) inserts 
the current entry of kill-ring, just the same as 'yank.

Any idea what I can look to find why it does this way, and correct it?
--
Mick



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-02-28  8:31 x-clipboard-yank insert kill-ring entry instead of primary selection mickbert
@ 2020-02-28 12:45 ` Stefan Monnier
  2020-02-28 12:47 ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2020-02-28 12:45 UTC (permalink / raw)
  To: help-gnu-emacs

> Note that the middle button of mouse, bound to 'mouse-yank-primary, works
> correctly. Instead the command 'x-clipboard-yank (which I bound to
> "<S-ins>", "<S-insert>", "<S-insertchar>" just as experiments) inserts 
> the current entry of kill-ring, just the same as 'yank.

As the name implies, `x-clipboard-yank` expected to interact with the
*clipboard* and not with the *primary selection*.


        Stefan




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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-02-28  8:31 x-clipboard-yank insert kill-ring entry instead of primary selection mickbert
  2020-02-28 12:45 ` Stefan Monnier
@ 2020-02-28 12:47 ` Eli Zaretskii
  2020-03-02  9:57   ` mickbert
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2020-02-28 12:47 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 28 Feb 2020 09:31:07 +0100
> From: mickbert@posteo.net
> 
> Hello.
> I am using GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 
> 3.22.30) of 2018-09-12 on x86-039.build.eng.bos.redhat.com (but the same 
> happen with the latest version compiled by me from sources) in an X 
> frame
> 
> Note that the middle button of mouse, bound to 'mouse-yank-primary, 
> works correctly. Instead the command 'x-clipboard-yank (which I bound to 
> "<S-ins>", "<S-insert>", "<S-insertchar>" just as experiments) inserts 
> the current entry of kill-ring, just the same as 'yank.
> 
> Any idea what I can look to find why it does this way, and correct it?

I suggest to read the section "Selection changes" in NEWS, it explains
what has changed in this area and how to customize Emacs to get back
the old pre-Emacs 24 behavior.



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-02-28 12:47 ` Eli Zaretskii
@ 2020-03-02  9:57   ` mickbert
  2020-03-02 11:34     ` Eli Zaretskii
  2020-03-02 16:31     ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: mickbert @ 2020-03-02  9:57 UTC (permalink / raw)
  To: help-gnu-emacs

On 28.02.2020 13:47, Eli Zaretskii wrote:
>> Date: Fri, 28 Feb 2020 09:31:07 +0100
> 
> I suggest to read the section "Selection changes" in NEWS, it explains
> what has changed in this area and how to customize Emacs to get back
> the old pre-Emacs 24 behavior.

I read it all, and now I have clearer image of the "copy/paste 
universe",  but
I can not find anything helpful yet - that is, a command to yank from
primary selection, other than mouse-yank-primary (which can only be
bound to mouse event).

even searching for command matching *select* or *primary* does not
give any interesting result. Is it possible that there is not any 
command
to yank from primary selection?
--
Mick



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02  9:57   ` mickbert
@ 2020-03-02 11:34     ` Eli Zaretskii
  2020-03-02 16:31     ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2020-03-02 11:34 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Mon, 02 Mar 2020 10:57:00 +0100
> From: mickbert@posteo.net
> 
> > I suggest to read the section "Selection changes" in NEWS, it explains
> > what has changed in this area and how to customize Emacs to get back
> > the old pre-Emacs 24 behavior.
> 
> I read it all, and now I have clearer image of the "copy/paste 
> universe",  but
> I can not find anything helpful yet - that is, a command to yank from
> primary selection, other than mouse-yank-primary (which can only be
> bound to mouse event).
> 
> even searching for command matching *select* or *primary* does not
> give any interesting result. Is it possible that there is not any 
> command
> to yank from primary selection?

Did you try customizing x-select-enable-clipboard to nil and
x-select-enable-primary to t?  AFAIU, if you do that, then C-y will
yank from the primary selection, if a primary selection exists.



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02  9:57   ` mickbert
  2020-03-02 11:34     ` Eli Zaretskii
@ 2020-03-02 16:31     ` Stefan Monnier
  2020-03-02 16:54       ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2020-03-02 16:31 UTC (permalink / raw)
  To: help-gnu-emacs

> mouse-yank-primary (which can only be bound to mouse event).

From where I stand, this restriction is a bug.

    (advice-add 'mouse-yank-primary :before
      (lambda (&rest _) (interactive (list last-nonmenu-event)) nil))

should work around the bug.  A more complete fix might look like the
patch below.


        Stefan


diff --git a/lisp/mouse.el b/lisp/mouse.el
index c1ddfc2b85..7bfcf2f3c4 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1521,12 +1521,14 @@ mouse-yank-at-click
   (setq mouse-selection-click-count 0)
   (yank arg))
 
-(defun mouse-yank-primary (click)
-  "Insert the primary selection at the position clicked on.
+(defun mouse-yank-primary (&optional event)
+  "Insert the primary selection.
 Move point to the end of the inserted text, and set mark at
-beginning.  If `mouse-yank-at-point' is non-nil, insert at point
-regardless of where you click."
-  (interactive "e")
+beginning.
+By default, insert at the position of the EVENT, but
+if `mouse-yank-at-point' is non-nil, insert at point
+regardless of where the event happened."
+  (interactive (list last-nonmenu-event))
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
   ;; Without this, confusing things happen upon e.g. inserting into
@@ -1534,7 +1536,7 @@ mouse-yank-primary
   (when select-active-regions
     (let (select-active-regions)
       (deactivate-mark)))
-  (or mouse-yank-at-point (mouse-set-point click))
+  (or mouse-yank-at-point (mouse-set-point event))
   (let ((primary (gui-get-primary-selection)))
     (push-mark)
     (insert-for-yank primary)))




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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02 16:31     ` Stefan Monnier
@ 2020-03-02 16:54       ` Eli Zaretskii
  2020-03-02 19:56         ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2020-03-02 16:54 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 02 Mar 2020 11:31:04 -0500
> 
> -(defun mouse-yank-primary (click)
> -  "Insert the primary selection at the position clicked on.
> +(defun mouse-yank-primary (&optional event)
> +  "Insert the primary selection.

A nit: a command that can be invoked not by mouse shouldn't be called
"mouse-SOMETHING".



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02 16:54       ` Eli Zaretskii
@ 2020-03-02 19:56         ` Stefan Monnier
  2020-03-02 20:15           ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2020-03-02 19:56 UTC (permalink / raw)
  To: help-gnu-emacs

>> -(defun mouse-yank-primary (click)
>> -  "Insert the primary selection at the position clicked on.
>> +(defun mouse-yank-primary (&optional event)
>> +  "Insert the primary selection.
>
> A nit: a command that can be invoked not by mouse shouldn't be called
> "mouse-SOMETHING".

;-)

I had the exact same reaction while writing the code.
Then again, mouse-set-point works with non-mouse events and I'm guessing
that many/most other commands in mouse.el can work with non-mouse events.

Not sure what we should do about it.  Renaming them all seems too
much trouble.  And they were all written with the mouse as the main
use case.  And they are all in mouse.el.

So I'm thinking maybe we can keep the "mouse-" prefix not to mean "only
useful for the mouse" but "originally introduced for the mouse" or
¨found in mouse.el".


        Stefan




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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02 19:56         ` Stefan Monnier
@ 2020-03-02 20:15           ` Eli Zaretskii
  2020-03-03 14:35             ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2020-03-02 20:15 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 02 Mar 2020 14:56:32 -0500
> 
> I had the exact same reaction while writing the code.
> Then again, mouse-set-point works with non-mouse events and I'm guessing
> that many/most other commands in mouse.el can work with non-mouse events.
> 
> Not sure what we should do about it.  Renaming them all seems too
> much trouble.

An alias?



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

* Re: x-clipboard-yank insert kill-ring entry instead of primary selection
  2020-03-02 20:15           ` Eli Zaretskii
@ 2020-03-03 14:35             ` Stefan Monnier
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2020-03-03 14:35 UTC (permalink / raw)
  To: help-gnu-emacs

>> Not sure what we should do about it.  Renaming them all seems too
>> much trouble.
> An alias?

Beside the number of potential obsolete-aliases this would introduce,
another problem I had with that option is to choose the namespace to put
it in.  I didn't like the idea of calling it `yank-primary` for some reason.

I guess we could use the "gui-" prefix already used for the selection
functions, so those mouse-* functions which can apply to non-mouse
situations to gui-*.


        Stefan




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

end of thread, other threads:[~2020-03-03 14:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-28  8:31 x-clipboard-yank insert kill-ring entry instead of primary selection mickbert
2020-02-28 12:45 ` Stefan Monnier
2020-02-28 12:47 ` Eli Zaretskii
2020-03-02  9:57   ` mickbert
2020-03-02 11:34     ` Eli Zaretskii
2020-03-02 16:31     ` Stefan Monnier
2020-03-02 16:54       ` Eli Zaretskii
2020-03-02 19:56         ` Stefan Monnier
2020-03-02 20:15           ` Eli Zaretskii
2020-03-03 14:35             ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.