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

Previous Next

Package: emacs;

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

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

Severity: normal

Tags: patch

Fixed in version 30.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Davide Masserut <dm <at> mssdvd.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65604 <at> debbugs.gnu.org, jporterbugs <at> gmail.com, me <at> eshelyaron.com
Subject: bug#65604: [PATCH] Display the exit code if the last command failed in Eshell
Date: Wed, 30 Aug 2023 21:59:35 +0200
Eli Zaretskii <eliz <at> gnu.org> 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.

"(elisp) Mode Line Data" says:

    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?




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

Previous Next


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