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.devel Subject: Re: INSIDE_EMACS and Tramp Date: Sun, 03 May 2020 16:52:18 +0200 Message-ID: <87zhapf4v1.fsf@gmail.com> 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> <87o8r6wfni.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="88951"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: emacs-devel@gnu.org To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 03 16:54:13 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 1jVG0T-000N2H-Ir for ged-emacs-devel@m.gmane-mx.org; Sun, 03 May 2020 16:54:13 +0200 Original-Received: from localhost ([::1]:59650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVG0S-000704-La for ged-emacs-devel@m.gmane-mx.org; Sun, 03 May 2020 10:54:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVFyh-0004X5-WE for emacs-devel@gnu.org; Sun, 03 May 2020 10:52:24 -0400 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:51479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVFyg-0007h1-G5 for emacs-devel@gnu.org; Sun, 03 May 2020 10:52:23 -0400 Original-Received: by mail-wm1-x329.google.com with SMTP id x4so5471833wmj.1 for ; Sun, 03 May 2020 07:52:22 -0700 (PDT) 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=oAFlEGRkfaPJhdq1H8EoKFZMtjQsc4jd/OBVrNlVxe0=; b=JrmApJLcuLEay+KNwdpJ9rPFHvzrZPNExc3XiKDpH25gN8xwJ38Mn62UBcF+34pkYK Fr00/AcHisynGlziFvb/6mYgJK6H+yNefPykOrKjFRDpGpa/1dm1aPU+42EGLwz//4vI 5j5CJMi1XeNpDkp26Lx1FsdDoSoxSAu3c4SOtIv83rIHhTS1oi8fFUJdeymuqyvIuGFu YLNCPS7CV3E+Hrm9Wh6/oXGPDS7h1LkezErftWGy46nCa+sFB+nbqqEmu/PXLSgILUzH MxKnQyuJzmZyS8iNuw9KvGUCW73eXDMdFVdC9WK/eZ10oKt1Omukyws02Pv9V837wMGK gsFw== 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=oAFlEGRkfaPJhdq1H8EoKFZMtjQsc4jd/OBVrNlVxe0=; b=UvLEjFrugZvFJWGMK+AfZ/tPiSHyTq+F8KBXP8GxS6sI9VC3CN0CAX28gVgNPyamu4 R63Z5ZhSV/aT2T8k8FuqQOpGyltqmI1v9vvWY2hmTo/2qNryGuZtRw6goEZTRAaF1tXi vYy4IIDPv/OtMgYjq6zumNR1vJQ5Qm0bsCLd3ozcschA9h3zF803sOmKBoOELrWW2NBB X+Cv9mcbIhxZ92Dtzb4WuaWBPGSMWWoQOT8k6vhJvr9xs4pf1z0Y7jbXkCeyZOnY3+tp nme5pVPCAGLPMw7KwtQQ9KczHmx4WdaIWpHU3s8BTBSMSQ9XebhUuGhOWDtYDHjL3l/9 yH8w== X-Gm-Message-State: AGi0PuaUFjVQLJYVeccGr8/2omLm1+F7bCelRrk3Hx0zJ0ntB2D6f7Oo nAie/lwK2B1XrwrYpVQ+lNeNwO06WvE= X-Google-Smtp-Source: APiQypJsf/1Cqx1YP6b46AtQMX65yIj8yE7TENQMz9rniZGH71FEGKyRR9AEei1BzsnJUj50O8KtDQ== X-Received: by 2002:a1c:f306:: with SMTP id q6mr9649533wmq.169.1588517540376; Sun, 03 May 2020 07:52:20 -0700 (PDT) Original-Received: from lead ([2a02:8109:8ac0:2ff0:f846:e136:aa78:2f03]) by smtp.gmail.com with ESMTPSA id a8sm1379044wrg.85.2020.05.03.07.52.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 May 2020 07:52:19 -0700 (PDT) In-Reply-To: <87o8r6wfni.fsf@gmx.de> (Michael Albinus's message of "Sat, 02 May 2020 16:54:57 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=federicotedin@gmail.com; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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:248697 Archived-At: Hey Michael, > 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. Thanks for creating this patch! I have a couple of comments/observations. Note that this is my first time reviewing a patch by mail so formatting may not be very tidy. > diff --git a/lisp/comint.el b/lisp/comint.el > index ea06f8af87..1045d02641 100644 > --- 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=%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 > --- a/lisp/epg.el > +++ b/lisp/epg.el > @@ -606,8 +606,7 @@ epg--start > (cons (concat "GPG_TTY=" terminal-name) > (cons "TERM=xterm" process-environment)))) > (setq process-environment > - (cons (format "INSIDE_EMACS=%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 > --- 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 > --- 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='%s' INSIDE_EMACS='%s,tramp:%s' " > + "exec env TERM='%s' INSIDE_EMACS='%s' " > "ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %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=%s" > diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el > index 8d21133b3b..2351867129 100644 > --- 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. ^^^^^^^^^^ typo > +(when (symbolp inside-emacs-functions) > + (add-hook > + 'inside-emacs-functions > + (lambda () > + (when (file-remote-p default-directory) "tramp:2.5.0-pre")))) ^^^^^^^^^^^^^^^^^ Should this be `tramp-version' instead? > + > ;; 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 > --- 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=%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 > --- 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 ^^^^^^^^^^^ typo > +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=...\" string. > +This can be used to modify the `process-environment'. See > +`inside-emacs' for the CONTEXT parameter." > + (concat "INSIDE_EMACS=" (inside-emacs context))) > + > > ;;;; Prefix commands > > diff --git a/lisp/term.el b/lisp/term.el > index b990c83cfc..d6a1bdfd1f 100644 > --- a/lisp/term.el > +++ b/lisp/term.el > @@ -1535,7 +1535,7 @@ term-exec-1 > (format term-termcap-format "TERMCAP=" > term-term-name term-height term-width) > > - (format "INSIDE_EMACS=%s,term:%s" emacs-version term-protocol-version) > + (inside-emacs-envvar (format "term:%s" term-protocol-version)) > (format "LINES=%d" term-height) > (format "COLUMNS=%d" term-width)) > process-environment)) - Fede