Subject: 30.0.50; [PATCH] Eshell's TERM env varible use eshell-term-name as default

From: Lin Sun <[email-masked]>
Date: Wed, 1 May 2024 06:40:25 +0000

Hi,

Since emacs-29 the Eshell has been enhanced for the ansi-color a lot.
And the function `eshell-exec-visual` can support the executables with
colors, eg VIM, tmux...
I have tested the "/bin/ls --color=tty", "/bin/grep --color=tty" ...
and other executables in Eshell with "export TERM=eshell-color", they
all work great.

So we can safely export eshell's "TERM" with `eshell-term-name` to
support executables with colors.
I attached the patch, please help review it. Thanks.
From 5a43430e88e414a798923d882eff7c3b7cb86c1c Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Wed, 1 May 2024 06:55:23 +0000
Subject: [PATCH] Eshell's TERM env varible use eshell-term-name as default

* lisp/eshell/esh-var.el (eshell-variable-aliases-list):
  Initialize the TERM environment variable with eshell-term-name.
* doc/misc/eshell.texi: Document for TERM environment variable.
* etc/NEWS: Add entry in NEWS file.
---
 doc/misc/eshell.texi   | 5 +++++
 etc/NEWS               | 4 ++++
 lisp/eshell/esh-var.el | 1 +
 3 files changed, 10 insertions(+)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 30c85da795..07611c49ef 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -1456,6 +1456,11 @@ Variables
 @code{comint-pager} if non-@code{nil}; otherwise, it uses the value of
 @code{$PAGER} from the @code{process-environment}.
 
+@vindex $TERM
+@item $TERM
+This variable indicates the terminal type of the eshell.  Its default
+value is @code{eshell-term-name}.
+
 @end table
 
 @xref{Aliases}, for the built-in variables @samp{$*}, @samp{$1},
diff --git a/etc/NEWS b/etc/NEWS
index 4b0106fcb0..5ebc5172f6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -864,6 +864,10 @@ command passed as arguments to 'env'.  If you pass any initial
 arguments of the form 'VAR=VALUE', 'env' will first set 'VAR' to
 'VALUE' before running the command.
 
++++
+*** Eshell's 'TERM' env var uses 'eshell-term-name' as default.
+The eshell's 'TERM' environment variable uses 'eshell-term-name' as default.
+
 ---
 *** Eshell's 'umask' command now supports setting the mask symbolically.
 Now, you can pass an argument like "u+w,o-r" to Eshell's 'umask'
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 02b5c78562..8dd8a84da8 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -161,6 +161,7 @@ eshell-variable-aliases-list
   `(;; for eshell.el
     ("COLUMNS" ,(lambda () (window-body-width nil 'remap)) t t)
     ("LINES" ,(lambda () (window-body-height nil 'remap)) t t)
+    ("TERM" eshell-term-name t)
     ("INSIDE_EMACS" eshell-inside-emacs t)
     ("PAGER" (,(lambda () (or comint-pager (getenv "PAGER")))
               . ,(lambda (_ value)
-- 
2.20.5