From unknown Sat Jun 21 10:17:38 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#65604 <65604@debbugs.gnu.org> To: bug#65604 <65604@debbugs.gnu.org> Subject: Status: [PATCH] Display the exit code if the last command failed in Eshell Reply-To: bug#65604 <65604@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:17:38 +0000 retitle 65604 [PATCH] Display the exit code if the last command failed in E= shell reassign 65604 emacs submitter 65604 Davide Masserut severity 65604 normal tag 65604 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 29 18:44:27 2023 Received: (at submit) by debbugs.gnu.org; 29 Aug 2023 22:44:27 +0000 Received: from localhost ([127.0.0.1]:51777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qb7Ri-0002IP-7Q for submit@debbugs.gnu.org; Tue, 29 Aug 2023 18:44:27 -0400 Received: from lists.gnu.org ([2001:470:142::17]:38488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qb7Rf-0002IA-3Y for submit@debbugs.gnu.org; Tue, 29 Aug 2023 18:44:24 -0400 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 1qb7RS-0004x9-8u for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 18:44:10 -0400 Received: from out-248.mta0.migadu.com ([91.218.175.248]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb7RO-0002i0-OT for bug-gnu-emacs@gnu.org; Tue, 29 Aug 2023 18:44:10 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693349034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=G/MVQE88Dp2Kwul2RNOKDmHHETyRzOKn3VCoQ0shVq8=; b=vJ6zFLO4MzLWHggyQH6SeXlZ5YI0ED6yDH3yjcYaS/FcVbg7UdEHueHVfRL4Uh50Ms/Cae RX+PTg3fJC13hUW4Sbke8rcxKFezr5gvIvrH+ag1hd5G6wfMkckBKIHe2fl3lOvDgNHF4f LxlvSDR0MSwmIKuyP3eop6S6P4vUOaRfxM+odG8vFk37erOw/N9YL+UxsuZFSQAhV4Zvvj A7kQWYctG30roZvMOU/8Nt/JPa6OVcQbnGdy4ue+qe2EF7XTwN0pseH/b82+NXzLNBp/Si 5TTSmbLUqkrhU4QwK6UhA7c2G1Dr2MQQfPmgvSvZK12+825SEfRKG4dqisHsoA== From: Davide Masserut To: bug-gnu-emacs@gnu.org Subject: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 00:24:28 +0200 Message-ID: <87cyz5wjtm.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.248; envelope-from=dm@mssdvd.com; helo=out-248.mta0.migadu.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_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain; format=flowed Tags: patch There are commands that fail without printing any messages, but set specific error codes. This patch extends the default prompt function to show the exit code of the previous failed command. Before: ~ $ false ~ $ After: ~ $ false ~ [1] $ I believe this is a good default, since it is displayed only when a error occurs and hopefully makes debugging easier by showing the error code without further input. In GNU Emacs 30.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-29 built on T480s Repository revision: ed77dc17f657d99ccf23778c14f06f7226f478f0 Repository branch: master System Description: Arch Linux Configured using: 'configure -C --prefix /home/davide/.local --with-pgtk --with-native-compilation --enable-link-time-optimization --enable-locallisppath=/usr/share/emacs/site-lisp/ 'CFLAGS=-march=native -O2'' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Display-the-exit-code-if-the-last-command-failed-in-.patch >From a0e2f7bda33767e8ce104dd32c76e4d3d6c1a2f8 Mon Sep 17 00:00:00 2001 From: Davide Masserut Date: Tue, 29 Aug 2023 22:33:48 +0200 Subject: [PATCH] Display the exit code if the last command failed in Eshell * etc/NEWS: Announce change. * lisp/eshell/em-prompt.el (eshell-prompt-function): Insert the exit code if last command failed. * lisp/eshell/esh-io.el (eshell-last-command-status): Make it buffer-local. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test/after-failure) (em-prompt-test/next-previous-prompt-with) (em-prompt-test/forward-backward-matching-input-with): New tests. --- etc/NEWS | 3 +++ lisp/eshell/em-prompt.el | 2 ++ lisp/eshell/esh-io.el | 2 +- test/lisp/eshell/em-prompt-tests.el | 37 +++++++++++++++++++++++++---- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 9a98db8c83a..9622e57f476 100644 --- 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. +--- +*** The Eshell prompt now shows the exit code if the last command failed. + ** Pcomplete --- diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 42f8f273b52..692b579d02d 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -50,6 +50,8 @@ eshell-prompt-load-hook (defcustom eshell-prompt-function (lambda () (concat (abbreviate-file-name (eshell/pwd)) + (unless (eshell-exit-success-p) + (format " [%d]" eshell-last-command-status)) (if (= (file-user-uid) 0) " # " " $ "))) "A function that returns the Eshell prompt string. Make sure to update `eshell-prompt-regexp' so that it will match your diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..cd0cee6e21d 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -170,7 +170,7 @@ eshell-redirection-operators-alist (defvar eshell-current-handles nil) -(defvar eshell-last-command-status 0 +(defvar-local eshell-last-command-status 0 "The exit code from the last command. 0 if successful.") (defvar eshell-last-command-result nil diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 93bf9d84ab3..c90f417cefd 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -34,6 +34,25 @@ ;;; Tests: +(ert-deftest em-prompt-test/after-failure () + "Check that current prompt shows the exit code of the last failed command." + (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) + (let ((current-prompt (field-string (1- (point))))) + (should (equal-including-properties + current-prompt + (propertize + (concat (directory-file-name default-directory) + (unless (eshell-exit-success-p) + (format " [%d]" eshell-last-command-status)) + (if (= (file-user-uid) 0) " # " " $ ")) + 'read-only t + 'field 'prompt + 'font-lock-face 'eshell-prompt + 'front-sticky '(read-only field font-lock-face) + 'rear-nonsticky '(read-only field font-lock-face))))))) + (ert-deftest em-prompt-test/field-properties () "Check that field properties are properly set on Eshell output/prompts." (with-temp-eshell @@ -88,6 +107,8 @@ em-prompt-test--with-multiline (defun em-prompt-test/next-previous-prompt-with () "Helper for checking forward/backward navigation of old prompts." (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. (eshell-insert-command "echo one") (eshell-insert-command "echo two") (eshell-insert-command "echo three") @@ -99,8 +120,11 @@ em-prompt-test/next-previous-prompt-with (end-of-line) (eshell-previous-prompt 2) (should (equal (eshell-get-old-input) "echo one")) - ;; Go forward three prompts. - (eshell-next-prompt 3) + ;; Go back one prompt. + (eshell-previous-prompt 1) + (should (equal (eshell-get-old-input) "(zerop \"foo\")")) + ;; Go forward four prompts. + (eshell-next-prompt 4) (should (equal (eshell-get-old-input) "echo fou")))) (ert-deftest em-prompt-test/next-previous-prompt () @@ -115,6 +139,8 @@ em-prompt-test/next-previous-prompt-multiline (defun em-prompt-test/forward-backward-matching-input-with () "Helper for checking forward/backward navigation via regexps." (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. (eshell-insert-command "echo one") (eshell-insert-command "printnl something else") (eshell-insert-command "echo two") @@ -127,8 +153,11 @@ em-prompt-test/forward-backward-matching-input-with (end-of-line) (eshell-backward-matching-input "echo" 2) (should (equal (eshell-get-old-input) "echo one")) - ;; Go forward three prompts. - (eshell-forward-matching-input "echo" 3) + ;; Go back one prompt. + (eshell-previous-prompt 1) + (should (equal (eshell-get-old-input) "(zerop \"foo\")")) + ;; Go forward four prompts. + (eshell-forward-matching-input "echo" 4) (should (equal (eshell-get-old-input) "echo fou")))) (ert-deftest em-prompt-test/forward-backward-matching-input () -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 29 21:52:59 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 01:52:59 +0000 Received: from localhost ([127.0.0.1]:51861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbAOB-00074J-3X for submit@debbugs.gnu.org; Tue, 29 Aug 2023 21:52:59 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45219) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbAO6-000744-Ro for 65604@debbugs.gnu.org; Tue, 29 Aug 2023 21:52:58 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-565439b6b3fso2107313a12.2 for <65604@debbugs.gnu.org>; Tue, 29 Aug 2023 18:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693360361; x=1693965161; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=V5kRtvR3dMDuprhKEM/NJzPM55GlkrPZjm1BK4qgRMs=; b=l/CPM4ui8QmxvJocxpcuPL5M9mARB609lcspE4jKODoxeTHGLT+QsQqBWBgBwQUFxC qcOfchLQBhFjkIRBot55d6UdOmfdghT6dC1H+GkFqnG5Ijwnshh4/s7dIu8oeZkQGe0y arOu7fm/dUToXLFd5eACBzXU5vicJxyZdgG7EXqGlUaD9A+FnCAtD/v6PF3gi37ia8yH rlZrro2cAJC25nduJm5mYSwMYrtef72iTarJotGe1YTWfAdaqbZ/pFJMAu7jiataopja q/Aav/xRu0ZwRd3kFZbkoQxw6bAIVq4TI5nbbbuub5poG1UmKfiLXWnnqLW/6FDR16HB 5FUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693360361; x=1693965161; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V5kRtvR3dMDuprhKEM/NJzPM55GlkrPZjm1BK4qgRMs=; b=DDL2I+Vp1GNzOkz94XCQe1sqXOIdGQ4T2kSN4SAHTe0H/Ne8xsCk3aWkEVwSjIBYqF rW6LmrBvJS9KNdcYv2wZ056S/dLb/V73raPxVWu3TFRBqk3P8r37FzpVUN4blnG4Hve7 dlonMT0uYXGM73VOpDHVnKjoaW96BxeC8pEbLcHuaMOc0tHwCxvKyDdG85JSzMk3ckyU w2d8HGq6Pr5tWV2VzRuiyEFggFN2gBVwh/C8gt9ijaV0amMjVAr3AyHE0JBgGUc6jL9j Irnpkfssg7eMe3Rrzbm0VCwoZtKXvhet3x2hkv08bKe+bHqZo+eH7znZ0lBvTyQwgBci gRUA== X-Gm-Message-State: AOJu0YyvWIeFHtk7IAjxOpB7TJ1ott9PcqcymxPpwWdTz7FJTM6S0Cgf Uwa2AJv8vR0jZ0+XSpEfbDMEnlnr8Fg= X-Google-Smtp-Source: AGHT+IEoD1cU1vrpNZhoG/hEILPzdatRovw4Rx3Gbdqkuw+UBbDW4J005g55tVGaQRYwKxwpSmNzCg== X-Received: by 2002:a17:90a:d494:b0:268:f987:305d with SMTP id s20-20020a17090ad49400b00268f987305dmr891220pju.5.1693360361537; Tue, 29 Aug 2023 18:52:41 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id d23-20020a17090a115700b00264040322desm244513pje.40.2023.08.29.18.52.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Aug 2023 18:52:41 -0700 (PDT) Message-ID: <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> Date: Tue, 29 Aug 2023 18:52:40 -0700 MIME-Version: 1.0 Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Content-Language: en-US To: Davide Masserut , 65604@debbugs.gnu.org References: <87cyz5wjtm.fsf@mssdvd.com> From: Jim Porter In-Reply-To: <87cyz5wjtm.fsf@mssdvd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8/29/2023 3:24 PM, Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Tags: patch > > There are commands that fail without printing any messages, but set > specific error codes. > > This patch extends the default prompt function to show the exit code of > the previous failed command. Thanks. I think this makes sense as an option, but I wonder if this is the right default place to put it. Instead, what about putting the exit status in the mode-line, like with compilation buffers? Eshell already uses the mode-line to show when a command is running, so I think it's an obvious enhancement to show the status of a command that just finished running. This does mean you don't see the *history* of failed commands, but it still provides useful feedback for users without requiring a change to the prompt (which is a bit more in-your-face). In the future, I hope to make it easier for people to customize the Eshell prompt without writing (as much) Elisp, e.g. by defining it the same way we can define the mode-line. However, I haven't finished up that patch yet, so it's sitting on one of my pile of local branches... From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 11:10:28 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 15:10:28 +0000 Received: from localhost ([127.0.0.1]:53759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbMpv-0005AY-Ix for submit@debbugs.gnu.org; Wed, 30 Aug 2023 11:10:28 -0400 Received: from out-247.mta1.migadu.com ([2001:41d0:203:375::f7]:53618) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbMpr-0005AL-3i for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 11:10:27 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693408212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=G35xytxy6VU+wfcKoyeqBnMDVMs/KOd8WT7IZrW8tC0=; b=XdEPkhlMqk51FaThJwgSkJbLILT4m/8TlQqsyg3GJGa+LvV/f1YF6lWp+yT6UWfDRaoVDj FWuRrEm9pyHRW6KMYfdHpIcQosptrMWxlmgXsT2bURyTzRKIxhgWjopUA2SeXisTUnkN0o RQXVf9RU+/UxZ5d7RWg1NmELnJI1ZFekWdoJNdLiJH6zb6nrT3PFYzPJJfZbt+NdoFByqZ kgKf0zX+gEcCdOIqduxuHeecn1PlpyjWQGozWnIcnYu8GOP6UABXPKeTxhBrCIdZtilfU2 wKSGeu+qx9lhBnz2JyGgpjg0GSCv0R0eG//tZ7hmCzznxh2bOQHOrm2pMjWdog== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Jim Porter Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 11:18:49 +0200 In-reply-to: <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> Message-ID: <87o7iolg6o.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Jim Porter writes: > Thanks. I think this makes sense as an option, but I wonder if > this is > the right default place to put it. Instead, what about putting > the > exit status in the mode-line, like with compilation [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 1.1 DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.1 (/) --=-=-= Content-Type: text/plain; format=flowed Jim Porter writes: > Thanks. I think this makes sense as an option, but I wonder if > this is > the right default place to put it. Instead, what about putting > the > exit status in the mode-line, like with compilation buffers? > Eshell > already uses the mode-line to show when a command is running, so > I > think it's an obvious enhancement to show the status of a > command that > just finished running. This does mean you don't see the > *history* of > failed commands, but it still provides useful feedback for users > without requiring a change to the prompt (which is a bit more > in-your-face). I have made the changes you suggested. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Display-the-exit-code-if-the-last-command-failed-in-.patch >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 * etc/NEWS: Announce change. * lisp/eshell/esh-cmd.el (eshell-exec-lisp): (eshell-lisp-command): Use new helper function. * lisp/eshell/esh-io.el: (eshell-close-handles): Use new helper function. (eshell-update-last-command-status): Add new helper function. * test/lisp/eshell/em-io-tests.el (em-io-test/modeline-after-failure): Add new test. --- etc/NEWS | 3 +++ lisp/eshell/esh-cmd.el | 8 ++++---- lisp/eshell/esh-io.el | 15 ++++++++++++++- test/lisp/eshell/esh-io-tests.el | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 9a98db8c83a..810172e3b11 100644 --- 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. + ** Pcomplete --- diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 80066263396..3672481a66a 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1407,10 +1407,10 @@ eshell-exec-lisp ;; command status to some non-zero value to indicate an error; to ;; match GNU/Linux, we use 141, which the numeric value of ;; SIGPIPE on GNU/Linux (13) with the high bit (2^7) set. - (setq eshell-last-command-status 141) + (eshell-update-last-command-status 141) nil) (error - (setq eshell-last-command-status 1) + (eshell-update-last-command-status 1) (let ((msg (error-message-string err))) (if (and (not form-p) (string-match "^Wrong number of arguments" msg) @@ -1481,8 +1481,8 @@ eshell-lisp-command (unless eshell-allow-commands (signal 'eshell-commands-forbidden '(lisp))) (catch 'eshell-external ; deferred to an external command - (setq eshell-last-command-status 0 - eshell-last-arguments args) + (eshell-update-last-command-status 0) + (setq eshell-last-arguments args) (let* ((eshell-ensure-newline-p (eshell-interactive-output-p)) (command-form-p (functionp object)) (result diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..d734a83e02f 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -70,6 +70,7 @@ (require 'esh-arg) (require 'esh-util) +(require 'compile) (eval-when-compile (require 'cl-lib)) @@ -362,7 +363,7 @@ eshell-close-handles RESULT is the quoted value of the last command. If nil, then use the value already set in `eshell-last-command-result'." (when exit-code - (setq eshell-last-command-status exit-code)) + (eshell-update-last-command-status exit-code)) (when result (cl-assert (eq (car result) 'quote)) (setq eshell-last-command-result (cadr result))) @@ -670,5 +671,17 @@ eshell-output-object (dolist (target targets) (eshell-output-object-to-target object target)))) +(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)) + (provide 'esh-io) ;;; esh-io.el ends here diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index ce80f3a8f08..c134f262007 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -23,6 +23,7 @@ (require 'ert-x) (require 'esh-mode) (require 'eshell) +(require 'compile) (require 'eshell-tests-helpers (expand-file-name "eshell-tests-helpers" @@ -370,4 +371,18 @@ esh-io-test/virtual/dev-kill (eshell-insert-command "echo three >> /dev/kill") (should (equal (car kill-ring) "twothree")))) +(ert-deftest esh-io-test/modeline-after-failure () + "Check that exit code is displayed after a failure." + (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. + (should (equal-including-properties + mode-line-process + (list + (let ((out-string (format ":[%s]" eshell-last-command-status)) + (msg (format "Last command exited with code %s" eshell-last-command-status))) + (propertize out-string + 'help-echo msg + 'face 'compilation-mode-line-fail))))))) + ;;; esh-io-tests.el ends here -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 11:29:28 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 15:29:28 +0000 Received: from localhost ([127.0.0.1]:53775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbN8J-0005cd-KU for submit@debbugs.gnu.org; Wed, 30 Aug 2023 11:29:28 -0400 Received: from out-248.mta0.migadu.com ([91.218.175.248]:45555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbN8E-0005cM-Pp for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 11:29:25 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693409353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+xPd8dkz5YNTu0GGfUTnWK+fyOm1r5dR2NDhYziczNg=; b=bZf1tx0w+8NmA0G9P5iVlfpG4bMCmeZwoudFb2DiruEXE+PivkCrxO39wvkFBoiwLSLztj TWT6+01rgXfx4vbFvH18ojwo+FUsnv3w5M6lWiSVj77zEvHq9vMZ9rp1kYPoTyGX9oELPc IQ9HW3DcmjiZIPokkCnUvvUFou1Iqw3ElpUEuH0G+Phc8XZ1PLDJaq1ucmc76gvbti0TnA We+0ySYbkJxKEl0GEGnJ+3CgloxdKSavq3cp49hF4unocyFzkJpQMqfyyxuRqpnBYKgCLX 3U1MhYf/25HGRoOsCvOkwCyXPeA+sE0dPyWiO3SrMzmsAj6EyOcdMsSny0fc3Q== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Davide Masserut Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 17:26:27 +0200 In-reply-to: <87o7iolg6o.fsf@mssdvd.com> Message-ID: <87jztclfb1.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, Jim Porter X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; format=flowed Sorry, I forgot to make a variable buffer-local. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Display-the-exit-code-if-the-last-command-failed-in-.patch >From d418c7a9a88cc2c5aff2e0ff7ad9681c0c0016bb 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 * etc/NEWS: Announce change. * lisp/eshell/esh-cmd.el (eshell-exec-lisp): (eshell-lisp-command): Use new helper function. * lisp/eshell/esh-io.el: (eshell-close-handles): Use new helper function. (eshell-update-last-command-status): Add new helper function. * test/lisp/eshell/em-io-tests.el (em-io-test/modeline-after-failure): Add new test. --- etc/NEWS | 3 +++ lisp/eshell/esh-cmd.el | 8 ++++---- lisp/eshell/esh-io.el | 17 +++++++++++++++-- test/lisp/eshell/esh-io-tests.el | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 9a98db8c83a..810172e3b11 100644 --- 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. + ** Pcomplete --- diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 80066263396..3672481a66a 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1407,10 +1407,10 @@ eshell-exec-lisp ;; command status to some non-zero value to indicate an error; to ;; match GNU/Linux, we use 141, which the numeric value of ;; SIGPIPE on GNU/Linux (13) with the high bit (2^7) set. - (setq eshell-last-command-status 141) + (eshell-update-last-command-status 141) nil) (error - (setq eshell-last-command-status 1) + (eshell-update-last-command-status 1) (let ((msg (error-message-string err))) (if (and (not form-p) (string-match "^Wrong number of arguments" msg) @@ -1481,8 +1481,8 @@ eshell-lisp-command (unless eshell-allow-commands (signal 'eshell-commands-forbidden '(lisp))) (catch 'eshell-external ; deferred to an external command - (setq eshell-last-command-status 0 - eshell-last-arguments args) + (eshell-update-last-command-status 0) + (setq eshell-last-arguments args) (let* ((eshell-ensure-newline-p (eshell-interactive-output-p)) (command-form-p (functionp object)) (result diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..96ce08051b4 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -70,6 +70,7 @@ (require 'esh-arg) (require 'esh-util) +(require 'compile) (eval-when-compile (require 'cl-lib)) @@ -170,7 +171,7 @@ eshell-redirection-operators-alist (defvar eshell-current-handles nil) -(defvar eshell-last-command-status 0 +(defvar-local eshell-last-command-status 0 "The exit code from the last command. 0 if successful.") (defvar eshell-last-command-result nil @@ -362,7 +363,7 @@ eshell-close-handles RESULT is the quoted value of the last command. If nil, then use the value already set in `eshell-last-command-result'." (when exit-code - (setq eshell-last-command-status exit-code)) + (eshell-update-last-command-status exit-code)) (when result (cl-assert (eq (car result) 'quote)) (setq eshell-last-command-result (cadr result))) @@ -670,5 +671,17 @@ eshell-output-object (dolist (target targets) (eshell-output-object-to-target object target)))) +(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)) + (provide 'esh-io) ;;; esh-io.el ends here diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index ce80f3a8f08..c134f262007 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -23,6 +23,7 @@ (require 'ert-x) (require 'esh-mode) (require 'eshell) +(require 'compile) (require 'eshell-tests-helpers (expand-file-name "eshell-tests-helpers" @@ -370,4 +371,18 @@ esh-io-test/virtual/dev-kill (eshell-insert-command "echo three >> /dev/kill") (should (equal (car kill-ring) "twothree")))) +(ert-deftest esh-io-test/modeline-after-failure () + "Check that exit code is displayed after a failure." + (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. + (should (equal-including-properties + mode-line-process + (list + (let ((out-string (format ":[%s]" eshell-last-command-status)) + (msg (format "Last command exited with code %s" eshell-last-command-status))) + (propertize out-string + 'help-echo msg + 'face 'compilation-mode-line-fail))))))) + ;;; esh-io-tests.el ends here -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 11:35:18 2023 Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 15:35:18 +0000 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 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 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 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== From: Eshel Yaron To: Davide Masserut via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell In-Reply-To: <87o7iolg6o.fsf@mssdvd.com> (Davide Masserut via's message of "Wed, 30 Aug 2023 11:18:49 +0200") References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> Date: Wed, 30 Aug 2023 17:34:51 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: 65604@debbugs.gnu.org, Jim Porter , Davide Masserut X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) 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) From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 12:46:09 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 16:46:09 +0000 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 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 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==; Date: Wed, 30 Aug 2023 19:45:29 +0300 Message-Id: <83v8cwfphy.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, dm@mssdvd.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 12:59:04 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 16:59:04 +0000 Received: from localhost ([127.0.0.1]:53889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbOX2-00082E-17 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 12:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbOWz-00081h-GV for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 12:59:02 -0400 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 1qbOWl-0005fR-1X; Wed, 30 Aug 2023 12:58:47 -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=jR7mwJH9yKomln6YZaerh5wzEfy6Ndag4pFSSEA0HT0=; b=QaNGRuTHY+TE HlC8isn+AXu+JvqF+/p3ljj4Z18NEs0Bu0CzhceoFZO/3DIOyGYANhQVn4qkTfjpyGKqm05P1nkUA PAf2UHBvTeBpIs9AS7WxyFwC0Aqae8WGwp1JQdfDR6/LVvd5G/jH5vvDEPHZFJ9gIDndn++pw7/d+ IV1DqndjhnIuoqI7ZpXuHBnSnj1VQ5nQIYRIGwpoT4QEAz+gvQ+rDIhu5wH81SquLu7YkdXkuqc+J oFd9vyfQf2MIIebbJQJJYG82ZSzSGExarM1wPBc/STZQHXHE4C8d/R2iJmBjyWV6AUKKWEYzsNwQx ZmrQxKID1+LlaRmAtRejbw==; Date: Wed, 30 Aug 2023 19:58:27 +0300 Message-Id: <83sf80fowc.fsf@gnu.org> From: Eli Zaretskii To: me@eshelyaron.com In-Reply-To: <83v8cwfphy.fsf@gnu.org> (message from Eli Zaretskii on Wed, 30 Aug 2023 19:45:29 +0300) Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, dm@mssdvd.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, dm@mssdvd.com > Date: Wed, 30 Aug 2023 19:45:29 +0300 > From: Eli Zaretskii > > 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. Even better: If a command exits abnormally, Eshel now displays the command's exit code on the mode line. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 15:05:46 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 19:05:46 +0000 Received: from localhost ([127.0.0.1]:54044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbQVe-0002x6-BX for submit@debbugs.gnu.org; Wed, 30 Aug 2023 15:05:46 -0400 Received: from out-242.mta0.migadu.com ([91.218.175.242]:33866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbQVb-0002wx-Nf for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 15:05:44 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693422334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ylyHXCgDGB58nvRa5EbvBmyuEXj/YUcYhLbBO8oTzgU=; b=WRIfDvVRCVYHFYVO9q0Upt3xcEdBX0Q153qFqi63yonzOi3YmAoWmlnBXuRW/SRwZNYZCV PPtlThxJyLqpPn8EHHEwjVFB1OTRtJjKN/R0e1+4dahxQBuAxsn26UtqTGKkhHWllEO+AD k+OQOkF94WiOoRyehctEfGKTNhNKkyEhuCnzJZYvrfsHT+j3fRDOcCs4GyQVGZIWAmtLJ+ /mxiAGo6un2jHLLqpo+5nroj6IyKGllpQs+hqU7mm6YjA4nAjaNYZXivjzl91e+NrUWQpt gxr52e7FB6ZQdhE9cthHJ9+4SP3BrpqRHfNez19ATHtpmK12Pkoa8D3oZFNsTQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Eli Zaretskii Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 21:02:00 +0200 In-reply-to: <83v8cwfphy.fsf@gnu.org> Message-ID: <87wmxc4ah3.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, Eshel Yaron X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > 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. Wouldn't this strip the symbol of its text properties? From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 15:26:15 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 19:26:15 +0000 Received: from localhost ([127.0.0.1]:54096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbQpS-0003Xi-M8 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 15:26:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbQpO-0003XR-HP for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 15:26:13 -0400 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 1qbQpB-0004FC-Dt; Wed, 30 Aug 2023 15:25:57 -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=DmCuHGRWKxiJhlw0ullo1QFZeiXdLvHHxguiuVMLRsM=; b=W1gYIh4RUUCs IEAtWoBECPGyEeq4lzStLeQbxTQqQrieK9d6KB+WbQOZ9fgJRPWGLEOIhy9RvhercyMp/VqUQADUE Pny808AkhhcntHeCM65NEXckHGEee9dK9VOWFUrmrrRDOkg5eXI7VWjfaeTx6oU57t99n/lqBMk3s 9r9tCGXy4add6AZMq+WviHWNKa3aNcGY2ZYd4/o7d/oePs1pvE2P9XEBBkHaK0awibR9TTsJRzMVq WOtWOFmlLEM3Bm/50gUb6wq2ZsyLNCejaebx7AT4PJgLeK6LtjPDokO0P6Y9C1tFED3fb/YeC9T/Q zEFkDxy9A74bWURTCbSIcQ==; Date: Wed, 30 Aug 2023 22:25:34 +0300 Message-Id: <83fs40fi35.fsf@gnu.org> From: Eli Zaretskii To: Davide Masserut In-Reply-To: <87wmxc4ah3.fsf@mssdvd.com> (message from Davide Masserut on Wed, 30 Aug 2023 21:02:00 +0200) Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Davide Masserut > Cc: Eshel Yaron , 65604@debbugs.gnu.org, > jporterbugs@gmail.com > Date: Wed, 30 Aug 2023 21:02:00 +0200 > > Eli Zaretskii writes: > > > 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. > > Wouldn't this strip the symbol of its text properties? Sorry, I don't understand: what symbol and why do we care about its text properties? What I meant is that reference to a symbol in mode-line-format automatically uses the value of that symbol, unless I'm confused or misremembering. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 16:10:56 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 20:10:57 +0000 Received: from localhost ([127.0.0.1]:54185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbRWi-0004kN-JM for submit@debbugs.gnu.org; Wed, 30 Aug 2023 16:10:56 -0400 Received: from out-247.mta0.migadu.com ([91.218.175.247]:35707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbRWd-0004kC-EO for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 16:10:55 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693426242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tWePzGkuKRuaviWCX26azPJCVCYR43LGjTlSCKTtYTI=; b=t+BpcFqViY/etdz2vJb8hFbo1j5lyjMler7UCinwBn2E6bmTmvaLfpe+sVSNpaWdn/TZ/4 7lrODk9tdwtkqLDHoEi/xZSTLWDWXU5DvoppwVbpwuuW18c2i2hwWgIDJsn4atX+R7feer 9KDu9nk/leBhYj8CIFZ3M+eHLrbcBIU/im2Q3o2jmU/tQ9jzpyuJRGqPmpAgZxaH7IVsHw IMD2xjCIFZdK96mw18Q7pprJUEnJMilRC2TWk/9BzG8y/s6iXDIuobXpPb5gLnDo0CBfuD 3rGbe4AaNIiyarS3AFGHvrAmODPcJG187H2AibxGmxcQ2yAqPlmEI+vJTBLo5w== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Eli Zaretskii Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 21:59:35 +0200 In-reply-to: <83fs40fi35.fsf@gnu.org> Message-ID: <87msy8s344.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> > 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. >> >> Wouldn't this strip the symbol of its text properties? > > Sorry, I don't understand: what symbol and why do we care about=20 > its > text properties? > > What I meant is that reference to a symbol in mode-line-format > automatically uses the value of that symbol, unless I'm confused=20 > or > misremembering. "(elisp) Mode Line Data" says: Unless SYMBOL is marked as risky (i.e., it has a non-=E2=80=98nil=E2= =80=99 =E2=80=98risky-local-variable=E2=80=99 property), all text properties= =20 specified in SYMBOL=E2=80=99s value are ignored. This includes the text=20 properties of strings in SYMBOL=E2=80=99s value, as well as all =E2=80=98:eval=E2=80= =99 and=20 =E2=80=98:propertize=E2=80=99 forms in it. (The reason for this is security: non-risky=20 variables could be set automatically from file variables without=20 prompting the user.) Given this code: (defun eshell-mode-line-exit-code () (when (> eshell-last-command-status 0) (propertize (format ":[%s]" eshell-last-command-status) 'help-echo (format "Last command exited with code %s" eshell-last-command-status) 'face 'compilation-mode-line-fail))) (setq-local mode-line-process 'eshell-mode-line-exit-code) Doesn't it mean that unless we mark it "risky-local-variable",=20 Emacs will remove the "compilation-mode-line-fail" face? From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 30 16:28:53 2023 Received: (at 65604) by debbugs.gnu.org; 30 Aug 2023 20:28:53 +0000 Received: from localhost ([127.0.0.1]:54191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbRo4-0005A4-E5 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 16:28:53 -0400 Received: from out-253.mta0.migadu.com ([2001:41d0:1004:224b::fd]:22702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbRo0-00059n-4C for 65604@debbugs.gnu.org; Wed, 30 Aug 2023 16:28:51 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693427318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kJpuS4iRh+eughlhLwURrLAwVpTnHoiuw3atcJdOVhk=; b=vRt4lva4lBfg55i2oJXUe96tY3lJmQ1rK5G/7wXoeDg+MipZz5P1DoBzYojcTAHxoPXdiU DfbJPEUfNY23R/uvZ55L/4u8z6I3ZPOQlYiYT/BYv72UlEtMiFYQrCz6LQVW1JHsphZVMC i0A1T8VAlm9dgQUgvFTlkVmCduQklPqwDFYjDCgsG1cVI0IPihunieqDf+KDUuQPbgJx9i B4lIDLvFzQXF1Fm1hNOiIz4yQmEX2xfWM9ahO56+33RSH/GIV5towY0GN/mCy92edGo5pd piXU71WBQMv0dQTxNzAQ3AdjldYkCU3TyABPT2SdSSH7kK8gEBEZH24EyXIRnA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Eli Zaretskii , me@eshelyaron.com, 65604@debbugs.gnu.org, jporterbugs@gmail.com Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Wed, 30 Aug 2023 22:20:56 +0200 In-reply-to: <87msy8s344.fsf@mssdvd.com> Message-ID: <87il8ws2aa.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; format=flowed I updated the NEWS file, the manual and used the ":eval" construct to update "mode-line-process". --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Display-the-exit-code-if-the-last-command-failed-in-.patch >From 33e97ff350e1184f97c2867bd689a77291a2c7fd Mon Sep 17 00:00:00 2001 From: Davide Masserut Date: Wed, 30 Aug 2023 21:34:08 +0200 Subject: [PATCH] Display the exit code if the last command failed in Eshell * doc/misc/eshell.texi (Invocation): Document change. * etc/NEWS: Announce change. * lisp/eshell/esh-io.el (eshell-last-command-status): Make it buffer-local. * lisp/eshell/esh-mode.el (compile): Require it for a face. (eshell-mode): Update mode-line-process based on the exit code of the last command. * test/lisp/eshell/esh-io-tests.el (eshell) (esh-io-test/modeline-after-failure): Add test. --- doc/misc/eshell.texi | 3 +++ etc/NEWS | 3 +++ lisp/eshell/esh-io.el | 2 +- lisp/eshell/esh-mode.el | 12 ++++++++++++ test/lisp/eshell/esh-io-tests.el | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index f8f60bae13a..b544e0cda41 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -234,6 +234,9 @@ Invocation can be controlled the same way as any other background process in Emacs. +If a command exits abnormally, Eshell displays the command's exit code +on the mode line. + @subsection Command form Command form looks much the same as in other shells. A command consists of arguments separated by spaces; the first argument is the diff --git a/etc/NEWS b/etc/NEWS index 9a98db8c83a..fe81cfc2477 100644 --- 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 a command exits abnormally, Eshell now displays the command's exit code on the mode line. + ** Pcomplete --- diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..cd0cee6e21d 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -170,7 +170,7 @@ eshell-redirection-operators-alist (defvar eshell-current-handles nil) -(defvar eshell-last-command-status 0 +(defvar-local eshell-last-command-status 0 "The exit code from the last command. 0 if successful.") (defvar eshell-last-command-result nil diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 0c381dbb86a..71ff901c764 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -69,6 +69,8 @@ (require 'esh-util) (require 'esh-var) +(require 'compile) + (defgroup eshell-mode nil "This module contains code for handling input from the user." :tag "User interface" @@ -369,6 +371,16 @@ eshell-mode ;; strong R2L character. (setq bidi-paragraph-direction 'left-to-right) + (setq-local + mode-line-process + '(:eval + (when (> eshell-last-command-status 0) + (propertize + (format ":[%s]" eshell-last-command-status) + 'help-echo (format "Last command exited with code %s" + eshell-last-command-status) + 'face 'compilation-mode-line-fail)))) + ;; load extension modules into memory. This will cause any global ;; variables they define to be visible, since some of the core ;; modules sometimes take advantage of their functionality if used. diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index ce80f3a8f08..349c4332d82 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -23,6 +23,7 @@ (require 'ert-x) (require 'esh-mode) (require 'eshell) +(require 'compile) (require 'eshell-tests-helpers (expand-file-name "eshell-tests-helpers" @@ -370,4 +371,19 @@ esh-io-test/virtual/dev-kill (eshell-insert-command "echo three >> /dev/kill") (should (equal (car kill-ring) "twothree")))) +(ert-deftest esh-io-test/modeline-after-failure () + "Check that exit code is displayed after a failure." + (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. + (should (equal-including-properties + mode-line-process + '(:eval + (when (> eshell-last-command-status 0) + (propertize + (format ":[%s]" eshell-last-command-status) + 'help-echo (format "Last command exited with code %s" + eshell-last-command-status) + 'face 'compilation-mode-line-fail))))))) + ;;; esh-io-tests.el ends here -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 31 00:52:51 2023 Received: (at 65604) by debbugs.gnu.org; 31 Aug 2023 04:52:51 +0000 Received: from localhost ([127.0.0.1]:54590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbZfm-00014b-Us for submit@debbugs.gnu.org; Thu, 31 Aug 2023 00:52:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbZfj-00014M-Mc for 65604@debbugs.gnu.org; Thu, 31 Aug 2023 00:52:48 -0400 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 1qbZfW-0003xg-7p; Thu, 31 Aug 2023 00:52:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=7sSjeRK4EfaqyIST8ugvXC/UVx1TB4bK4kWVWzpx3n4=; b=DZw48cECz2xDrLKU/zws 9NKIUfIdS3fvnAhZA1RCBWSxAwCKs/zPgZi+qVlCl8PQqmwu+xDQTPYbgqON2lOeAemzF2VqnUlGj aZeiWOucEmhuKHcV/WOOHAp1sQ6zIsQXUoiIMpHc8qcr9JRDw3RnhFu9uWcnTb6QQ8/9kiNN37yRg AeODPzQjJ/+CzAcMEseE3TXHtdIBQrGjAzqtqVG846Yeb+3PPntVoTa+oJerb4bxeAihv9WMW0xcL 9JwzhWVvAqI9N+hi+r16Ama2NR9W91zBlfqZaDMMsDV/txUMuqa34+pTUndzKWIBNvu464hUzXxVI lk2dSNC+X6ONEw==; Date: Thu, 31 Aug 2023 07:52:16 +0300 Message-Id: <83a5u7g6f3.fsf@gnu.org> From: Eli Zaretskii To: Davide Masserut In-Reply-To: <87msy8s344.fsf@mssdvd.com> (message from Davide Masserut on Wed, 30 Aug 2023 21:59:35 +0200) Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Davide Masserut > Cc: me@eshelyaron.com, 65604@debbugs.gnu.org, jporterbugs@gmail.com > Date: Wed, 30 Aug 2023 21:59:35 +0200 > > Unless SYMBOL is marked as risky (i.e., it has a non-‘nil’ > ‘risky-local-variable’ property), all text properties > specified in > SYMBOL’s value are ignored. This includes the text > properties of > strings in SYMBOL’s value, as well as all ‘:eval’ and > ‘:propertize’ > forms in it. (The reason for this is security: non-risky > variables > could be set automatically from file variables without > prompting > the user.) > > > Given this code: > > (defun eshell-mode-line-exit-code () > (when (> eshell-last-command-status 0) > (propertize > (format ":[%s]" eshell-last-command-status) > 'help-echo (format "Last command exited with code %s" > eshell-last-command-status) > 'face 'compilation-mode-line-fail))) > > (setq-local mode-line-process 'eshell-mode-line-exit-code) > > Doesn't it mean that unless we mark it "risky-local-variable", > Emacs will remove the "compilation-mode-line-fail" face? Ah, that. Yes, the properties will be ignored. But do we really need fancy faces on that display? (FWIW, I personally don't like the idea of showing this on the mode line: the mode line is already quite cramped, and OTOH Bash does show abnormal exit codes as part of its prompt. But feel free to disregard my opinions, as I'm not a heavy user of Eshell.) From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 31 05:56:14 2023 Received: (at 65604) by debbugs.gnu.org; 31 Aug 2023 09:56:14 +0000 Received: from localhost ([127.0.0.1]:54897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbePM-0003Mz-4E for submit@debbugs.gnu.org; Thu, 31 Aug 2023 05:56:14 -0400 Received: from out-250.mta0.migadu.com ([91.218.175.250]:31636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbePG-0003Mj-Cb for 65604@debbugs.gnu.org; Thu, 31 Aug 2023 05:56:10 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693475756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yFdjiPoyGqTa2vzMmF+yCpuMs/IxEDG3zB6rLmjrk8Y=; b=UDcVjdoD4IT75lCHm+CA6WZXnjGvheV0zhWG0uEfafkrHd2p7Mf70jht4YjYXqE7NMjfvn UzV4mcbISJiZNIDl1oL/6cMhPiyTDo1Z1WY5mz47cFC4UQJEFDM7RBYxAvNLgYeJUMoHuL Lg0YCkiNqvv7fDVDX2fpSdNWzXfLli812uhYRWQtnjOYj5NibnkuIRW4T/XzWe4z9O11Uu 0p9MXv2d4FPWG2IVvOYgHgOY9lJ3WKXuPYuu8TflF1UPfxMOhFSM8SjZyLJPQVa6e8Bepk xYS99Ocd1uXJXOeCD+8hP9sBlaLJH2On87V7dEfAmMyV+vi/nZV6kvj3qh+tIA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Eli Zaretskii Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Thu, 31 Aug 2023 11:31:53 +0200 In-reply-to: <83a5u7g6f3.fsf@gnu.org> Message-ID: <87cyz38rj2.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, jporterbugs@gmail.com, me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Ah, that. Yes, the properties will be ignored. But do we > really need > fancy faces on that display? They make the error stand out. > (FWIW, I personally don't like the idea of showing this on the > mode > line: the mode line is already quite cramped I agree with you, this is one of the main reasons I had in mind when I made the first patch. > and OTOH Bash does show abnormal exit codes as part of its > prompt. But feel free to disregard > my opinions, as I'm not a heavy user of Eshell.) fish and some zsh distributions also show the error in the prompt. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 01:17:49 2023 Received: (at 65604) by debbugs.gnu.org; 2 Sep 2023 05:17:49 +0000 Received: from localhost ([127.0.0.1]:34898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcJ13-0003LI-By for submit@debbugs.gnu.org; Sat, 02 Sep 2023 01:17:49 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]:61807) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcJ11-0003L6-Cg for 65604@debbugs.gnu.org; Sat, 02 Sep 2023 01:17:47 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5732481b22eso1752146eaf.3 for <65604@debbugs.gnu.org>; Fri, 01 Sep 2023 22:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693631852; x=1694236652; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=nStdIKCJ4tD1x7LNH5eXEmRGpKESfdc8yI0fgzJ8Jd0=; b=ik0zJ2Rc1cHCKAQyEp1qw63Y4RVLhhUFYny6ypv971cxYfGoUY8cLpE6NwbBlbEcUU CYn6uWy+M50IV1J6rJzIxfTeg6RoH+OhZcPj2dHjbKr20N9TY5d/KrVhjdSnn+UUIfwg JKf910FAzSRNM92Oq29wCM3TJcp4S4Nu6v1pzQAsTZQCYi+Pa9dsJ9pKlwdugwct+ciI u+RbaDtGYjtm9wokAbz9rJ9FMXHdoOGz+rnspZmkbBs4sZjTBmgVhQtSI7/uLQFcJI5S GRNcqTbYV75w/Jt8nauxUs+jQw6kK0tBGE4X8s+glS6fZf9rFYQEayfyWla5ex19/oWo nCRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693631852; x=1694236652; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nStdIKCJ4tD1x7LNH5eXEmRGpKESfdc8yI0fgzJ8Jd0=; b=NYmFMXtT82XY3c7hZ3/wwoavEl+6fx+eBAxCp9aemiEmZMKiXLCQLRFwPLmbJrlFB7 5SsNJekNsbbuVWKGHO/eVWi3bvVlb0kBTLe5UbyOi4xSkPaO+2grDhdtKHO0CE1g9B3M 6M7GoezcfS+8CD81stS5rmp2MXYOcv0qP6T8JzLxizCZwd/6plqknNqpZwuwFD1A9bge JN99aRtatF2FRMAFqSKWw2NgwPPBBxXwT34OwB1rts5SSSWeDOk1G1Zn+M1NMCyZoqXn PQ4vZUQDh7JfSx8EBMlHANifsMxtj/dFz4ZKcr+Ro3knIMFiXoMDrt7WjwrGyM2fAGtk aqhA== X-Gm-Message-State: AOJu0YzuxR7yRAG9LF2SoXmVwx7kgsXMQ8EAwaZEjPGTkbM5ecVJ4PTz Rp1yXdIOtHLvBZMvvr4LnnU= X-Google-Smtp-Source: AGHT+IF8XcJeXNMrr23oLt4rLPTB3oIRwkjopaNxCGyQzhv69/7hxucPBzL5HfDF5BDdjigecrV95g== X-Received: by 2002:a05:6808:2091:b0:3a5:a607:650d with SMTP id s17-20020a056808209100b003a5a607650dmr5731456oiw.45.1693631852084; Fri, 01 Sep 2023 22:17:32 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id x7-20020a63b207000000b00563df2ba23bsm3746727pge.50.2023.09.01.22.17.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Sep 2023 22:17:31 -0700 (PDT) Message-ID: <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> Date: Fri, 1 Sep 2023 22:17:30 -0700 MIME-Version: 1.0 Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Content-Language: en-US To: Davide Masserut , Eli Zaretskii References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> From: Jim Porter In-Reply-To: <87cyz38rj2.fsf@mssdvd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8/31/2023 2:31 AM, Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >> (FWIW, I personally don't like the idea of showing this on the mode >> line: the mode line is already quite cramped > > I agree with you, this is one of the main reasons I had in mind when I > made the first patch. Hmm, well if everyone else disagrees, I suppose I don't see any *major* issues with including the exit status in the prompt, though I'm a little worried it would annoy people who like the current way. If it were easier to customize the prompt, I don't think I'd be as worried. Fixing that for real is probably beyond the scope of this bug, but I do have a WIP patch for it. If we do use the mode-line to display this though, I was initially thinking we could use the existing variable 'eshell-command-running-string', which we could set to something like "!!" in 'eshell-command-finished'. That's not as useful as the actual number though, and honestly I'm not sure the current 'eshell-status-in-mode-line' code is a good idea anyway. It (buffer-locally) replaces the mode-line construct immediately after 'mode-line-front-space', which means you lose some of the potentially-useful information there. Maybe it would make sense to move *all* of the current Eshell mode-line stuff to the 'mode-line-process' construct. That seems like it would be less brittle. That is, in 'mode-line-process', we could show whether a command is running or the exit status if nothing's running (possibly including successful exit). What does everyone think about that? >> and OTOH Bash does show abnormal exit codes as part of its prompt. >> But feel free to disregard >> my opinions, as I'm not a heavy user of Eshell.) > > fish and some zsh distributions also show the error in the prompt. Do they? I tried to see what the default was for Bash and after some searching, it seemed that it doesn't show the exit status by default. But that could be wrong. In any case, sorry for the back and forth. This is another corner of Eshell I wasn't really aware of until this bug, so I'm not 100% sure what implementation follows the spirit of Eshell the most... From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 05:35:48 2023 Received: (at 65604) by debbugs.gnu.org; 2 Sep 2023 09:35:48 +0000 Received: from localhost ([127.0.0.1]:35231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcN2h-00070Y-J6 for submit@debbugs.gnu.org; Sat, 02 Sep 2023 05:35:48 -0400 Received: from out-235.mta0.migadu.com ([91.218.175.235]:41614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcN2f-00070N-8O for 65604@debbugs.gnu.org; Sat, 02 Sep 2023 05:35:46 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693647334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5jAvKYrNS/eyl+EOzzlh6Ua9ploQONc3eby135+9/pY=; b=dTk8nlcrFBSmZzFIZ0vqFns8ZfU7GYlpS1hJTdUG8xq1ssNN52OKP/fkRKjVc6i9NIr4Wl fC9QDtnPWd1qTTRT2pNbOrLkMxLkHucvFOd/B/njmFaCJi9MUX8VLTG+uTHq4a9NyAGDap KYIknLFEG+VBqYeqiFZzhNwmiiq2KSBhFvSgHS2icvS48A1jJUKPZTgM9Uigo6hhEQXsmJ FsUIW9rnf4ttsfqyT17SunTIZyiW6Zly38zz/jf5HyNZUBsZcLN1uY4xaM3XJTwy85yLVX n+3syqt9BHTk74cp8rNXH0AcD7hzhja8qSmRHycEmzpTIrmd3uiOWzDlzDSRdQ== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Jim Porter Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Sat, 02 Sep 2023 10:47:15 +0200 In-reply-to: <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> Message-ID: <87msy4yl2c.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, Eli Zaretskii , me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jim Porter writes: > Hmm, well if everyone else disagrees, I suppose I don't see any > *major* issues with including the exit status in the prompt, though > I'm a little worried it would annoy people who like the current > way. If it were easier to customize the prompt, I don't think I'd be > as worried. Fixing that for real is probably beyond the scope of=20 > this > bug, but I do have a WIP patch for it. What do you find difficult to customize? I can only think of two things: 1) The default function is quite simple, but displaying the bytecode=20 in customization buffer can be confusing. Hide Eshell Prompt Function: Function: #[0 "\300\301 !\302 \303U\203\0\304\202\0\305P\207" [abbreviate-file-name eshell/pwd file-user-uid 0 " # " " $ "] 3] State : STANDARD. A function that returns the Eshell prompt string. Hide Make sure to update =E2=80=98eshell-prompt-regexp=E2=80=99 so that it wi= ll match=20 your prompt. 2) It may require to update the regexp. Can we use rx to make it more understandable? > If we do use the mode-line to display this though, I was initially > thinking we could use the existing variable > 'eshell-command-running-string', which we could set to something=20 > like > "!!" in 'eshell-command-finished'. That's not as useful as the=20 > actual > number though, and honestly I'm not sure the current > 'eshell-status-in-mode-line' code is a good idea anyway. It > (buffer-locally) replaces the mode-line construct immediately after > 'mode-line-front-space', which means you lose some of the > potentially-useful information there. > > Maybe it would make sense to move *all* of the current Eshell > mode-line stuff to the 'mode-line-process' construct. That seems=20 > like > it would be less brittle. That is, in 'mode-line-process', we could > show whether a command is running or the exit status if nothing's > running (possibly including successful exit). What does everyone=20 > think > about that? In this case I would add a small delay before signaling that something=20 is running. However, I'm not sure it is so useful to signaling it. When I suspect that the process is hanging, I usually use tools like=20 top or proced to check if something is stuck, but otherwise I already=20 know something is going on. I believe some terminals update the title bar when something is=20 running and send a notification when process ends and the window is=20 not focused. But for such long operations compilation-mode works best for me (BTW,=20 thank you for the new compile command). >>> and OTOH Bash does show abnormal exit codes as part of its prompt. >>> But feel free to disregard >>> my opinions, as I'm not a heavy user of Eshell.) >> fish and some zsh distributions also show the error in the prompt. > > Do they? I tried to see what the default was for Bash and after some > searching, it seemed that it doesn't show the exit status by > default. But that could be wrong. Distros often change the default prompt. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 14:41:10 2023 Received: (at 65604) by debbugs.gnu.org; 2 Sep 2023 18:41:11 +0000 Received: from localhost ([127.0.0.1]:38643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVYU-0001k2-GZ for submit@debbugs.gnu.org; Sat, 02 Sep 2023 14:41:10 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:53560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcVYS-0001jq-W2 for 65604@debbugs.gnu.org; Sat, 02 Sep 2023 14:41:10 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso590385ad.3 for <65604@debbugs.gnu.org>; Sat, 02 Sep 2023 11:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693680053; x=1694284853; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=BmfgzRWAGmUtf0M1y+urMo824JWJxYD+o2AO6ZrXB3o=; b=f1eogGeK8m7kpv0eGosOuQ23OfPq6r+lVbe8lfH3wKNwnJs97h4D7VAhPitratfIRP BUAta2jlE5P+d3a47exD4GOl3gPVcIaNWFYBApDy56VdnD08jIKJRh+hk60rQS9/39Z3 vRyIVymef6Z45k5IcFVECIulRmkq1ZpGD8tCRgpSX9+nsBmBXPg0VpB8WFodVzjfj1U7 zCZWsE0Ijphmab+15ePBLGRbcW0EgOlMNcWtwQEolVv0ym63wbRZpA59+Tq0faE28JNa Q7H4Scn5L5GsEjHtUMF40BPINYMLqrv7MZAi+IWg5yAfdzMr12lvSK0JLCG1WDuNWFad PVFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693680053; x=1694284853; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BmfgzRWAGmUtf0M1y+urMo824JWJxYD+o2AO6ZrXB3o=; b=a4OcYrPTzAr9o0VrclvW9G9v45rAX3UaFx5mQJ/9xRUVhuMIrdDpQUrzGq9iYErGhv j10IOw4kNnBRwfmVyv+p1UzPc96ocNssWqP9jwee4WCM71J+c13vD3S/LMg7hY2GujX8 YgcAJfKWX/P+tKYjGPXm8nj7/7BgeGkk511QEscSnlM5GasWSf9BRMhp2zCWIfT0Exjl d+98JE0Jd/fxcpiVrRLJN702FxZjC6bwc+jhGfFrlb/5IFG729AicDYYvHZYjighwD0n XkYUsM8Bq/wyqKrR4kkhDEzpAtlCP6UQkVnZ6qstkWSQnN+hryiR03Q1ExGwEHFnl4ad U/OQ== X-Gm-Message-State: AOJu0YwOmrFzovHbLbWQitFYOeWrMOudY/2RD8GbQQnRiTRyVda0cape 09momcgpqJ0RAcdtx9b0NYY= X-Google-Smtp-Source: AGHT+IGA3mQNjnOr6fWdqRqquT0FjJ9iPGHIJG1El52oXOAzFJAxnfmrMzQul57RZpUgm5+FZR3Nhw== X-Received: by 2002:a17:903:1210:b0:1bb:994c:bc43 with SMTP id l16-20020a170903121000b001bb994cbc43mr6264924plh.18.1693680053063; Sat, 02 Sep 2023 11:40:53 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id je7-20020a170903264700b001a9b29b6759sm4928932plb.183.2023.09.02.11.40.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Sep 2023 11:40:52 -0700 (PDT) Message-ID: <1f740d2f-ee68-7157-b6bb-d2725c9c67c3@gmail.com> Date: Sat, 2 Sep 2023 11:40:53 -0700 MIME-Version: 1.0 Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Content-Language: en-US To: Davide Masserut References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> <87msy4yl2c.fsf@mssdvd.com> From: Jim Porter In-Reply-To: <87msy4yl2c.fsf@mssdvd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, Eli Zaretskii , me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 9/2/2023 1:47 AM, Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Jim Porter writes: > >> Hmm, well if everyone else disagrees, I suppose I don't see any >> *major* issues with including the exit status in the prompt, though >> I'm a little worried it would annoy people who like the current >> way. If it were easier to customize the prompt, I don't think I'd be >> as worried. Fixing that for real is probably beyond the scope of this >> bug, but I do have a WIP patch for it. > > What do you find difficult to customize? > > I can only think of two things: > > 1) The default function is quite simple, but displaying the bytecode in > customization buffer can be confusing. Yeah, mainly the Customize interface. It's a bit confusing, and when I think back to when I didn't understand Elisp, I would have found any customization of the Eshell prompt to be pretty intimidating. I have a WIP patch for this though, which uses 'mode-line-format' to make the Eshell prompt work more like the mode-line. It seems to work pretty well, but I need to finish it up. (And especially to make sure it doesn't do anything weird with multi-line prompts.) > 2) It may require to update the regexp. The prompt regexp is (thankfully) almost irrelevant in Emacs 30 now. It only matters for paragraph-movement commands, which we could probably just remap to the actual Eshell-specific commands to navigate forward and backward through the prompts. I should probably just make a patch for this and finally get rid of that regexp entirely. > In this case I would add a small delay before signaling that something > is running. The delay isn't present in the current Eshell mode-line implementation, and I don't think anyone's raised an issue about that... > However, I'm not sure it is so useful to signaling it. > When I suspect that the process is hanging, I usually use tools like top > or proced to check if something is stuck, but otherwise I already know > something is going on. I think there's some use, especially for longer-running Lisp functions, but that area is a bit of a mess anyway since it's tough to run Lisp code asynchronously (or at least, in a way that meshes with Eshell). > I believe some terminals update the title bar when something is running > and send a notification when process ends and the window is not focused. > But for such long operations compilation-mode works best for me (BTW, > thank you for the new compile command). Yeah, this is roughly what I'm thinking for Eshell. The mode-line seems to me like a decent place for that info. >> Do they? I tried to see what the default was for Bash and after some >> searching, it seemed that it doesn't show the exit status by >> default. But that could be wrong. > > Distros often change the default prompt. Yeah, I tried to take that into account when I looked it up. The actual default from GNU Bash is *very* basic, but what you get as a fresh user on most distros is a little fancier. I didn't see that it reported the exit status though. ... in any case, maybe the simplest way forward here is to put the (non-zero) exit status in the prompt like your original patch, and then separately, I can try to improve the customizability of the prompt, as well as thinking about what to do with the mode-line. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 17:00:42 2023 Received: (at 65604) by debbugs.gnu.org; 2 Sep 2023 21:00:42 +0000 Received: from localhost ([127.0.0.1]:38778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcXjV-0007xF-D2 for submit@debbugs.gnu.org; Sat, 02 Sep 2023 17:00:41 -0400 Received: from out-220.mta0.migadu.com ([91.218.175.220]:16795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcXjQ-0007x2-Bm for 65604@debbugs.gnu.org; Sat, 02 Sep 2023 17:00:39 -0400 References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> <87msy4yl2c.fsf@mssdvd.com> <1f740d2f-ee68-7157-b6bb-d2725c9c67c3@gmail.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mssdvd.com; s=key1; t=1693688424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SDFR8N3+tTe53A9H0IsdnG7QkkOIn5G340JB5g/1FzM=; b=cP4fjK6KNU927qHMPblXnvyJMw4u/n+jyN8i0/AHEtoRIZK+fXjx4NVgF5tjwTGxLCNFOn LuAcDzpBbF3hY2n7bUAz+rmmblpjneu/9e8E+IAhus/x/YjOFyju+rmUMMShMDjD40kF+L RLT92HqN7UgqfPyJwfj5sUPsaLCNyZrfpRtzAuu1xG5BeQjL4CLqDKTb3C6DydL/Gm4Ng8 7ylJsZfLwVwQt9vWhEUBuLE1jqpDDPOwBOUSlSFo1wFTnyhFhMxr2UsKY6ihgcTmsGiO2q /5JMovPe0qrJtJF0TytDTYdfmLIgnykZFbpq31DT4T4ChngX8iKonHJrJzb1oA== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Davide Masserut To: Jim Porter Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Date: Sat, 02 Sep 2023 20:54:38 +0200 In-reply-to: <1f740d2f-ee68-7157-b6bb-d2725c9c67c3@gmail.com> Message-ID: <87zg24e1ei.fsf@mssdvd.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: 65604@debbugs.gnu.org, Eli Zaretskii , me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; format=flowed Jim Porter writes: >> 2) It may require to update the regexp. > > The prompt regexp is (thankfully) almost irrelevant in Emacs 30 > now. It only matters for paragraph-movement commands, which we > could > probably just remap to the actual Eshell-specific commands to > navigate > forward and backward through the prompts. I should probably just > make > a patch for this and finally get rid of that regexp entirely. I didn't know that, thanks. >> In this case I would add a small delay before signaling that >> something is running. > > The delay isn't present in the current Eshell mode-line > implementation, and I don't think anyone's raised an issue about > that... Sorry, I meant that if we decided to show a relative long message like "Running" in the mode-line, then we should show it only when it lasts for more than, let's say, 0.5s. This would prevent the mode-line from moving to right for just a fraction of a second when running fast commands like cd or ls. > ... in any case, maybe the simplest way forward here is to put > the > (non-zero) exit status in the prompt like your original patch, > and > then separately, I can try to improve the customizability of the > prompt, as well as thinking about what to do with the mode-line. I have updated the patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Display-the-exit-code-if-the-last-command-failed-in-.patch >From 83f716950a60ee64c49654033430f8e09d373f24 Mon Sep 17 00:00:00 2001 From: Davide Masserut Date: Tue, 29 Aug 2023 22:33:48 +0200 Subject: [PATCH] Display the exit code if the last command failed in Eshell * doc/misc/eshell.texi (Invocation): Document change. * etc/NEWS: Announce change. * lisp/eshell/em-prompt.el (eshell-prompt-function): Insert the exit code if last command failed. * lisp/eshell/esh-io.el (eshell-last-command-status): Make it buffer-local. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test/after-failure) (em-prompt-test/next-previous-prompt-with) (em-prompt-test/forward-backward-matching-input-with): New tests. --- doc/misc/eshell.texi | 3 +++ etc/NEWS | 3 +++ lisp/eshell/em-prompt.el | 2 ++ lisp/eshell/esh-io.el | 2 +- test/lisp/eshell/em-prompt-tests.el | 37 +++++++++++++++++++++++++---- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index 7a563bc794c..677bd0f3e3e 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -234,6 +234,9 @@ Invocation can be controlled the same way as any other background process in Emacs. +If a command exits abnormally, Eshell displays the command's exit code +in the prompt. + @subsection Command form Command form looks much the same as in other shells. A command consists of arguments separated by spaces; the first argument is the diff --git a/etc/NEWS b/etc/NEWS index 5c11b6b9ac7..7a9010a2a9a 100644 --- 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 a command exits abnormally, Eshell now displays the command's exit code in the prompt. + ** Pcomplete --- diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 42f8f273b52..692b579d02d 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -50,6 +50,8 @@ eshell-prompt-load-hook (defcustom eshell-prompt-function (lambda () (concat (abbreviate-file-name (eshell/pwd)) + (unless (eshell-exit-success-p) + (format " [%d]" eshell-last-command-status)) (if (= (file-user-uid) 0) " # " " $ "))) "A function that returns the Eshell prompt string. Make sure to update `eshell-prompt-regexp' so that it will match your diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index c07f871dd37..cd0cee6e21d 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -170,7 +170,7 @@ eshell-redirection-operators-alist (defvar eshell-current-handles nil) -(defvar eshell-last-command-status 0 +(defvar-local eshell-last-command-status 0 "The exit code from the last command. 0 if successful.") (defvar eshell-last-command-result nil diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 93bf9d84ab3..c90f417cefd 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -34,6 +34,25 @@ ;;; Tests: +(ert-deftest em-prompt-test/after-failure () + "Check that current prompt shows the exit code of the last failed command." + (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) + (let ((current-prompt (field-string (1- (point))))) + (should (equal-including-properties + current-prompt + (propertize + (concat (directory-file-name default-directory) + (unless (eshell-exit-success-p) + (format " [%d]" eshell-last-command-status)) + (if (= (file-user-uid) 0) " # " " $ ")) + 'read-only t + 'field 'prompt + 'font-lock-face 'eshell-prompt + 'front-sticky '(read-only field font-lock-face) + 'rear-nonsticky '(read-only field font-lock-face))))))) + (ert-deftest em-prompt-test/field-properties () "Check that field properties are properly set on Eshell output/prompts." (with-temp-eshell @@ -88,6 +107,8 @@ em-prompt-test--with-multiline (defun em-prompt-test/next-previous-prompt-with () "Helper for checking forward/backward navigation of old prompts." (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. (eshell-insert-command "echo one") (eshell-insert-command "echo two") (eshell-insert-command "echo three") @@ -99,8 +120,11 @@ em-prompt-test/next-previous-prompt-with (end-of-line) (eshell-previous-prompt 2) (should (equal (eshell-get-old-input) "echo one")) - ;; Go forward three prompts. - (eshell-next-prompt 3) + ;; Go back one prompt. + (eshell-previous-prompt 1) + (should (equal (eshell-get-old-input) "(zerop \"foo\")")) + ;; Go forward four prompts. + (eshell-next-prompt 4) (should (equal (eshell-get-old-input) "echo fou")))) (ert-deftest em-prompt-test/next-previous-prompt () @@ -115,6 +139,8 @@ em-prompt-test/next-previous-prompt-multiline (defun em-prompt-test/forward-backward-matching-input-with () "Helper for checking forward/backward navigation via regexps." (with-temp-eshell + (let ((debug-on-error nil)) + (eshell-insert-command "(zerop \"foo\")")) ; A failed command. (eshell-insert-command "echo one") (eshell-insert-command "printnl something else") (eshell-insert-command "echo two") @@ -127,8 +153,11 @@ em-prompt-test/forward-backward-matching-input-with (end-of-line) (eshell-backward-matching-input "echo" 2) (should (equal (eshell-get-old-input) "echo one")) - ;; Go forward three prompts. - (eshell-forward-matching-input "echo" 3) + ;; Go back one prompt. + (eshell-previous-prompt 1) + (should (equal (eshell-get-old-input) "(zerop \"foo\")")) + ;; Go forward four prompts. + (eshell-forward-matching-input "echo" 4) (should (equal (eshell-get-old-input) "echo fou")))) (ert-deftest em-prompt-test/forward-backward-matching-input () -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 02 18:46:30 2023 Received: (at 65604-done) by debbugs.gnu.org; 2 Sep 2023 22:46:30 +0000 Received: from localhost ([127.0.0.1]:38870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcZNu-0004oU-0A for submit@debbugs.gnu.org; Sat, 02 Sep 2023 18:46:30 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]:51200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qcZNs-0004oH-Gu for 65604-done@debbugs.gnu.org; Sat, 02 Sep 2023 18:46:29 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5733789a44cso164667eaf.2 for <65604-done@debbugs.gnu.org>; Sat, 02 Sep 2023 15:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693694773; x=1694299573; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=J+I9GbZGt/5Hwi1DMfm8IU2XflyBBoR3erK1EKlymr0=; b=Dd7yTCcJJn7mdeIuVKFvkhYfDp917mENh1acMPnHzFIaazOs0B9vjBz0tjS9SzwvRm fjqJu1q3crnOI7HcCnDGI3DbKncX7GVPjuC73JE2ybyH8FiPTy/gUBTxIyzcOnn+FEjD NJXexdNKKAZMSwZRl25YZAIPRtd05bVOmzvGgJpiOu6/mQh8FV2Z8PTJKdoE3ErSKaSV 2+Rv3O9ENgvuNHnexyVpWVtjkIeBnr0D9k25G6YAIENQUoAN/9v+GVg8+ZfjkyxUSuxp jf5l7RwXgqQfG+mvJ+/1OBJdbA4mRne60IrWroP4eBvJ78RPENM+I6JaNHDeKcCvHWGG ulwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693694773; x=1694299573; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J+I9GbZGt/5Hwi1DMfm8IU2XflyBBoR3erK1EKlymr0=; b=JfDcOQIPpRJp5S4qAnc7LjnoRehmH1mUtjpH7CUF84T6B6ZbNpNfYDYYWzsiLkDgda x+lcsyrAonWlMnmHXd21bPaUoGKR+F/tM0icRngaqi2puDl5RZWvtDK4SXTOcRcAVmkC cl05geh3NC5oBi9Gh+r83S/eebLv6QiQjjEkkEr9edGvFZ+BPka2wpU80hoSePEEMzxR XxdvdxGhVf8KiyNadc/SP9p5uDyAjJGt/c4ebiuja2GulV/G3VdjULmRBHf03P3Gea+i gllhsUqOA8U+JlQcCAXRCm2M814+Lhgu8lzfbcInVQuf4Y1pBwdB1C9EeIc4RPtq63W4 RhnQ== X-Gm-Message-State: AOJu0YwpCamvlycNUBI2yLN6l4TNe0EF8eCFm9cFRwo2Oprqgq6+IdLe aN6mu/DMX/GRRc+tiSDRRV4= X-Google-Smtp-Source: AGHT+IHMsaSp4swjInex3SJkIUQCpjhoKD0UmtoZrnM43ZSglSnx9pWBWamuuOXCvF728ed1g82YlA== X-Received: by 2002:a05:6808:8f6:b0:3a7:330d:93da with SMTP id d22-20020a05680808f600b003a7330d93damr6462010oic.19.1693694772795; Sat, 02 Sep 2023 15:46:12 -0700 (PDT) Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id q18-20020a170902dad200b001b39ffff838sm5071280plx.25.2023.09.02.15.46.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Sep 2023 15:46:12 -0700 (PDT) Message-ID: <261eee80-5ccb-8680-b895-26379a837a52@gmail.com> Date: Sat, 2 Sep 2023 15:46:11 -0700 MIME-Version: 1.0 Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell Content-Language: en-US To: Davide Masserut References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> <87msy4yl2c.fsf@mssdvd.com> <1f740d2f-ee68-7157-b6bb-d2725c9c67c3@gmail.com> <87zg24e1ei.fsf@mssdvd.com> From: Jim Porter In-Reply-To: <87zg24e1ei.fsf@mssdvd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604-done Cc: 65604-done@debbugs.gnu.org, Eli Zaretskii , me@eshelyaron.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Version: 30.1 On 9/2/2023 11:54 AM, Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Jim Porter writes: > >> The prompt regexp is (thankfully) almost irrelevant in Emacs 30 >> now. It only matters for paragraph-movement commands, which we could >> probably just remap to the actual Eshell-specific commands to navigate >> forward and backward through the prompts. I should probably just make >> a patch for this and finally get rid of that regexp entirely. > > I didn't know that, thanks. I've now made it fully-obsolete, so it doesn't do anything anymore (now, Eshell implements its own paragraph navigation based on fields). > Sorry, I meant that if we decided to show a relative long message like > "Running" in the mode-line, then we should show it only when it lasts > for more than, let's say, 0.5s.  This would prevent the mode-line from > moving to right for just a fraction of a second when running fast > commands like cd or ls. Hmm, that's true. One benefit of the current mode-line implementation for Eshell is that the indicator always takes up the same width. I'll keep thinking about this. >> ... in any case, maybe the simplest way forward here is to put the >> (non-zero) exit status in the prompt like your original patch, and >> then separately, I can try to improve the customizability of the >> prompt, as well as thinking about what to do with the mode-line. > > I have updated the patch. Thanks. I rebased it on top of my changes and pushed it to master as 3d08d0dd80a. Closing this bug now. From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 10 10:44:39 2023 Received: (at 65604) by debbugs.gnu.org; 10 Sep 2023 14:44:39 +0000 Received: from localhost ([127.0.0.1]:51071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfLfy-0005zJ-O6 for submit@debbugs.gnu.org; Sun, 10 Sep 2023 10:44:39 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:46805) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfLfu-0005z3-VX for 65604@debbugs.gnu.org; Sun, 10 Sep 2023 10:44:37 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5C38F5C006A; Sun, 10 Sep 2023 10:44:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 10 Sep 2023 10:44:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1694357065; x= 1694443465; bh=9DMKNf/ErMvvZpfe/kiG747mWkAuOXtOkTBI303QBPw=; b=B kVYqR9w6hXBsKnTNSVLOy2EYNzm4/Q88a74TowCLGWPk5hOWsKAoSg4wzMitwOIo Ud4g55FHfLQlGutMJeXmdsH2qx93Ki3gPnfGYozyMqlK/dZzu9TbcihB86ZbqtuW J5dBxF3ProgbUiwM489WX93CeDsBjmxyjKqZroj5+YMz/QZhp6iBYgXzGyf5JDno vAyWl65iIeKPcdWvUy4zqdD3oLPlyzYBXnWdXOePXPDbO5mPnWBtcHxnkkGgkyb0 PMexodikWJKVIkZflct0goXDlH+SGlKgHNSnR52Or/6gZDnpdJv/dP0GgVm9h0TP bhKPDDaOlHGMbo4rENaxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1694357065; x=1694443465; bh=9DMKNf/ErMvvZ pfe/kiG747mWkAuOXtOkTBI303QBPw=; b=Nmrd7QQZSd36uhVrWc4AAt4iCW2OF 0lE/5aUNUqYaoJhWOKpOy6G+A4eD3djoKbvoCWCtmPfQ4VVeCrEkQspYTuFaA3/D 2h4mBAFqPI/Hr8JMZ6XyZemPW+EPU/s+ChO55CSjBRl7qii72avVvLwtkT6GV9lH E2GTxZ/Fa/not7ycDUDayis+BWHgKMf9ePAuKBbp7TU5AabX7MHwaObAFpN9inSu 7cQtbtzlw3KZufXs0sRdV9VGlLOtXhdlROySBq3wZc3uI+VEMf6b8zg/x/RMdS0a Q/sebH/K8vQNri3CLoW+2hpCe/gIy19to+Vzkpcv+b1P97BwxsE5Ha6DA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeivddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufgjfhffkfgfgggtsehttd dttddtredtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhhhithhtohhn sehsphifhhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnheptdffvdffueelue dvteekvdevhefghedvgeevgffhvedukeeggeelveegjeekteeknecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtthhonhesshhpfi hhihhtthhonhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i23c04076:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 10 Sep 2023 10:44:24 -0400 (EDT) Received: by melete.silentflame.com (Postfix, from userid 1000) id 32D647E386B; Sun, 10 Sep 2023 15:44:22 +0100 (BST) From: Sean Whitton To: 65604@debbugs.gnu.org Subject: Re: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell In-Reply-To: <261eee80-5ccb-8680-b895-26379a837a52@gmail.com> (Jim Porter's message of "Sat, 2 Sep 2023 15:46:11 -0700") References: <87cyz5wjtm.fsf@mssdvd.com> <05108d35-d095-c975-78b8-6b00fc7e6a08@gmail.com> <87o7iolg6o.fsf@mssdvd.com> <83v8cwfphy.fsf@gnu.org> <87wmxc4ah3.fsf@mssdvd.com> <83fs40fi35.fsf@gnu.org> <87msy8s344.fsf@mssdvd.com> <83a5u7g6f3.fsf@gnu.org> <87cyz38rj2.fsf@mssdvd.com> <98c6ac0f-08fd-8dd0-2213-8a482f5ac67f@gmail.com> <87msy4yl2c.fsf@mssdvd.com> <1f740d2f-ee68-7157-b6bb-d2725c9c67c3@gmail.com> <87zg24e1ei.fsf@mssdvd.com> <261eee80-5ccb-8680-b895-26379a837a52@gmail.com> Date: Sun, 10 Sep 2023 15:44:22 +0100 Message-ID: <87bkearsu1.fsf@melete.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65604 Cc: jporterbugs@gmail.com, dm@mssdvd.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hello, Thank you both for this. I've had this in my init.el for ages, and it nice to have it there by default. -- Sean Whitton From unknown Sat Jun 21 10:17:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 09 Oct 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator