From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 19:45:29 +0300 Message-ID: <83v8cwfphy.fsf@gnu.org> References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29648"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, dm@mssdvd.com To: Eshel Yaron Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 30 18:47:18 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 1qbOLd-0007U4-3i for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Aug 2023 18:47:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbOLJ-00078C-2x; Wed, 30 Aug 2023 12:46:57 -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 1qbOLH-00076M-2V for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 12:46:55 -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 1qbOLG-0002mh-Q6 for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 12:46:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qbOLO-0007eW-85 for bug-gnu-emacs@gnu.org; Wed, 30 Aug 2023 12:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Aug 2023 16:47:02 +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 Original-Received: via spool by 65604-submit@debbugs.gnu.org id=B65604.169341396929346 (code B ref 65604); Wed, 30 Aug 2023 16:47:02 +0000 Original-Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 16:46:09 +0000 Original-Received: from localhost ([127.0.0.1]:53865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbOKX-0007dF-C9 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 12:46:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbOKT-0007cj-K8 for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 12:46:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbOKF-0002Yz-Tt; Wed, 30 Aug 2023 12:45:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=8+Hi66472oE7bOCGGq3X/0ITf0oe8U/73RXOXDwQdc0=; b=PIzsJvh29E5B KyfYRgaAEZ0vVR5mbM2E9wAiFMdNk/0louMFTZnmZGfkn9AWwALxKVkuavagk7DM5BKMzoBAV2ZX/ PHA3YnOWrbUXGw2UgQ4ptePxfeP8OP1/qwNnlDrTqCx35mr0chgFFxJxvuArW2590wYQQSil6EFVd UAixoVgb4o774APO8FC6VVPQR6F1cZGG3VCoVVUttLN25oiNqfUNBP8XBsBdhHeUOtxU/MUdcrhzu snUwFOIQHGNcy0hG9HxQOXTd1F2uGsNS1Z9K2RSjtYwhMoPMp6K59pDLMMx/M7QPPTY6GGCz+yin6 PKfIXZZfOWZlCUv1fSvHDg==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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:268731 Archived-At: > Cc: jporterbugs@gmail.com, dm@mssdvd.com > Date: Wed, 30 Aug 2023 17:34:51 +0200 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > 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." Always try to avoid possible confusion due to wrong attribution (does "it's" refer to the mode line or to the last command or to the exit code?). So: If a command exits abnormally, Eshel now displays its exit code on the mode line. > Also, shouldn't this also be mentioned in the manual? Of course, it should! > > +(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. Why do you meed :eval at all? AFAIR, having a symbol in the mode line automatically uses its current value when the mode line is redrawn.