From: Allen Li <vianchielfaura@gmail.com>
To: 29583@debbugs.gnu.org
Subject: bug#29583: [PATCH] 25.2.50; Allow setting a custom TERM for comint
Date: Tue, 5 Dec 2017 14:08:08 -0800 [thread overview]
Message-ID: <CAJr1M6d6rPnnf=WFAHdcsUSN68SU7Jic_0i=yW5WbQqM704gkQ@mail.gmail.com> (raw)
In-Reply-To: <CAJr1M6eOtC3+h3jFJZ5FnxJy5uKOx3zrr21AV4uD-fKmaETgDw@mail.gmail.com>
[-- 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
next prev parent reply other threads:[~2017-12-05 22:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2017-12-12 9:16 ` bug#29583: [PATCH] " Michael Albinus
2017-12-13 3:35 ` Allen Li
2018-06-06 0:22 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJr1M6d6rPnnf=WFAHdcsUSN68SU7Jic_0i=yW5WbQqM704gkQ@mail.gmail.com' \
--to=vianchielfaura@gmail.com \
--cc=29583@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).