[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (getenv "TERM") always returns "dumb"

From: Juri Linkov
Subject: Re: (getenv "TERM") always returns "dumb"
Date: Sat, 04 Sep 2004 01:34:03 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:
>>     Most processes started from within Emacs do not talk to a smart
>>     terminal, but they believe they do.
>> Why do they believe they do?  Is it because the Lisp code that starts
>> them does not specify "dumb" as the terminal type?
>> If so, the straightforward solution is to change the Lisp code
>> that invokes them.
> Right, but *none* of the subprocesses can talk directly to the terminal on
> which Emacs was started, so every single piece of elisp that starts
> a process should change the TERM variable.  It seems preferable to change it
> once and forall, doesn't it?

If there is a real need to preserve the initial environment, the whole
initial `process-environment' could be copied to some new special

OTOH, if modifying the TERM variable is only needed for subprocesses,
all low-level functions that invoke subprocesses could append the TERM
variable to `process-environment' locally from some new user option
which specifies additional environment variables for subprocesses, e.g.

(defcustom exec-variables '("TERM=dumb" ...) ...)

BTW, there is one problem in the `setenv' function - it modifies
`process-environment' destructively, and so the global value becomes
modified even for let-bound variables:

(getenv "TERM") -> "dumb"
(let ((process-environment process-environment)) (setenv "TERM" "xterm")) -> 
(getenv "TERM") -> "xterm"

Of course, `copy-sequence' might be used in this case, but there are
many places in Emacs where the copy is not created for let-bound
`process-environment'.  This is too error-prone.

I think, unless there are reasons not to do so, to replace `setcar'
in `setenv' with code deleting the old element and adding a new one
to the head of the list.

Juri Linkov

reply via email to

[Prev in Thread] Current Thread [Next in Thread]