aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Li2017-12-15 11:30:25 +0200
committerEli Zaretskii2017-12-15 11:30:25 +0200
commit8ed529f0f300487600ac49cff22cce09c45db94b (patch)
tree73ae92d652246239b34d9aa1b793a6767d860f14
parent889f07c352f7e0deccf59353a60a45f2716551d8 (diff)
downloademacs-8ed529f0f300487600ac49cff22cce09c45db94b.tar.gz
emacs-8ed529f0f300487600ac49cff22cce09c45db94b.zip
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.
-rw-r--r--doc/emacs/misc.texi9
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/comint.el35
-rw-r--r--lisp/progmodes/compile.el8
4 files changed, 39 insertions, 20 deletions
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 6ad5fbafdd6..b6b396af8f5 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1396,6 +1396,15 @@ directory stack if they are not already on it
1396(@code{shell-pushd-dunique}). The values you choose should match the 1396(@code{shell-pushd-dunique}). The values you choose should match the
1397underlying shell, of course. 1397underlying shell, of course.
1398 1398
1399@vindex comint-terminfo-terminal
1400Comint mode sets the @env{TERM} environment variable to a safe default
1401value, but this value disables some useful features. For example,
1402color is disabled for applications that use @env{TERM} to determine if
1403color is supported. Therefore, Emacs provides an option
1404@code{comint-terminfo-terminal}, which you can set to a terminal that
1405is present in your system's terminfo database, in order to take
1406advantage of advanced features of that terminal.
1407
1399@node Terminal emulator 1408@node Terminal emulator
1400@subsection Emacs Terminal Emulator 1409@subsection Emacs Terminal Emulator
1401@findex term 1410@findex term
diff --git a/etc/NEWS b/etc/NEWS
index 6151543ee4e..784c608041b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -812,6 +812,13 @@ whose content matches a regexp; bound to '% g'.
812*** New user option 'comint-move-point-for-matching-input' to control 812*** New user option 'comint-move-point-for-matching-input' to control
813where to place point after 'C-c M-r' and 'C-c M-s'. 813where to place point after 'C-c M-r' and 'C-c M-s'.
814 814
815+++
816*** New user option 'comint-terminfo-terminal'.
817This option allows control of the value of the TERM environment
818variable Emacs puts into the environment of the Comint mode and its
819derivatives, such as Shell mode and Compilation Shell minor-mode. The
820default is "dumb", for compatibility with previous behavior.
821
815** Compilation mode 822** Compilation mode
816 823
817--- 824---
diff --git a/lisp/comint.el b/lisp/comint.el
index dcf1ff794f9..7c56c259c49 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -459,6 +459,11 @@ executed once when the buffer is created."
459 :type 'hook 459 :type 'hook
460 :group 'comint) 460 :group 'comint)
461 461
462(defcustom comint-terminfo-terminal "dumb"
463 "Value to use for TERM when the system uses terminfo."
464 :type 'string
465 :group 'comint)
466
462(defvar comint-mode-map 467(defvar comint-mode-map
463 (let ((map (make-sparse-keymap))) 468 (let ((map (make-sparse-keymap)))
464 ;; Keys: 469 ;; Keys:
@@ -817,19 +822,7 @@ series of processes in the same Comint buffer. The hook
817(defun comint-exec-1 (name buffer command switches) 822(defun comint-exec-1 (name buffer command switches)
818 (let ((process-environment 823 (let ((process-environment
819 (nconc 824 (nconc
820 ;; If using termcap, we specify `emacs' as the terminal type 825 (comint-term-environment)
821 ;; because that lets us specify a width.
822 ;; If using terminfo, we specify `dumb' because that is
823 ;; a defined terminal type. `emacs' is not a defined terminal type
824 ;; and there is no way for us to define it here.
825 ;; Some programs that use terminfo get very confused
826 ;; if TERM is not a valid terminal type.
827 ;; ;; There is similar code in compile.el.
828 (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
829 (list "TERM=dumb" "TERMCAP="
830 (format "COLUMNS=%d" (window-width)))
831 (list "TERM=emacs"
832 (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width))))
833 (list (format "INSIDE_EMACS=%s,comint" emacs-version)) 826 (list (format "INSIDE_EMACS=%s,comint" emacs-version))
834 process-environment)) 827 process-environment))
835 (default-directory 828 (default-directory
@@ -858,6 +851,22 @@ series of processes in the same Comint buffer. The hook
858 (set-process-coding-system proc decoding encoding)) 851 (set-process-coding-system proc decoding encoding))
859 proc)) 852 proc))
860 853
854(defun comint-term-environment ()
855 "Return an environment variable list for terminal configuration."
856 ;; If using termcap, we specify `emacs' as the terminal type
857 ;; because that lets us specify a width.
858 ;; If using terminfo, we default to `dumb' because that is
859 ;; a defined terminal type. `emacs' is not a defined terminal type
860 ;; and there is no way for us to define it here.
861 ;; Some programs that use terminfo get very confused
862 ;; if TERM is not a valid terminal type.
863 (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
864 (list (format "TERM=%s" comint-terminfo-terminal)
865 "TERMCAP="
866 (format "COLUMNS=%d" (window-width)))
867 (list "TERM=emacs"
868 (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))))
869
861(defun comint-nonblank-p (str) 870(defun comint-nonblank-p (str)
862 "Return non-nil if STR contains non-whitespace syntax." 871 "Return non-nil if STR contains non-whitespace syntax."
863 (not (string-match "\\`\\s *\\'" str))) 872 (not (string-match "\\`\\s *\\'" str)))
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 4cce47e5d8c..c68001d2366 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1746,13 +1746,7 @@ Returns the compilation buffer created."
1746 (let ((process-environment 1746 (let ((process-environment
1747 (append 1747 (append
1748 compilation-environment 1748 compilation-environment
1749 (if (if (boundp 'system-uses-terminfo);`If' for compiler warning. 1749 (comint-term-environment)
1750 system-uses-terminfo)
1751 (list "TERM=dumb" "TERMCAP="
1752 (format "COLUMNS=%d" (window-width)))
1753 (list "TERM=emacs"
1754 (format "TERMCAP=emacs:co#%d:tc=unknown:"
1755 (window-width))))
1756 (list (format "INSIDE_EMACS=%s,compile" emacs-version)) 1750 (list (format "INSIDE_EMACS=%s,compile" emacs-version))
1757 (copy-sequence process-environment)))) 1751 (copy-sequence process-environment))))
1758 (set (make-local-variable 'compilation-arguments) 1752 (set (make-local-variable 'compilation-arguments)