bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65604: [PATCH] Display the exit code if the last command failed in E


From: Davide Masserut
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@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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]