* bug#30134: ehsell and process-environment variable
@ 2018-01-16 2:31 SK Kim
2018-01-16 3:40 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: SK Kim @ 2018-01-16 2:31 UTC (permalink / raw)
To: 30134
[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]
I found weird situation and looked into it by myself but I couldn't
solve it. so I'm writing down this mail now.
I wanted to make a new term with modifed process-environment but it
did not work properly when I make a new term from eshell buffer. The
situation can be reproduced as below.
1) start emacs with 'emacs -Q'
2) evaluate below code in any buffer.
(let ((process-environment (cons "TEST=1234" process-environment)))
(make-term "test-term" "/bin/bash"))
3) moved to buffer 'test-term' and type 'echo $TEST' and you can see
the result '1234'
Above is what I expected modified process-environment variable would
work and it actually works as I expected. However there is a condition
it doesn't work as I expected.
1) start emacs with 'emacs -Q'
2) 'M-x eshell' to open eshell buffer.
3) evaluate below code in eshell buffer.
(let ((process-environment (cons "TEST=1234" process-environment)))
(make-term "test-term" "/bin/bash"))
4) moved to buffer 'test-term' and type 'echo $TEST' and you can see
nothing.
The modified process-environment variable is not properly affected if
the code is evaluated in eshell buffer. The eshell buffer is the only
buffer that I found the above code is not working properly.
This is tested on GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, X toolkit,
Xaw scroll bars) of 2017-12-13
Possibly this might not be a bug and there is specific reason it works
that way but I couldn't have found any information about this and
couldn't have solved this by myself neither. So now I am sending this
bug report.
Thanks for everyone contributing to emacs. I appreciate it.
Thanks.
[-- Attachment #2: Type: text/html, Size: 2345 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#30134: ehsell and process-environment variable
2018-01-16 2:31 bug#30134: ehsell and process-environment variable SK Kim
@ 2018-01-16 3:40 ` Eli Zaretskii
[not found] ` <CAKYNWwSCjTu=tU=Kx9x8-7RxaHyeaXE6OpkEBvWvNQGVM_GsFA@mail.gmail.com>
2018-01-16 18:03 ` Glenn Morris
0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2018-01-16 3:40 UTC (permalink / raw)
To: SK Kim; +Cc: 30134
> From: SK Kim <tttuuu888@gmail.com>
> Date: Tue, 16 Jan 2018 11:31:27 +0900
>
> 1) start emacs with 'emacs -Q'
>
> 2) 'M-x eshell' to open eshell buffer.
>
> 3) evaluate below code in eshell buffer.
> (let ((process-environment (cons "TEST=1234" process-environment)))
> (make-term "test-term" "/bin/bash"))
>
> 4) moved to buffer 'test-term' and type 'echo $TEST' and you can see
> nothing.
>
> The modified process-environment variable is not properly affected if
> the code is evaluated in eshell buffer. The eshell buffer is the only
> buffer that I found the above code is not working properly.
process-environment is for invoking other programs from Emacs. By
contrast, Eshell does not invoke any other program, it is implemented
in Emacs itself. And process-environment doesn't affect Emacs itself.
That is why you see the difference with other programs, in particular
shells invoked from Emacs.
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <CAKYNWwSCjTu=tU=Kx9x8-7RxaHyeaXE6OpkEBvWvNQGVM_GsFA@mail.gmail.com>]
* bug#30134: ehsell and process-environment variable
[not found] ` <CAKYNWwSCjTu=tU=Kx9x8-7RxaHyeaXE6OpkEBvWvNQGVM_GsFA@mail.gmail.com>
@ 2018-01-16 17:04 ` Eli Zaretskii
0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2018-01-16 17:04 UTC (permalink / raw)
To: SK Kim; +Cc: 30134
[Please keep the bug address on the CC list.]
> From: SK Kim <tttuuu888@gmail.com>
> Date: Tue, 16 Jan 2018 16:09:17 +0900
>
> So that means, this result is natural in Emacs and package authors
> should also avoid such a code. Is this right?
Yes, I think so.
> Maybe if I want to guarantee the code is working properly in any
> buffers of Emacs, I should wrap the code with 'with-temp-buffer' as below.
>
> (with-temp-buffer
> (let ((process-environment (cons "TEST=1234" process-environment)))
> (make-term "test-term" "/bin/bash")))
Maybe. I will take another look in a couple of days.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#30134: ehsell and process-environment variable
2018-01-16 3:40 ` Eli Zaretskii
[not found] ` <CAKYNWwSCjTu=tU=Kx9x8-7RxaHyeaXE6OpkEBvWvNQGVM_GsFA@mail.gmail.com>
@ 2018-01-16 18:03 ` Glenn Morris
2018-01-18 6:11 ` SK Kim
1 sibling, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2018-01-16 18:03 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 30134, SK Kim
Eli Zaretskii wrote:
>> 2) 'M-x eshell' to open eshell buffer.
>>
>> 3) evaluate below code in eshell buffer.
>> (let ((process-environment (cons "TEST=1234" process-environment)))
>> (make-term "test-term" "/bin/bash"))
>>
>> 4) moved to buffer 'test-term' and type 'echo $TEST' and you can see
>> nothing.
[...]
> process-environment is for invoking other programs from Emacs. By
> contrast, Eshell does not invoke any other program, it is implemented
> in Emacs itself. And process-environment doesn't affect Emacs itself.
> That is why you see the difference with other programs, in particular
> shells invoked from Emacs.
I don't think that's relevant to this report, where a bash shell is
being invoked, it just happens to be launched from an eshell buffer.
eshell seems to have some special handling for process-environment,
which is (presumably) the cause of this difference from other buffers.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#30134: ehsell and process-environment variable
2018-01-16 18:03 ` Glenn Morris
@ 2018-01-18 6:11 ` SK Kim
2018-01-18 17:49 ` Glenn Morris
2018-01-18 17:52 ` Noam Postavsky
0 siblings, 2 replies; 9+ messages in thread
From: SK Kim @ 2018-01-18 6:11 UTC (permalink / raw)
To: 30134
[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]
I have looked into eshell and make-term source and narrowed down the
range of the issue somewhat.
If I evaluate the test code from eshell buffer, process-environment
lose "TEST=1234" inside make-term function as below.
(defun make-term (name program &optional startfile &rest switches)
(let ((buffer (get-buffer-create (concat "*" name "*"))))
(cond ((not (term-check-proc buffer))
;; Here, process-environemnt still have "TEST=1234"
(with-current-buffer buffer
;; Here, process-environemnt lost "TEST=1234"
(term-mode))
(term-exec buffer name program startfile switches)))
buffer))
I still don't know why but process-environment lost some values when
creating new buffer with 'get-buffer-create' function.
You can test this as below:
1-1) emacs -Q
1-2) evaluate below code.
(let ((process-environment (cons "TEST=1234" process-environment)))
(get-buffer-create "test-buffer")
(switch-to-buffer "test-buffer")
(member "TEST=1234" process-environment))
1-3) you can see "TEST=1234" is a member of process-environment in new
buffer.
2-1) emacs -Q
2-2) M-x eshell
2-3) evaluate below code in eshell buffer.
(let ((process-environment (cons "TEST=1234" process-environment)))
(get-buffer-create "test-buffer")
(switch-to-buffer "test-buffer")
(member "TEST=1234" process-environment))
2-4) you can see "TEST=1234" is lost from process-environment.
You can also test this simply as below.
3-1) emacs -Q
3-2) M-x eshell
3-3) evaluate below code in eshell buffer.
(let ((process-environment (cons "TEST=1234" process-environment)))
(with-temp-buffer
(member "TEST=1234" process-environment)))
3-4) you can see "TEST=1234" is lost from process-environment.
[-- Attachment #2: Type: text/html, Size: 2689 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#30134: ehsell and process-environment variable
2018-01-18 6:11 ` SK Kim
@ 2018-01-18 17:49 ` Glenn Morris
2018-01-18 17:54 ` Glenn Morris
2018-01-18 17:52 ` Noam Postavsky
1 sibling, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2018-01-18 17:49 UTC (permalink / raw)
To: SK Kim; +Cc: 30134
[Please reply-to-all]
SK Kim wrote:
> I still don't know why but process-environment lost some values when
> creating new buffer with 'get-buffer-create' function.
Eshell makes process-environment buffer-local.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#30134: ehsell and process-environment variable
2018-01-18 6:11 ` SK Kim
2018-01-18 17:49 ` Glenn Morris
@ 2018-01-18 17:52 ` Noam Postavsky
1 sibling, 0 replies; 9+ messages in thread
From: Noam Postavsky @ 2018-01-18 17:52 UTC (permalink / raw)
To: SK Kim; +Cc: 30134
On Thu, Jan 18, 2018 at 1:11 AM, SK Kim <tttuuu888@gmail.com> wrote:
> I still don't know why but process-environment lost some values when
> creating new buffer with 'get-buffer-create' function.
Probably because it's made into a buffer-local variable in eshell buffers:
(defun eshell-var-initialize ()
"Initialize the variable handle code."
;; Break the association with our parent's environment. Otherwise,
;; changing a variable will affect all of Emacs.
(unless eshell-modify-global-environment
(set (make-local-variable 'process-environment)
(eshell-copy-environment)))
[...]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-01-19 1:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16 2:31 bug#30134: ehsell and process-environment variable SK Kim
2018-01-16 3:40 ` Eli Zaretskii
[not found] ` <CAKYNWwSCjTu=tU=Kx9x8-7RxaHyeaXE6OpkEBvWvNQGVM_GsFA@mail.gmail.com>
2018-01-16 17:04 ` Eli Zaretskii
2018-01-16 18:03 ` Glenn Morris
2018-01-18 6:11 ` SK Kim
2018-01-18 17:49 ` Glenn Morris
2018-01-18 17:54 ` Glenn Morris
2018-01-19 1:33 ` SK Kim
2018-01-18 17:52 ` 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.