From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#39596: 26.3; Export INSIDE_EMACS with Eshell Date: Wed, 19 Feb 2020 00:18:39 +0100 Message-ID: References: <87a75lvds8.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125658"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) Cc: 39596@debbugs.gnu.org To: Pierre Neidhardt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 19 00:19:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j4C92-000WZ7-L0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Feb 2020 00:19:12 +0100 Original-Received: from localhost ([::1]:43144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4C91-0004IN-AI for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Feb 2020 18:19:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50203) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4C8t-0004IG-Bq for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2020 18:19:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4C8r-0004PF-VP for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2020 18:19:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35489) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j4C8r-0004P7-QQ for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2020 18:19:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j4C8r-0007ma-Lb for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2020 18:19:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Feb 2020 23:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39596 X-GNU-PR-Package: emacs Original-Received: via spool by 39596-submit@debbugs.gnu.org id=B39596.158206792929898 (code B ref 39596); Tue, 18 Feb 2020 23:19:01 +0000 Original-Received: (at 39596) by debbugs.gnu.org; 18 Feb 2020 23:18:49 +0000 Original-Received: from localhost ([127.0.0.1]:41462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j4C8f-0007mA-8l for submit@debbugs.gnu.org; Tue, 18 Feb 2020 18:18:49 -0500 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:51432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j4C8d-0007lv-IL for 39596@debbugs.gnu.org; Tue, 18 Feb 2020 18:18:48 -0500 Original-Received: by mail-wm1-f50.google.com with SMTP id t23so4507064wmi.1 for <39596@debbugs.gnu.org>; Tue, 18 Feb 2020 15:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=dln/ZYK3DvGZ2Atgp240nPtIfShUPrBaGN78N/xmUxU=; b=CrMDv6SNdxk5R0bqxKR2hHCulEfXgPlff8ZNwYDisAL48TqMYNqyqhJVSbBLXHL6kY DCwN8WgJwLjxExl7NXV18TpNOhAuI2QK48p8CNHJ08EydFAo+a/R0vZzSfe9zfxiPnrC kNRZ6S62W9+iFom+7iCKs6QY0tuwtkbRRakXOat5dgCg8xCLHT87h34pBOg9xoYAwpIQ /E1A8VHZuDaoPt8b1NOVBhjeimvCIVTJsF0Y/cawL5QlRbRGouI+D/6nrLXJNWG1LoH7 rFHY38rwMMKa8wNMnnW5NLYC8Me6lwnc43Z6q1sywUrYOcQ+SayCKWkG2UWXzc4UM29H 6Xyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=dln/ZYK3DvGZ2Atgp240nPtIfShUPrBaGN78N/xmUxU=; b=jx2MS+aXiLVk61VPKd5+9XHh2TpBwC+fFpb533l/mkkI5x3k6BIczDxRJ/0gHD4bil lD3R2W6HXF07Jv+IMTuYFEPM5xmm5ALgLxyFrdu9SPysVcK2zWWct9X/7VSEvE3bq1EF NDLJtdxYP3OzqfyfdwCjIxijPuGBQRHEwrViAep8588t/INqc2EzsWBGRjAqQuVoVLBs VkAhjAL74XinrGNoec6mnfTfe3ZtUFEmCnS5L9AISAahs+zsxvVbWPmwJxARuMXiSzgk 11+Hz//TA3KFkVnz+Ml5CW7HSLbJ/XplGC8yvJS5Vdrc+2qFDvOQqX/9YMNdrelgxTXG zFCg== X-Gm-Message-State: APjAAAV6ojz+MOvcXmFRlM8hZL2+pwDt1D9MIel+oMUofcRJtMlyySqQ ZgukGcPBjyKtP1HTY0efYCQlegvx X-Google-Smtp-Source: APXvYqxvTvIdYPo1Z/TxG3Pg5StlF1FvLOGFdg1gG+73i6kk9gFnMd6d1u8SSma2TSnz8LthPlmcEA== X-Received: by 2002:a05:600c:2254:: with SMTP id a20mr5118511wmm.188.1582067921354; Tue, 18 Feb 2020 15:18:41 -0800 (PST) Original-Received: from BERMB00016 ([2a02:8109:8ac0:2ff0:f102:995d:d75f:fabc]) by smtp.gmail.com with ESMTPSA id g15sm274746wro.65.2020.02.18.15.18.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2020 15:18:40 -0800 (PST) In-Reply-To: <87a75lvds8.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Fri, 14 Feb 2020 08:17:11 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:176228 Archived-At: --=-=-= Content-Type: text/plain > 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Copy-INSIDE_EMACS-env-variable-to-subprocesses-in-Es.patch >From cf93960de7d3d92ccb7a5465851bbcb55a0f20d9 Mon Sep 17 00:00:00 2001 From: Federico Tedin 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) --=-=-=--