From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: INSIDE_EMACS and Tramp Date: Sat, 02 May 2020 16:54:57 +0200 Message-ID: <87o8r6wfni.fsf@gmx.de> References: <20200402230535.10490.95720@vcs0.savannah.gnu.org> <20200402230536.E0A3F20CDD@vcs0.savannah.gnu.org> <87lfndarwh.fsf_-_@gmx.de> <87blo78exg.fsf@gmx.de> <871rp357s1.fsf@gmail.com> <87lfmzg3ds.fsf@gmx.de> <87a7397tqz.fsf@gmail.com> 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="19040"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Federico Tedin Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 02 16:57:58 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jUtaX-0004oT-43 for ged-emacs-devel@m.gmane-mx.org; Sat, 02 May 2020 16:57:57 +0200 Original-Received: from localhost ([::1]:60772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUtaV-0007Cm-Vs for ged-emacs-devel@m.gmane-mx.org; Sat, 02 May 2020 10:57:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUtXk-00013l-S9 for emacs-devel@gnu.org; Sat, 02 May 2020 10:55:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUtXj-0003L9-ID for emacs-devel@gnu.org; Sat, 02 May 2020 10:55:04 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:40629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUtXi-0003IF-R0 for emacs-devel@gnu.org; Sat, 02 May 2020 10:55:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1588431300; bh=apFNtJVuHv0YgST4bv9isGEPRcxUEY6wkPydst4lM+c=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=gPL5JpqwXAaF+EnrX7x/97nDyq4xjIQ/DwB0p8AaXBokgtaBXyNXNrA+M+Ue4xDBp YmmE4DEAV1oviUgVeGJ9YNYCXNRmF/rtA6RUr/1sNOgAiwLGNhKT/Q/JzxQZCCwzVe PlsEfqywMwGeVWy/5QVxx3GMtxMRJBVa5unOlsf0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.112.148]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MpUUm-1inuIa0FES-00pvqH; Sat, 02 May 2020 16:55:00 +0200 In-Reply-To: <87a7397tqz.fsf@gmail.com> (Federico Tedin's message of "Fri, 17 Apr 2020 22:16:36 +0200") X-Provags-ID: V03:K1:ObtB7BWTKVJxbHejk5tSFF2cbd+bVYEOmFQFQegxIhFLci8JLH1 6iBnLSK71TjLHPa5fFYh25+HUxg4ePUboM2beZCLhxBW529bAlY1YMjlzBHX8BUBWjd6I6p YDBwrhn/yXSeU/0EHzzbPPeYnpK3IgJY9cqO7YCQm+eODzbgKd1Pg0yT1qC5im2ZxZxtnQ7 P6tcRcnVYbs/ecfE8bAUQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ucT/AVFB3kk=:zP4E9E7BivEf2T01KftgUl 2At4Sd6JU+yxfE+78yrgm/CR6ZRt6cTgyA0kKBZWwwCpBycNF3/AtL/BxM+XeL4qyFryMCoLt MsisT3LQbrVMm1xyH0QyNp/zJh5SyNHmKn0gEg83MZH+lwBXdyr44eBpA/1FEI7Eip5tNV1oU Sd8MLNZ065YgA8lgm0rOMYrTK9PFMHYRATFjdzWpwAcRXtfUgbG/B0xGITsXF4bCiKMJkAsqo 3jwn6W58FHdGzIwNDI/gMlMKl3jOEJVBkzCPv4wGiM+YrOoQBlUUXs8ZjBR9Wk+PESDOZaX9M 7A+d12ypEXnN5xICSv1r1Ea2n1NIJDOzRdPkPVc0jdXMYt3TYlrY0KZUYSHh1MyervlwMy5OY URv9c81TvEJMSmFq6UEf3+lqlMSWPgPH/teYx3gXHecFkrAcaIBI7wq0dK4cBHWjMb9XYF8cl rMrUu0XxFX7h1n5PxoboeJmaK94KtjVWRKMcjGDcdMFF8O7HI1CKAfOkcg8VIIAXTzX0Rsiez n6FRElHpBLyawXPSDYeWO+i3BjmN91DkIwVJ0v7t1o8iR2MML7tNaTFkz6A44wS9K2MTHJL1L ByhuVAVW7mUKgfGhF9zR5dXY2aJT7qZ/1SK8NdI1FJ6pJphlM10O2RuJijPLFb4/5eLntYF0B hLAlAq520fPOsO6uxon3c/zNdr47T/N17++4l303SZppO1aqEPSjqnjIXI5RRLe5yo+VTasYK kkpXYwfejnC8Gx8j8R5AcjQQ7f4mh5z7xpQD6X3NnSYrkAY8xExLzPfsdUJc27DRjNCyHvdR Received-SPF: pass client-ip=212.227.17.22; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/02 06:32:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:248460 Archived-At: --=-=-= Content-Type: text/plain Federico Tedin writes: > Hi Michael, Hi Federico, > OK, I see that it is more useful in this case to have a list of > functions that are called rather than a fixed list of strings. However I > didn't understand your use of `run-hooks' - wouldn't this function call > return nil in all cases? What would be an easy way of getting the > results of calling all the hooks? You're right, `run-hooks' was a stupid idea. I have adapted my proposal and prepared a patch which works for me as expected. See appended. Eli, would it be OK to push something like this to master? > - Fede Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/comint.el b/lisp/comint.el index ea06f8af87..1045d02641 100644 =2D-- a/lisp/comint.el +++ b/lisp/comint.el @@ -831,7 +831,7 @@ comint-exec-1 (let ((process-environment (nconc (comint-term-environment) - (list (format "INSIDE_EMACS=3D%s,comint" emacs-version)) + (list (inside-emacs-envvar "comint")) process-environment)) (default-directory (if (file-accessible-directory-p default-directory) diff --git a/lisp/epg.el b/lisp/epg.el index 222fd913e1..a5c06c9ae8 100644 =2D-- a/lisp/epg.el +++ b/lisp/epg.el @@ -606,8 +606,7 @@ epg--start (cons (concat "GPG_TTY=3D" terminal-name) (cons "TERM=3Dxterm" process-environment)))) (setq process-environment - (cons (format "INSIDE_EMACS=3D%s,epg" emacs-version) - process-environment)) + (cons (inside-emacs-envvar "epg") process-environment)) ;; Record modified time of gpg-agent socket to restore the Emacs ;; frame on text terminal in `epg-wait-for-completion'. ;; See diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 51df6fa1d5..7218279e08 100644 =2D-- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el @@ -168,9 +168,6 @@ eshell-dirstack (defvar eshell-last-dir-ring nil "The last directory that Eshell was in.") -(defconst eshell-inside-emacs (format "%s,eshell" emacs-version) - "Value for the `INSIDE_EMACS' environment variable.") - ;;; Functions: (defun eshell-dirs-initialize () ;Called from `eshell-mode' via intern= -soft! @@ -195,7 +192,8 @@ eshell-dirs-initialize (expand-file-name (ring-ref eshell-last-dir-ring 0)))) t) - ("INSIDE_EMACS" eshell-inside-emacs + ("INSIDE_EMACS" ,(lambda (_indices) + (inside-emacs "eshell")) t)))) (when eshell-cd-on-directory diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index a39d503e22..414fca10cc 100644 =2D-- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -4166,10 +4166,10 @@ tramp-open-shell vec (format (eval-when-compile (concat - "exec env TERM=3D'%s' INSIDE_EMACS=3D'%s,tramp:%s' " + "exec env TERM=3D'%s' INSIDE_EMACS=3D'%s' " "ENV=3D%s %s PROMPT_COMMAND=3D'' PS1=3D%s PS2=3D'' PS3=3D'' %s %s= ")) tramp-terminal-type - emacs-version tramp-version ; INSIDE_EMACS + (inside-emacs) (or (getenv-internal "ENV" tramp-remote-process-environment) = "") (if (stringp tramp-histfile-override) (format "HISTFILE=3D%s" diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index 8d21133b3b..2351867129 100644 =2D-- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -76,6 +76,13 @@ tramp-repository-version (replace-regexp-in-string "\n" "" (emacs-version)))))) (unless (string-equal "ok" x) (error "%s" x))) +;; `inside-emacs-functions' has been introduces with Emacs 28.1. +(when (symbolp inside-emacs-functions) + (add-hook + 'inside-emacs-functions + (lambda () + (when (file-remote-p default-directory) "tramp:2.5.0-pre")))) + ;; Tramp versions integrated into Emacs. If a user option declares a ;; `:package-version' which doesn't belong to an integrated Tramp ;; version, it must be added here as well (see `tramp-syntax', for diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index a76a3c44a3..65c5257d93 100644 =2D-- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1823,7 +1823,7 @@ compilation-start (append compilation-environment (comint-term-environment) - (list (format "INSIDE_EMACS=3D%s,compile" emacs-version)) + (list (inside-emacs-envvar "compile")) (copy-sequence process-environment)))) (set (make-local-variable 'compilation-arguments) (list command mode name-function highlight-regexp)) diff --git a/lisp/simple.el b/lisp/simple.el index b5ba05426f..70621225ec 100644 =2D-- a/lisp/simple.el +++ b/lisp/simple.el @@ -4295,6 +4295,29 @@ list-processes (tabulated-list-print)) (display-buffer buffer) nil) + +(defvar inside-emacs-functions nil + "List of functions to compose the environment variable INSIDE_EMACS. +Every package which needs to set a string in that envirenmont +variable shall add a function without arguments, which returns +the respective string, or nil.") + +(defun inside-emacs (&optional context) + "Return the string to be set in environment variable INSIDE_EMACS. +CONTEXT could be a string which is added." + (mapconcat + #'identity + (delq nil (append `(,emacs-version + ,(and (stringp context) context)) + (mapcar #'funcall inside-emacs-functions))) + ",")) + +(defun inside-emacs-envvar (&optional context) + "Return the \"INSIDE_EMACS=3D...\" string. +This can be used to modify the `process-environment'. See +`inside-emacs' for the CONTEXT parameter." + (concat "INSIDE_EMACS=3D" (inside-emacs context))) + =0C ;;;; Prefix commands diff --git a/lisp/term.el b/lisp/term.el index b990c83cfc..d6a1bdfd1f 100644 =2D-- a/lisp/term.el +++ b/lisp/term.el @@ -1535,7 +1535,7 @@ term-exec-1 (format term-termcap-format "TERMCAP=3D" term-term-name term-height term-width) - (format "INSIDE_EMACS=3D%s,term:%s" emacs-version term-protocol-versi= on) + (inside-emacs-envvar (format "term:%s" term-protocol-version)) (format "LINES=3D%d" term-height) (format "COLUMNS=3D%d" term-width)) process-environment)) --=-=-=--