* bug#29583: 25.2.50; Allow setting a custom TERM for comint
@ 2017-12-05 20:40 Allen Li
2017-12-05 22:08 ` bug#29583: [PATCH] " Allen Li
0 siblings, 1 reply; 5+ messages in thread
From: Allen Li @ 2017-12-05 20:40 UTC (permalink / raw)
To: 29583
comint hard codes TERM=dumb The user can ship their own terminfo
configuration for Emacs/comint to enable color, but comint does not
currently expose a way to use such a custom terminfo entry.
In GNU Emacs 25.2.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11),
modified by Debian
Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#29583: [PATCH] 25.2.50; Allow setting a custom TERM for comint
2017-12-05 20:40 bug#29583: 25.2.50; Allow setting a custom TERM for comint Allen Li
@ 2017-12-05 22:08 ` Allen Li
2017-12-12 9:16 ` Michael Albinus
0 siblings, 1 reply; 5+ messages in thread
From: Allen Li @ 2017-12-05 22:08 UTC (permalink / raw)
To: 29583
[-- Attachment #1: Type: text/plain, Size: 34 bytes --]
I have attached a patch for this.
[-- Attachment #2: 0001-Add-option-to-configure-comint-TERM.patch --]
[-- Type: text/x-patch, Size: 4710 bytes --]
From cb5a40d8f9778756a1d8817025a9699e30432522 Mon Sep 17 00:00:00 2001
From: Allen Li <darkfeline@felesatra.moe>
Date: Tue, 5 Dec 2017 13:01:24 -0800
Subject: [PATCH] Add option to configure comint TERM
* doc/emacs/misc.texi (Shell Options): Document new option
* lisp/comint.el (comint-terminfo-terminal): Add new option
(comint-term-environment): Add new function for setting terminal options
(comint-exec-1): Use comint-term-environment
* lisp/progmodes/compile.el (compilation-start): Use comint-term-environment
---
doc/emacs/misc.texi | 8 ++++++++
lisp/comint.el | 35 ++++++++++++++++++++++-------------
lisp/progmodes/compile.el | 8 +-------
3 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 6ad5fbafdd..fda7341fe2 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1396,6 +1396,14 @@ Shell Options
(@code{shell-pushd-dunique}). The values you choose should match the
underlying shell, of course.
+@vindex comint-terminfo-terminal
+Emacs sets the @code{TERM} environment variable to a safe value, but
+this value may not reflect the full features of comint. For example,
+color is disabled for some applications that use @code{TERM} to
+determine if color is supported. On systems that use terminfo, you
+can configure @code{comint-terminfo-terminal} to a terminal that is
+present in your system's terminfo database.
+
@node Terminal emulator
@subsection Emacs Terminal Emulator
@findex term
diff --git a/lisp/comint.el b/lisp/comint.el
index aa7dab28f3..433eeb1fb2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -458,6 +458,11 @@ comint-exec-hook
:type 'hook
:group 'comint)
+(defcustom comint-terminfo-terminal "dumb"
+ "Value to use for TERM when the system uses terminfo."
+ :type 'string
+ :group 'comint)
+
(defvar comint-mode-map
(let ((map (make-sparse-keymap)))
;; Keys:
@@ -816,19 +821,7 @@ comint-exec
(defun comint-exec-1 (name buffer command switches)
(let ((process-environment
(nconc
- ;; If using termcap, we specify `emacs' as the terminal type
- ;; because that lets us specify a width.
- ;; If using terminfo, we specify `dumb' because that is
- ;; a defined terminal type. `emacs' is not a defined terminal type
- ;; and there is no way for us to define it here.
- ;; Some programs that use terminfo get very confused
- ;; if TERM is not a valid terminal type.
- ;; ;; There is similar code in compile.el.
- (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
- (list "TERM=dumb" "TERMCAP="
- (format "COLUMNS=%d" (window-width)))
- (list "TERM=emacs"
- (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
+ (comint-term-environment)
(list (format "INSIDE_EMACS=%s,comint" emacs-version))
process-environment))
(default-directory
@@ -857,6 +850,22 @@ comint-exec-1
(set-process-coding-system proc decoding encoding))
proc))
+(defun comint-term-environment ()
+ "Return an environment variable list for terminal configuration."
+ ;; If using termcap, we specify `emacs' as the terminal type
+ ;; because that lets us specify a width.
+ ;; If using terminfo, we default to `dumb' because that is
+ ;; a defined terminal type. `emacs' is not a defined terminal type
+ ;; and there is no way for us to define it here.
+ ;; Some programs that use terminfo get very confused
+ ;; if TERM is not a valid terminal type.
+ (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
+ (list (format "TERM=%s" comint-terminfo-terminal)
+ "TERMCAP="
+ (format "COLUMNS=%d" (window-width)))
+ (list "TERM=emacs"
+ (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
+
(defun comint-nonblank-p (str)
"Return non-nil if STR contains non-whitespace syntax."
(not (string-match "\\`\\s *\\'" str)))
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 4cce47e5d8..c68001d236 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1746,13 +1746,7 @@ compilation-start
(let ((process-environment
(append
compilation-environment
- (if (if (boundp 'system-uses-terminfo);`If' for compiler warning.
- system-uses-terminfo)
- (list "TERM=dumb" "TERMCAP="
- (format "COLUMNS=%d" (window-width)))
- (list "TERM=emacs"
- (format "TERMCAP=emacs:co#%d:tc=unknown:"
- (window-width))))
+ (comint-term-environment)
(list (format "INSIDE_EMACS=%s,compile" emacs-version))
(copy-sequence process-environment))))
(set (make-local-variable 'compilation-arguments)
--
2.15.0.531.g2ccb3012c9-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#29583: [PATCH] 25.2.50; Allow setting a custom TERM for comint
2017-12-05 22:08 ` bug#29583: [PATCH] " Allen Li
@ 2017-12-12 9:16 ` Michael Albinus
2017-12-13 3:35 ` Allen Li
0 siblings, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2017-12-12 9:16 UTC (permalink / raw)
To: Allen Li; +Cc: 29583
Allen Li <vianchielfaura@gmail.com> writes:
Hi Allen,
> +@vindex comint-terminfo-terminal
> +Emacs sets the @code{TERM} environment variable to a safe value, but
> +this value may not reflect the full features of comint. For example,
> +color is disabled for some applications that use @code{TERM} to
> +determine if color is supported. On systems that use terminfo, you
> +can configure @code{comint-terminfo-terminal} to a terminal that is
> +present in your system's terminfo database.
You might mention that some applications will override this. For
example, Tramp will always use `tramp-terminal-type' (which is
"dumb"). This is because Tramp will run into problems if color is enabled.
Btw, environment variables in the Emacs manual are emphazised as @env{TERM}.
Best regards, Michael.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#29583: [PATCH] 25.2.50; Allow setting a custom TERM for comint
2017-12-12 9:16 ` Michael Albinus
@ 2017-12-13 3:35 ` Allen Li
2018-06-06 0:22 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Allen Li @ 2017-12-13 3:35 UTC (permalink / raw)
To: Michael Albinus; +Cc: 29583
[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]
On Tue, Dec 12, 2017 at 1:16 AM, Michael Albinus <michael.albinus@gmx.de> wrote:
> Allen Li <vianchielfaura@gmail.com> writes:
>
> Hi Allen,
>
>> +@vindex comint-terminfo-terminal
>> +Emacs sets the @code{TERM} environment variable to a safe value, but
>> +this value may not reflect the full features of comint. For example,
>> +color is disabled for some applications that use @code{TERM} to
>> +determine if color is supported. On systems that use terminfo, you
>> +can configure @code{comint-terminfo-terminal} to a terminal that is
>> +present in your system's terminfo database.
>
> You might mention that some applications will override this. For
> example, Tramp will always use `tramp-terminal-type' (which is
> "dumb"). This is because Tramp will run into problems if color is enabled.
>
> Btw, environment variables in the Emacs manual are emphazised as @env{TERM}.
>
> Best regards, Michael.
Thanks, fixed to use @env. I've changed it to say that Comint uses
this, rather than Emacs. Naturally, derived modes may override this
behavior; I don't think it's necessary to point that out unless it
turns out to be a common misconception.
[-- Attachment #2: 0001-Add-option-to-configure-comint-TERM.patch --]
[-- Type: text/x-patch, Size: 4688 bytes --]
From 1a947dd65de23e3d4ad1c2da468c5c4e764286a3 Mon Sep 17 00:00:00 2001
From: Allen Li <darkfeline@felesatra.moe>
Date: Tue, 5 Dec 2017 13:01:24 -0800
Subject: [PATCH] Add option to configure comint TERM
* doc/emacs/misc.texi (Shell Options): Document new option
* lisp/comint.el (comint-terminfo-terminal): Add new option
(comint-term-environment): Add new function for setting terminal options
(comint-exec-1): Use comint-term-environment
* lisp/progmodes/compile.el (compilation-start): Use comint-term-environment
---
doc/emacs/misc.texi | 8 ++++++++
lisp/comint.el | 35 ++++++++++++++++++++++-------------
lisp/progmodes/compile.el | 8 +-------
3 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 6ad5fbafdd..1eaa2160c9 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1396,6 +1396,14 @@ Shell Options
(@code{shell-pushd-dunique}). The values you choose should match the
underlying shell, of course.
+@vindex comint-terminfo-terminal
+Comint sets the @env{TERM} environment variable to a safe value, but
+this value may not reflect the full features of comint. For example,
+color is disabled for some applications that use @env{TERM} to
+determine if color is supported. On systems that use terminfo, you
+can configure @code{comint-terminfo-terminal} to a terminal that is
+present in your system's terminfo database.
+
@node Terminal emulator
@subsection Emacs Terminal Emulator
@findex term
diff --git a/lisp/comint.el b/lisp/comint.el
index aa7dab28f3..433eeb1fb2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -458,6 +458,11 @@ comint-exec-hook
:type 'hook
:group 'comint)
+(defcustom comint-terminfo-terminal "dumb"
+ "Value to use for TERM when the system uses terminfo."
+ :type 'string
+ :group 'comint)
+
(defvar comint-mode-map
(let ((map (make-sparse-keymap)))
;; Keys:
@@ -816,19 +821,7 @@ comint-exec
(defun comint-exec-1 (name buffer command switches)
(let ((process-environment
(nconc
- ;; If using termcap, we specify `emacs' as the terminal type
- ;; because that lets us specify a width.
- ;; If using terminfo, we specify `dumb' because that is
- ;; a defined terminal type. `emacs' is not a defined terminal type
- ;; and there is no way for us to define it here.
- ;; Some programs that use terminfo get very confused
- ;; if TERM is not a valid terminal type.
- ;; ;; There is similar code in compile.el.
- (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
- (list "TERM=dumb" "TERMCAP="
- (format "COLUMNS=%d" (window-width)))
- (list "TERM=emacs"
- (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
+ (comint-term-environment)
(list (format "INSIDE_EMACS=%s,comint" emacs-version))
process-environment))
(default-directory
@@ -857,6 +850,22 @@ comint-exec-1
(set-process-coding-system proc decoding encoding))
proc))
+(defun comint-term-environment ()
+ "Return an environment variable list for terminal configuration."
+ ;; If using termcap, we specify `emacs' as the terminal type
+ ;; because that lets us specify a width.
+ ;; If using terminfo, we default to `dumb' because that is
+ ;; a defined terminal type. `emacs' is not a defined terminal type
+ ;; and there is no way for us to define it here.
+ ;; Some programs that use terminfo get very confused
+ ;; if TERM is not a valid terminal type.
+ (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
+ (list (format "TERM=%s" comint-terminfo-terminal)
+ "TERMCAP="
+ (format "COLUMNS=%d" (window-width)))
+ (list "TERM=emacs"
+ (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
+
(defun comint-nonblank-p (str)
"Return non-nil if STR contains non-whitespace syntax."
(not (string-match "\\`\\s *\\'" str)))
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 4cce47e5d8..c68001d236 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1746,13 +1746,7 @@ compilation-start
(let ((process-environment
(append
compilation-environment
- (if (if (boundp 'system-uses-terminfo);`If' for compiler warning.
- system-uses-terminfo)
- (list "TERM=dumb" "TERMCAP="
- (format "COLUMNS=%d" (window-width)))
- (list "TERM=emacs"
- (format "TERMCAP=emacs:co#%d:tc=unknown:"
- (window-width))))
+ (comint-term-environment)
(list (format "INSIDE_EMACS=%s,compile" emacs-version))
(copy-sequence process-environment))))
(set (make-local-variable 'compilation-arguments)
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#29583: [PATCH] 25.2.50; Allow setting a custom TERM for comint
2017-12-13 3:35 ` Allen Li
@ 2018-06-06 0:22 ` Noam Postavsky
0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2018-06-06 0:22 UTC (permalink / raw)
To: Allen Li; +Cc: Michael Albinus, 29583
tags 29583 fixed
close 29583 26.1
quit
Allen Li <vianchielfaura@gmail.com> writes:
> Subject: [PATCH] Add option to configure comint TERM
It was pushed.
[1: 8ed529f0f3]: 2017-12-15 11:30:25 +0200
Add option to configure comint TERM
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=8ed529f0f300487600ac49cff22cce09c45db94b
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-06 0:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05 20:40 bug#29583: 25.2.50; Allow setting a custom TERM for comint Allen Li
2017-12-05 22:08 ` bug#29583: [PATCH] " Allen Li
2017-12-12 9:16 ` Michael Albinus
2017-12-13 3:35 ` Allen Li
2018-06-06 0:22 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.