GNU bug report logs - #65604
[PATCH] Display the exit code if the last command failed in Eshell

Previous Next

Package: emacs;

Reported by: Davide Masserut <dm <at> mssdvd.com>

Date: Tue, 29 Aug 2023 22:45:01 UTC

Severity: normal

Tags: patch

Fixed in version 30.1

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: Davide Masserut via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: 65604 <at> debbugs.gnu.org, Jim Porter <jporterbugs <at> gmail.com>,
 Davide Masserut <dm <at> mssdvd.com>
Subject: Re: bug#65604: [PATCH] Display the exit code if the last command
 failed in Eshell
Date: Wed, 30 Aug 2023 17:34:51 +0200
Hello Davide,

This looks interesting, a couple of thoughts:

> From 8b9f3870e00cdf920e803d92138a9bb0f3c3b645 Mon Sep 17 00:00:00 2001
> From: Davide Masserut <dm <at> mssdvd.com>
> Date: Wed, 30 Aug 2023 16:38:07 +0200
> Subject: [PATCH] Display the exit code if the last command failed in Eshell
>

[...]

> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -370,6 +370,9 @@ to load the edited aliases.
>  Running 'rgrep' in Eshell now uses the Emacs grep facility instead of
>  calling external rgrep.
>  
> +---
> +*** If the last command failed, its exit code is now displayed in the modeline.
> +

I suggest a small rephrase to avoid the passive voice:
"Eshell now displays the exit code of the last command in the mode line
when it's non-zero."

Also, shouldn't this also be mentioned in the manual?

> +(defun eshell-update-last-command-status (exit-code)
> +  "Set `eshell-last-command-status' to EXIT-CODE and update `mode-line-process'."
> +  (setq mode-line-process
> +        (when (> exit-code 0)
> +            (list
> +             (let ((out-string (format ":[%s]" exit-code))
> +                   (msg (format "Last command exited with code %s" exit-code)))
> +               (propertize out-string
> +                           'help-echo msg
> +                           'face 'compilation-mode-line-fail))))
> +        eshell-last-command-status exit-code))
> +

You should be able to use an `:eval` mode line construct here instead of
resetting `mode-line-process` after each command this way.  This would
allow other code to extend modify `mode-line-process` as well, without
having the modification undone after each command.


Best,

Eshel (no relation to Eshell)




This bug report was last modified 1 year and 256 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.