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

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

[nongnu] elpa/eat 51eebc562b: Fix yanking text into terminal


From: ELPA Syncer
Subject: [nongnu] elpa/eat 51eebc562b: Fix yanking text into terminal
Date: Sat, 10 Dec 2022 05:58:56 -0500 (EST)

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

    Fix yanking text into terminal
    
    * eat.el (eat-yank): Use simpler, saner and better approach to get the
    yanked string instead of the previous stupid, insane and buggy
    approach.
    * eat.el (eat-yank-pop): Remove, because it's not cancel the text
    already sent to the terminal.
    * eat.el (eat-yank-from-kill-ring): New function.  Behaves essentially
    the same the previous (not properly working) 'eat-yank-pop'.
    * eat.el (eat-semi-char-mode-map, eat-eshell-semi-char-mode-map):
    Replace 'eat-yank-pop' with 'eat-yank-from-kill-ring'.
---
 eat.el | 59 +++++++++++++++++++++--------------------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)

diff --git a/eat.el b/eat.el
index ae1ca1210e..6d935b0760 100644
--- a/eat.el
+++ b/eat.el
@@ -4580,44 +4580,27 @@ ARG is passed to `yank', which see."
   (interactive "*P")
   (when eat--terminal
     (funcall eat--synchronize-scroll-function)
-    (cl-letf* ((inhibit-read-only t)
-               (insert-for-yank (symbol-function #'insert-for-yank))
-               ((symbol-function #'insert-for-yank)
-                (lambda (&rest args)
-                  (cl-letf (((symbol-function #'insert)
-                             (lambda (&rest args)
-                               (eat-send-string-as-yank
-                                eat--terminal
-                                (mapconcat (lambda (arg)
-                                             (if (stringp arg)
-                                                 arg
-                                               (string arg)))
-                                           args "")))))
-                    (apply insert-for-yank args)))))
-      (yank arg))))
-
-(defun eat-yank-pop (&optional arg)
-  "Same as `yank-pop', but for Eat.
-
-ARG is passed to `yank-pop', which see."
-  (interactive "p")
+    (eat-send-string-as-yank
+     eat--terminal (let ((yank-hook yank-transform-functions))
+                     (with-temp-buffer
+                       (setq-local yank-transform-functions yank-hook)
+                       (yank arg)
+                       (buffer-string))))))
+
+(defun eat-yank-from-kill-ring (string &optional arg)
+  "Same as `yank-from-kill-ring', but for Eat.
+
+STRING and ARG are passed to `yank-pop', which see."
+  (interactive (list (read-from-kill-ring "Yank from kill-ring: ")
+                     current-prefix-arg))
   (when eat--terminal
     (funcall eat--synchronize-scroll-function)
-    (cl-letf* ((inhibit-read-only t)
-               (insert-for-yank (symbol-function #'insert-for-yank))
-               ((symbol-function #'insert-for-yank)
-                (lambda (&rest args)
-                  (cl-letf (((symbol-function #'insert)
-                             (lambda (&rest args)
-                               (eat-send-string-as-yank
-                                eat--terminal
-                                (mapconcat (lambda (arg)
-                                             (if (stringp arg)
-                                                 arg
-                                               (string arg)))
-                                           args "")))))
-                    (apply insert-for-yank args)))))
-      (yank-pop arg))))
+    (eat-send-string-as-yank
+     eat--terminal (let ((yank-hook yank-transform-functions))
+                     (with-temp-buffer
+                       (setq-local yank-transform-functions yank-hook)
+                       (yank-from-kill-ring string arg)
+                       (buffer-string))))))
 
 ;; When changing these keymaps, be sure to update the manual, README
 ;; and commentary.
@@ -4640,7 +4623,7 @@ ARG is passed to `yank-pop', which see."
                  [?\e ?!] [?\e ?&] [?\C-y] [?\e ?y]))))
     (define-key map [?\C-q] #'eat-quoted-input)
     (define-key map [?\C-y] #'eat-yank)
-    (define-key map [?\M-y] #'eat-yank-pop)
+    (define-key map [?\M-y] #'eat-yank-from-kill-ring)
     (define-key map [?\C-c ?\C-c] #'eat-self-input)
     (define-key map [?\C-c ?\C-e] #'eat-emacs-mode)
     (define-key map [remap insert-char] #'eat-input-char)
@@ -5260,7 +5243,7 @@ PROGRAM can be a shell command."
                  [?\e ?!] [?\e ?&] [?\C-y] [?\e ?y]))))
     (define-key map [?\C-q] #'eat-quoted-input)
     (define-key map [?\C-y] #'eat-yank)
-    (define-key map [?\M-y] #'eat-yank-pop)
+    (define-key map [?\M-y] #'eat-yank-from-kill-ring)
     (define-key map [?\C-c ?\C-e] #'eat-eshell-emacs-mode)
     (define-key map [remap insert-char] #'eat-input-char)
     map)



reply via email to

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