From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 17:34:51 +0200 Message-ID: References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16584"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: jporterbugs@gmail.com, dm@mssdvd.com To: 65604@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 30 17:36:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qbNF1-00047v-4m for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Aug 2023 17:36:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbNEe-0007f0-9E; Wed, 30 Aug 2023 11:36:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbNEZ-0007eM-Om for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 11:35:56 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbNEZ-0002dp-Go for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 11:35:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qbNEh-0005pR-3E for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 11:36:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Aug 2023 15:36:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65604 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Davide Masserut via "Bug reports for GNU Emacs, the Swiss army knife of text editors" X-Debbugs-Original-Cc: 65604@debbugs.gnu.org, Jim Porter , Davide Masserut Original-Received: via spool by submit@debbugs.gnu.org id=B.169340971822331 (code B ref -1); Wed, 30 Aug 2023 15:36:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 15:35:18 +0000 Original-Received: from localhost ([127.0.0.1]:53797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbNDy-0005o6-4M for submit@debbugs.gnu.org; Wed, 30 Aug 2023 11:35:18 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:45610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbNDu-0005nZ-2L for submit@debbugs.gnu.org; Wed, 30 Aug 2023 11:35:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbNDh-0006tn-4n for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 11:35:01 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbNDf-0002C8-1h for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 11:35:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1693409697; bh=Am6zsTGMztOjgONs6LDn3m1DFZ8tJrl34LiYLM/BC9g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=cLcLg8GLztplZTWYDnIeQqNce3sQaNu65MdkXa062llnr2ynEgysk9oIbAgF6x7nG rmWxMAuhJYLmTndDJfEOinvYI1lNtf7mLBWgv0zCKc9ThwSrVHNJPCoFNr+TFNNKHw E2OXJDtNWGfv5F5jyG+oV+Ake5a6BTiQlXppAAlRqKKha0ORxSPY0PeKoqyH7jUD1I OzmCZG6dU75k4WbDXtHUQBgIaCoCIB/yMqzkZ/DkW/W2SAG77WvSwEvsC0mRTMktuI 9EEygVvUyYUvKxj7zhhh2vjMlpzksg5CEGLewbfTMfU0u5wHL1l19VEQ4LKjNveeBg bkBYkYh7tRd/Q== In-Reply-To: <87o7iolg6o.fsf@mssdvd.com> (Davide Masserut via's message of "Wed, 30 Aug 2023 11:18:49 +0200") Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268721 Archived-At: Hello Davide, This looks interesting, a couple of thoughts: > From 8b9f3870e00cdf920e803d92138a9bb0f3c3b645 Mon Sep 17 00:00:00 2001 > From: Davide Masserut > 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)