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'.
This commit is contained in:
parent
12a5fb72b2
commit
51eebc562b
1 changed files with 19 additions and 36 deletions
55
eat.el
55
eat.el
|
@ -4580,44 +4580,27 @@ ARG is passed to `yank', which see."
|
||||||
(interactive "*P")
|
(interactive "*P")
|
||||||
(when eat--terminal
|
(when eat--terminal
|
||||||
(funcall eat--synchronize-scroll-function)
|
(funcall eat--synchronize-scroll-function)
|
||||||
(cl-letf* ((inhibit-read-only t)
|
(eat-send-string-as-yank
|
||||||
(insert-for-yank (symbol-function #'insert-for-yank))
|
eat--terminal (let ((yank-hook yank-transform-functions))
|
||||||
((symbol-function #'insert-for-yank)
|
(with-temp-buffer
|
||||||
(lambda (&rest args)
|
(setq-local yank-transform-functions yank-hook)
|
||||||
(cl-letf (((symbol-function #'insert)
|
(yank arg)
|
||||||
(lambda (&rest args)
|
(buffer-string))))))
|
||||||
(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)
|
(defun eat-yank-from-kill-ring (string &optional arg)
|
||||||
"Same as `yank-pop', but for Eat.
|
"Same as `yank-from-kill-ring', but for Eat.
|
||||||
|
|
||||||
ARG is passed to `yank-pop', which see."
|
STRING and ARG are passed to `yank-pop', which see."
|
||||||
(interactive "p")
|
(interactive (list (read-from-kill-ring "Yank from kill-ring: ")
|
||||||
|
current-prefix-arg))
|
||||||
(when eat--terminal
|
(when eat--terminal
|
||||||
(funcall eat--synchronize-scroll-function)
|
(funcall eat--synchronize-scroll-function)
|
||||||
(cl-letf* ((inhibit-read-only t)
|
(eat-send-string-as-yank
|
||||||
(insert-for-yank (symbol-function #'insert-for-yank))
|
eat--terminal (let ((yank-hook yank-transform-functions))
|
||||||
((symbol-function #'insert-for-yank)
|
(with-temp-buffer
|
||||||
(lambda (&rest args)
|
(setq-local yank-transform-functions yank-hook)
|
||||||
(cl-letf (((symbol-function #'insert)
|
(yank-from-kill-ring string arg)
|
||||||
(lambda (&rest args)
|
(buffer-string))))))
|
||||||
(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))))
|
|
||||||
|
|
||||||
;; When changing these keymaps, be sure to update the manual, README
|
;; When changing these keymaps, be sure to update the manual, README
|
||||||
;; and commentary.
|
;; and commentary.
|
||||||
|
@ -4640,7 +4623,7 @@ ARG is passed to `yank-pop', which see."
|
||||||
[?\e ?!] [?\e ?&] [?\C-y] [?\e ?y]))))
|
[?\e ?!] [?\e ?&] [?\C-y] [?\e ?y]))))
|
||||||
(define-key map [?\C-q] #'eat-quoted-input)
|
(define-key map [?\C-q] #'eat-quoted-input)
|
||||||
(define-key map [?\C-y] #'eat-yank)
|
(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-c] #'eat-self-input)
|
||||||
(define-key map [?\C-c ?\C-e] #'eat-emacs-mode)
|
(define-key map [?\C-c ?\C-e] #'eat-emacs-mode)
|
||||||
(define-key map [remap insert-char] #'eat-input-char)
|
(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]))))
|
[?\e ?!] [?\e ?&] [?\C-y] [?\e ?y]))))
|
||||||
(define-key map [?\C-q] #'eat-quoted-input)
|
(define-key map [?\C-q] #'eat-quoted-input)
|
||||||
(define-key map [?\C-y] #'eat-yank)
|
(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 [?\C-c ?\C-e] #'eat-eshell-emacs-mode)
|
||||||
(define-key map [remap insert-char] #'eat-input-char)
|
(define-key map [remap insert-char] #'eat-input-char)
|
||||||
map)
|
map)
|
||||||
|
|
Loading…
Add table
Reference in a new issue