unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 65604@debbugs.gnu.org
Cc: jporterbugs@gmail.com, dm@mssdvd.com
Subject: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell
Date: Wed, 30 Aug 2023 17:34:51 +0200	[thread overview]
Message-ID: <m1ttsglf1g.fsf@eshelyaron.com> (raw)
In-Reply-To: <87o7iolg6o.fsf@mssdvd.com> (Davide Masserut via's message of "Wed, 30 Aug 2023 11:18:49 +0200")

Hello Davide,

This looks interesting, a couple of thoughts:

> From 8b9f3870e00cdf920e803d92138a9bb0f3c3b645 Mon Sep 17 00:00:00 2001
> From: Davide Masserut <dm@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)





  parent reply	other threads:[~2023-08-30 15:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 22:24 bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-30  1:52 ` Jim Porter
2023-08-30  9:18   ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-30 15:26     ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-30 15:34     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-30 16:45       ` Eli Zaretskii
2023-08-30 16:58         ` Eli Zaretskii
2023-08-30 19:02         ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-30 19:25           ` Eli Zaretskii
2023-08-30 19:59             ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-30 20:20               ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-31  4:52               ` Eli Zaretskii
2023-08-31  9:31                 ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02  5:17                   ` Jim Porter
2023-09-02  8:47                     ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 18:40                       ` Jim Porter
2023-09-02 18:54                         ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 22:46                           ` Jim Porter
2023-09-10 14:44                             ` Sean Whitton

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=m1ttsglf1g.fsf@eshelyaron.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65604@debbugs.gnu.org \
    --cc=dm@mssdvd.com \
    --cc=jporterbugs@gmail.com \
    --cc=me@eshelyaron.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).