emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/eat f01afd6c24 2/2: Fix middle-click yanking commands


From: ELPA Syncer
Subject: [nongnu] elpa/eat f01afd6c24 2/2: Fix middle-click yanking commands
Date: Sat, 6 May 2023 08:59:44 -0400 (EDT)

branch: elpa/eat
commit f01afd6c24289f0f3b3b0409baae7c266adfd43b
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Fix middle-click yanking commands
    
    * eat.el (eat-mouse-yank-primary): Switch to the window where
    the event was initiated.
    * eat.el (eat-mouse-yank-secondary): Switch to the window where
    the event was initiated.  Ensure that the secondary selection
    is non-empty before sending it.
---
 eat.el | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/eat.el b/eat.el
index 652a27274d..8d2ded0e07 100644
--- a/eat.el
+++ b/eat.el
@@ -5103,16 +5103,28 @@ STRING and ARG are passed to `yank-pop', which see."
          (yank-from-kill-ring string arg)
          (buffer-string))))))
 
-(defun eat-mouse-yank-primary ()
-  "Send the primary selection to the terminal."
-  (interactive)
+(defun eat-mouse-yank-primary (&optional event)
+  "Send the primary selection to the terminal.
+
+EVENT is the mouse event."
+  (interactive "e")
+  (unless (windowp (posn-window (event-start event)))
+    (error "Position not in text area of window"))
+  (select-window (posn-window (event-start event)))
   (eat-send-string-as-yank eat--terminal (gui-get-primary-selection)))
 
-(defun eat-mouse-yank-secondary ()
-  "Send the secondary selection to the terminal."
-  (interactive)
-  (eat-send-string-as-yank
-   eat--terminal (gui-get-selection 'SECONDARY)))
+(defun eat-mouse-yank-secondary (&optional event)
+  "Send the secondary selection to the terminal.
+
+EVENT is the mouse event."
+  (interactive "e")
+  (unless (windowp (posn-window (event-start event)))
+    (error "Position not in text area of window"))
+  (select-window (posn-window (event-start event)))
+  (let ((secondary (gui-get-selection 'SECONDARY)))
+    (if secondary
+        (eat-send-string-as-yank eat--terminal secondary)
+      (error "No secondary selection"))))
 
 (defun eat-xterm-paste (event)
   "Handle paste operation EVENT from XTerm."



reply via email to

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