Add option to configure comint TERM

* lisp/comint.el (comint-terminfo-terminal): New defcustom.
(comint-term-environment): New function for setting terminal options
(comint-exec-1): Use comint-term-environment.  (Bug#29583)
* lisp/progmodes/compile.el (compilation-start): Use comint-term-environment.

* etc/NEWS:
* doc/emacs/misc.texi (Shell Options): Document the new option.
This commit is contained in:
Allen Li 2017-12-15 11:30:25 +02:00 committed by Eli Zaretskii
parent 889f07c352
commit 8ed529f0f3
4 changed files with 39 additions and 20 deletions

View file

@ -1396,6 +1396,15 @@ directory stack if they are not already on it
(@code{shell-pushd-dunique}). The values you choose should match the
underlying shell, of course.
@vindex comint-terminfo-terminal
Comint mode sets the @env{TERM} environment variable to a safe default
value, but this value disables some useful features. For example,
color is disabled for applications that use @env{TERM} to determine if
color is supported. Therefore, Emacs provides an option
@code{comint-terminfo-terminal}, which you can set to a terminal that
is present in your system's terminfo database, in order to take
advantage of advanced features of that terminal.
@node Terminal emulator
@subsection Emacs Terminal Emulator
@findex term

View file

@ -812,6 +812,13 @@ whose content matches a regexp; bound to '% g'.
*** New user option 'comint-move-point-for-matching-input' to control
where to place point after 'C-c M-r' and 'C-c M-s'.
+++
*** New user option 'comint-terminfo-terminal'.
This option allows control of the value of the TERM environment
variable Emacs puts into the environment of the Comint mode and its
derivatives, such as Shell mode and Compilation Shell minor-mode. The
default is "dumb", for compatibility with previous behavior.
** Compilation mode
---

View file

@ -459,6 +459,11 @@ executed once when the buffer is created."
: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:
@ -817,19 +822,7 @@ series of processes in the same Comint buffer. The hook
(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
@ -858,6 +851,22 @@ series of processes in the same Comint buffer. The hook
(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)))

View file

@ -1746,13 +1746,7 @@ Returns the compilation buffer created."
(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)