]> git.eshelyaron.com Git - emacs.git/commitdiff
When deleting output in Eshell, optionally add it to the kill ring.
authorTomas Volf <~@wolfsden.cz>
Fri, 16 Feb 2024 02:23:23 +0000 (18:23 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 17 Feb 2024 07:23:01 +0000 (08:23 +0100)
* lisp/eshell/esh-mode.el (eshell-kill-output): Rename to...
(eshell-delete-output): ... this, for consistency with 'comint-mode',
and accept KILL argument.  Update callers.

Copyright-paperwork-exempt: yes
(cherry picked from commit 572d58b5e8d0f1f1244b9ccab8f02c4f50ca8d12)

lisp/eshell/esh-mode.el

index fd279f61673f2f4f956ae33705f75f28d5ad6de5..b15f99a03597a9d8ffd819f0bb612f9a71ac8b28 100644 (file)
@@ -290,7 +290,7 @@ non-interactive sessions, such as when using `eshell-command'.")
   "C-e" #'eshell-show-maximum-output
   "C-f" #'eshell-forward-argument
   "C-m" #'eshell-copy-old-input
-  "C-o" #'eshell-kill-output
+  "C-o" #'eshell-delete-output
   "C-r" #'eshell-show-output
   "C-t" #'eshell-truncate-buffer
   "C-u" #'eshell-kill-input
@@ -832,15 +832,23 @@ This function should be in the list `eshell-output-filter-functions'."
       eshell-last-output-start
     eshell-last-output-end))
 
-(defun eshell-kill-output ()
-  "Kill all output from interpreter since last input.
-Does not delete the prompt."
-  (interactive)
+(defun eshell-delete-output (&optional kill)
+  "Delete all output from interpreter since last input.
+If KILL is non-nil (interactively, the prefix), save the killed text in
+the kill ring.
+
+This command does not delete the prompt."
+  (interactive "P")
   (save-excursion
     (goto-char (eshell-beginning-of-output))
     (insert "*** output flushed ***\n")
+    (when kill
+      (copy-region-as-kill (point) (eshell-end-of-output)))
     (delete-region (point) (eshell-end-of-output))))
 
+(define-obsolete-function-alias 'eshell-kill-output
+  #'eshell-delete-output "30.1")
+
 (defun eshell-show-output (&optional arg)
   "Display start of this batch of interpreter output at top of window.
 Sets mark to the value of point when this command is run.