From: Jim Porter <jporterbugs@gmail.com>
To: Christopher Howard <christopher@librehacker.com>, 73722@debbugs.gnu.org
Subject: bug#73722: 30.0.91; error calling eshell/clear with no argument
Date: Tue, 15 Oct 2024 10:00:40 -0700 [thread overview]
Message-ID: <2126f0f9-388e-5717-b0af-b7e3ec90e7d9@gmail.com> (raw)
In-Reply-To: <87v7y1p4fi.fsf@librehacker.com>
[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]
On 10/9/2024 10:33 AM, Christopher Howard wrote:
>
> (same with or without emacs -Q)
> 1. M-x eshell
> 2. clear <return>
>
> Gives error "wrong-type-argument listp progn".
I think this is probably the result of some improvements I've made to
Eshell's command evaluator that revealed a latent bug in 'eshell/clear'
(it actually runs a *second* Eshell command consisting only of newlines,
which shouldn't be necessary).
The actual error reported here is fixed in Emacs 31; in Emacs 30,
'eshell-do-eval' mis-evaluates an empty '(progn)', but that generally
shouldn't occur except in odd cases like this. The "clear" command still
doesn't *work* correctly in Emacs 31 though.
Attached is the smallest fix I could come up with for this. This is made
somewhat more complex due to 'eshell/clear' also being used as an
interactive Emacs-level command. The two forms ("clear" at an Eshell
prompt and "M-x eshell/clear" in Emacs) should probably be separate
functions entirely since they behave differently regarding the current
prompt, but for the sake of compatibility, let's keep them fused
together for now...
Eli, does this look ok for the release branch? It fixes a regression
from Emacs 29 and adds a pair of regression tests to prevent future
breakage. (If and when this merges, I'll see about a more-thorough fix
for the master branch too.)
[-- Attachment #2: 0001-Fix-error-when-calling-clear-in-Eshell.patch --]
[-- Type: text/plain, Size: 2853 bytes --]
From 4c868dbad546b604076ab7c33839b4d3b5919f32 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 10 Oct 2024 21:03:45 -0700
Subject: [PATCH] Fix error when calling "clear" in Eshell.
* lisp/eshell/esh-mode.el (eshell/clear): Fix error, and improve
handling for using as an interactive Emacs command.
* test/lisp/eshell/esh-mode-tests.el
(esh-mode-test/clear/eshell-command, esh-mode-test/clear/emacs-command):
New tests.
---
lisp/eshell/esh-mode.el | 7 +++++--
test/lisp/eshell/esh-mode-tests.el | 23 +++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 34ce82cfbc4..78e43e84173 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -869,8 +869,11 @@ eshell/clear
(if scrollback
(eshell/clear-scrollback)
(let ((eshell-input-filter-functions nil))
- (insert (make-string (window-size) ?\n))
- (eshell-send-input))))
+ (eshell-interactive-print (make-string (window-size) ?\n))
+ (when (and (null eshell-current-handles)
+ (eshell-using-module 'eshell-prompt))
+ (declare-function eshell-emit-prompt "em-prompt" ())
+ (eshell-emit-prompt)))))
(defun eshell/clear-scrollback ()
"Clear the scrollback content of the eshell window."
diff --git a/test/lisp/eshell/esh-mode-tests.el b/test/lisp/eshell/esh-mode-tests.el
index 306e11ce445..896931c47f6 100644
--- a/test/lisp/eshell/esh-mode-tests.el
+++ b/test/lisp/eshell/esh-mode-tests.el
@@ -26,6 +26,8 @@
(require 'ert)
(require 'esh-mode)
(require 'eshell)
+(require 'em-banner)
+(require 'em-prompt)
(require 'eshell-tests-helpers
(expand-file-name "eshell-tests-helpers"
@@ -59,4 +61,25 @@ esh-mode-test/handle-control-codes/backspace
(eshell-match-command-output (format "(format \"hello%c%cp\")" ?\C-h ?\C-h)
"\\`help\n")))
+(ert-deftest esh-mode-test/clear/eshell-command ()
+ "Test that `eshell/clear' works as an Eshell command."
+ (let ((eshell-banner-message "")
+ (eshell-prompt-function (lambda () "$ ")))
+ (with-temp-eshell
+ (eshell-insert-command "echo hi")
+ (eshell-insert-command "clear")
+ (should (string-match "\\$ echo hi\nhi\n\\$ clear\n+\\$ "
+ (buffer-string))))))
+
+(ert-deftest esh-mode-test/clear/emacs-command ()
+ "Test that `eshell/clear' works as an interactive Emacs command."
+ (let ((eshell-banner-message "")
+ (eshell-prompt-function (lambda () "$ ")))
+ (with-temp-eshell
+ (eshell-insert-command "echo hi")
+ (insert "echo b")
+ (eshell/clear)
+ (should (string-match "\\$ echo hi\nhi\n\\$ \n+\\$ echo b"
+ (buffer-string))))))
+
;; esh-mode-tests.el ends here
--
2.25.1
next prev parent reply other threads:[~2024-10-15 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 17:33 bug#73722: 30.0.91; error calling eshell/clear with no argument Christopher Howard
2024-10-15 17:00 ` Jim Porter [this message]
2024-10-15 18:04 ` Eli Zaretskii
2024-10-15 21:31 ` Jim Porter
2024-10-16 5:17 ` Eli Zaretskii
2024-10-16 18:04 ` Jim Porter
2024-10-17 4:47 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2126f0f9-388e-5717-b0af-b7e3ec90e7d9@gmail.com \
--to=jporterbugs@gmail.com \
--cc=73722@debbugs.gnu.org \
--cc=christopher@librehacker.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).