aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/eshell
diff options
context:
space:
mode:
authorJim Porter2024-10-10 21:03:45 -0700
committerJim Porter2024-10-31 22:36:16 -0700
commit98e24e369a3f6bed95cdf0b32ee03999f5dfb98b (patch)
treea591755972ef901f2d11afec5103a3a5ccd3788a /test/lisp/eshell
parent9ff155183ca560fc9005027a65c53544afb772a1 (diff)
downloademacs-98e24e369a3f6bed95cdf0b32ee03999f5dfb98b.tar.gz
emacs-98e24e369a3f6bed95cdf0b32ee03999f5dfb98b.zip
Fix and improve behavior of 'eshell/clear'
* lisp/eshell/esh-mode.el (eshell-clear): New function. (eshell/clear): Fix incorrect behavior, and do the right thing when 'eshell-scroll-show-maximum-output' is nil. (eshell/clear-scrollback): Call 'eshell/clear'. * test/lisp/eshell/esh-mode-tests.el (esh-mode-test/clear/eshell-command) (esh-mode-test/clear/eshell-command/erase) (esh-mode-test/clear/emacs-command) (esh-mode-test/clear/emacs-command/erase): New tests. * etc/NEWS: Mention the new 'eshell-command' (bug#73722).
Diffstat (limited to 'test/lisp/eshell')
-rw-r--r--test/lisp/eshell/esh-mode-tests.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-mode-tests.el b/test/lisp/eshell/esh-mode-tests.el
index 306e11ce445..28839eb65cf 100644
--- a/test/lisp/eshell/esh-mode-tests.el
+++ b/test/lisp/eshell/esh-mode-tests.el
@@ -26,6 +26,8 @@
26(require 'ert) 26(require 'ert)
27(require 'esh-mode) 27(require 'esh-mode)
28(require 'eshell) 28(require 'eshell)
29(require 'em-banner)
30(require 'em-prompt)
29 31
30(require 'eshell-tests-helpers 32(require 'eshell-tests-helpers
31 (expand-file-name "eshell-tests-helpers" 33 (expand-file-name "eshell-tests-helpers"
@@ -59,4 +61,44 @@
59 (eshell-match-command-output (format "(format \"hello%c%cp\")" ?\C-h ?\C-h) 61 (eshell-match-command-output (format "(format \"hello%c%cp\")" ?\C-h ?\C-h)
60 "\\`help\n"))) 62 "\\`help\n")))
61 63
64(ert-deftest esh-mode-test/clear/eshell-command ()
65 "Test that `eshell/clear' works as an Eshell command."
66 (let ((eshell-banner-message "")
67 (eshell-prompt-function (lambda () "$ ")))
68 (with-temp-eshell
69 (eshell-insert-command "echo hi")
70 (eshell-insert-command "clear")
71 (should (string-match "\\`\\$ echo hi\nhi\n\\$ clear\n+\\$ "
72 (buffer-string))))))
73
74(ert-deftest esh-mode-test/clear/eshell-command/erase ()
75 "Test that `eshell/clear' can erase the buffer."
76 (let ((eshell-banner-message "")
77 (eshell-prompt-function (lambda () "$ ")))
78 (with-temp-eshell
79 (eshell-insert-command "echo hi")
80 (eshell-insert-command "clear t")
81 (should (string-match "\\`\\$ " (buffer-string))))))
82
83(ert-deftest esh-mode-test/clear/emacs-command ()
84 "Test that `eshell-clear' works as an interactive Emacs command."
85 (let ((eshell-banner-message "")
86 (eshell-prompt-function (lambda () "$ ")))
87 (with-temp-eshell
88 (eshell-insert-command "echo hi")
89 (insert "echo b")
90 (eshell-clear)
91 (should (string-match "\\`\\$ echo hi\nhi\n\n+\\$ echo b"
92 (buffer-string))))))
93
94(ert-deftest esh-mode-test/clear/emacs-command/erase ()
95 "Test that `eshell-clear' can erase the buffer."
96 (let ((eshell-banner-message "")
97 (eshell-prompt-function (lambda () "$ ")))
98 (with-temp-eshell
99 (eshell-insert-command "echo hi")
100 (insert "echo b")
101 (eshell-clear t)
102 (should (string-match "\\`\\$ echo b" (buffer-string))))))
103
62;; esh-mode-tests.el ends here 104;; esh-mode-tests.el ends here