* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
@ 2020-02-14 7:17 Pierre Neidhardt
2020-02-18 23:18 ` Federico Tedin
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Neidhardt @ 2020-02-14 7:17 UTC (permalink / raw)
To: 39596
[-- Attachment #1: Type: text/plain, Size: 350 bytes --]
Eshell does not have INSIDE_EMACS in its environment (unlike M-x shell)
which I think is a bug as it breaks the behaviour of programs that make
provisions for Emacs being used as a shell.
See
https://lists.gnu.org/archive/html/guix-devel/2020-02/msg00029.html
for a discussion.
Would it be possible to export this variable with Eshell? Thanks!
[-- Attachment #2.1: Type: text/plain, Size: 48 bytes --]
--
Pierre Neidhardt
https://ambrevar.xyz/
[-- Attachment #2.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-14 7:17 bug#39596: 26.3; Export INSIDE_EMACS with Eshell Pierre Neidhardt
@ 2020-02-18 23:18 ` Federico Tedin
2020-02-19 7:40 ` Pierre Neidhardt
0 siblings, 1 reply; 7+ messages in thread
From: Federico Tedin @ 2020-02-18 23:18 UTC (permalink / raw)
To: Pierre Neidhardt; +Cc: 39596
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
> Eshell does not have INSIDE_EMACS in its environment (unlike M-x shell)
> which I think is a bug as it breaks the behaviour of programs that make
> provisions for Emacs being used as a shell.
>
> See
> https://lists.gnu.org/archive/html/guix-devel/2020-02/msg00029.html
> for a discussion.
>
> Would it be possible to export this variable with Eshell? Thanks!
I have added this feature to Eshell and created a patch, please check if
this works for you.
Additionally, I noticed that the doc string for
`eshell-variable-aliases-list' mentioned an `eshell-user-aliases-list',
variable but wasn't able to find it anywhere (neither using the Git
log), so I removed the mention.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Copy-INSIDE_EMACS-env-variable-to-subprocesses-in-Es.patch --]
[-- Type: text/x-patch, Size: 4158 bytes --]
From cf93960de7d3d92ccb7a5465851bbcb55a0f20d9 Mon Sep 17 00:00:00 2001
From: Federico Tedin <federicotedin@gmail.com>
Date: Wed, 19 Feb 2020 00:11:35 +0100
Subject: [PATCH] Copy INSIDE_EMACS env variable to subprocesses in Eshell
* lisp/eshell/em-dirs.el (eshell-dirs-initialize): Add INSIDE_EMACS
variable to buffer-local value of eshell-variable-aliases-alist.
* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Update doc
string; remove mention of eshell-user-aliases-list and explain that
variables can optionally be copied to subprocesses' environments.
* test/lisp/eshell/eshell-tests.el (eshell-test/inside-emacs-var): Add
test for the INSIDE_EMACS variable.
* etc/NEWS: Announce changes.
---
etc/NEWS | 6 ++++++
lisp/eshell/em-dirs.el | 3 +++
lisp/eshell/esh-var.el | 11 ++++++-----
test/lisp/eshell/eshell-tests.el | 9 ++++++++-
4 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 1f8e6049a8..238184df24 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -120,6 +120,12 @@ To revert to the previous behaviour,
unconditionally aborts the current edebug instrumentation with the
supplied error message.
+** Eshell
+
+---
+*** Environment variable INSIDE_EMACS is now copied to subprocesses.
+Its value equals the result of evaluating '(format "%s,eshell" emacs-version)'.
+
** Tramp
+++
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 1949e5dc8f..b478ee028a 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -191,6 +191,9 @@ eshell-dirs-initialize
(unless (ring-empty-p eshell-last-dir-ring)
(expand-file-name
(ring-ref eshell-last-dir-ring 0))))
+ t)
+ ("INSIDE_EMACS" ,(lambda (_indices)
+ (format "%s,eshell" emacs-version))
t))))
(when eshell-cd-on-directory
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 327a1def46..4231be92fb 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -179,10 +179,8 @@ eshell-variable-aliases-list
(eshell-apply-indices eshell-command-arguments
indices)))))
"This list provides aliasing for variable references.
-It is very similar in concept to what `eshell-user-aliases-list' does
-for commands. Each member of this defines the name of a command,
-and the Lisp value to return for that variable if it is accessed
-via the syntax `$NAME'.
+Each member of this defines the name of a command, and the Lisp value
+to return for that variable if it is accessed via the syntax `$NAME'.
If the value is a function, that function will be called with two
arguments: the list of the indices that was used in the reference, and
@@ -190,7 +188,10 @@ eshell-variable-aliases-list
For example, a reference of `$NAME[10][20]' would result in the
function for alias `NAME' being called (assuming it were aliased to a
function), and the arguments passed to this function would be the list
-'(10 20)', and nil."
+'(10 20)', and nil.
+
+Additionally, each member may specify if it should be copied to the
+environment of created subprocesses."
:type '(repeat (list string sexp
(choice (const :tag "Copy to environment" t)
(const :tag "Use only in Eshell" nil)))))
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 026818ab06..f98e4ce92b 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -167,7 +167,14 @@ eshell-test/last-arg-var
"Test using the \"last arg\" ($_) variable"
(with-temp-eshell
(eshell-command-result-p "+ 1 2; + $_ 4"
- "3\n6\n")))
+ "3\n6\n")))
+
+(ert-deftest eshell-test/inside-emacs-var ()
+ "Test presence of \"INSIDE_EMACS\" in subprocesses"
+ (with-temp-eshell
+ (eshell-command-result-p "env"
+ (format "INSIDE_EMACS=%s,eshell"
+ emacs-version))))
(ert-deftest eshell-test/escape-nonspecial ()
"Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a
--
2.21.1 (Apple Git-122.3)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-18 23:18 ` Federico Tedin
@ 2020-02-19 7:40 ` Pierre Neidhardt
2020-02-19 16:22 ` Federico Tedin
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Neidhardt @ 2020-02-19 7:40 UTC (permalink / raw)
To: Federico Tedin; +Cc: 39596
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
Thanks for looking at this, Federico!
Your patch looks good to me, just one comment below:
> --- a/lisp/eshell/em-dirs.el
> +++ b/lisp/eshell/em-dirs.el
> @@ -191,6 +191,9 @@ eshell-dirs-initialize
> (unless (ring-empty-p eshell-last-dir-ring)
> (expand-file-name
> (ring-ref eshell-last-dir-ring 0))))
> + t)
> + ("INSIDE_EMACS" ,(lambda (_indices)
> + (format "%s,eshell" emacs-version))
> t))))
Why did you unquote the lambda here?
--
Pierre Neidhardt
https://ambrevar.xyz/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-19 7:40 ` Pierre Neidhardt
@ 2020-02-19 16:22 ` Federico Tedin
2020-02-19 16:30 ` Pierre Neidhardt
2020-02-19 17:10 ` Andreas Schwab
0 siblings, 2 replies; 7+ messages in thread
From: Federico Tedin @ 2020-02-19 16:22 UTC (permalink / raw)
To: Pierre Neidhardt; +Cc: 39596
Pierre Neidhardt <mail@ambrevar.xyz> writes:
> Thanks for looking at this, Federico!
>
> Your patch looks good to me, just one comment below:
>
>> --- a/lisp/eshell/em-dirs.el
>> +++ b/lisp/eshell/em-dirs.el
>> @@ -191,6 +191,9 @@ eshell-dirs-initialize
>> (unless (ring-empty-p eshell-last-dir-ring)
>> (expand-file-name
>> (ring-ref eshell-last-dir-ring 0))))
>> + t)
>> + ("INSIDE_EMACS" ,(lambda (_indices)
>> + (format "%s,eshell" emacs-version))
>> t))))
>
> Why did you unquote the lambda here?
I need to unquote the lambda to get its value, right? Or maybe not, and
I'm misunderstanding how lambdas work. I did notice though that the
other lambdas in the list are unquoted.
- Fede
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-19 16:22 ` Federico Tedin
@ 2020-02-19 16:30 ` Pierre Neidhardt
2020-02-19 17:10 ` Andreas Schwab
1 sibling, 0 replies; 7+ messages in thread
From: Pierre Neidhardt @ 2020-02-19 16:30 UTC (permalink / raw)
To: Federico Tedin; +Cc: 39596
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
Federico Tedin <federicotedin@gmail.com> writes:
> I need to unquote the lambda to get its value, right? Or maybe not, and
> I'm misunderstanding how lambdas work. I did notice though that the
> other lambdas in the list are unquoted.
I asked because the other lambdas are not unquoted on Emacs 26.3.
If it changed upstream, no problem then! :)
--
Pierre Neidhardt
https://ambrevar.xyz/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-19 16:22 ` Federico Tedin
2020-02-19 16:30 ` Pierre Neidhardt
@ 2020-02-19 17:10 ` Andreas Schwab
2020-02-19 21:16 ` Federico Tedin
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2020-02-19 17:10 UTC (permalink / raw)
To: Federico Tedin; +Cc: Pierre Neidhardt, 39596
On Feb 19 2020, Federico Tedin wrote:
> Pierre Neidhardt <mail@ambrevar.xyz> writes:
>
>> Thanks for looking at this, Federico!
>>
>> Your patch looks good to me, just one comment below:
>>
>>> --- a/lisp/eshell/em-dirs.el
>>> +++ b/lisp/eshell/em-dirs.el
>>> @@ -191,6 +191,9 @@ eshell-dirs-initialize
>>> (unless (ring-empty-p eshell-last-dir-ring)
>>> (expand-file-name
>>> (ring-ref eshell-last-dir-ring 0))))
>>> + t)
>>> + ("INSIDE_EMACS" ,(lambda (_indices)
>>> + (format "%s,eshell" emacs-version))
>>> t))))
>>
>> Why did you unquote the lambda here?
>
> I need to unquote the lambda to get its value, right?
Unquoting allows it to be byte-compiled.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#39596: 26.3; Export INSIDE_EMACS with Eshell
2020-02-19 17:10 ` Andreas Schwab
@ 2020-02-19 21:16 ` Federico Tedin
0 siblings, 0 replies; 7+ messages in thread
From: Federico Tedin @ 2020-02-19 21:16 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Pierre Neidhardt, 39596
Andreas Schwab <schwab@suse.de> writes:
> On Feb 19 2020, Federico Tedin wrote:
>
>> Pierre Neidhardt <mail@ambrevar.xyz> writes:
>>
>>> Thanks for looking at this, Federico!
>>>
>>> Your patch looks good to me, just one comment below:
>>>
>>>> --- a/lisp/eshell/em-dirs.el
>>>> +++ b/lisp/eshell/em-dirs.el
>>>> @@ -191,6 +191,9 @@ eshell-dirs-initialize
>>>> (unless (ring-empty-p eshell-last-dir-ring)
>>>> (expand-file-name
>>>> (ring-ref eshell-last-dir-ring 0))))
>>>> + t)
>>>> + ("INSIDE_EMACS" ,(lambda (_indices)
>>>> + (format "%s,eshell" emacs-version))
>>>> t))))
>>>
>>> Why did you unquote the lambda here?
>>
>> I need to unquote the lambda to get its value, right?
>
> Unquoting allows it to be byte-compiled.
>
> Andreas.
Wasn't aware of that, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-02-19 21:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-14 7:17 bug#39596: 26.3; Export INSIDE_EMACS with Eshell Pierre Neidhardt
2020-02-18 23:18 ` Federico Tedin
2020-02-19 7:40 ` Pierre Neidhardt
2020-02-19 16:22 ` Federico Tedin
2020-02-19 16:30 ` Pierre Neidhardt
2020-02-19 17:10 ` Andreas Schwab
2020-02-19 21:16 ` Federico Tedin
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.