From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Buffer-local process environments Date: Thu, 29 Apr 2021 10:02:50 -0400 Message-ID: References: <87eeets6jf.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5371"; 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: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 29 16:04:00 2021 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 1lc7Gp-0001JM-VX for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Apr 2021 16:03:59 +0200 Original-Received: from localhost ([::1]:56904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lc7Go-0004nQ-Tw for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Apr 2021 10:03:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lc7Ft-0003y5-EE for emacs-devel@gnu.org; Thu, 29 Apr 2021 10:03:01 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:65215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lc7Fr-0006X8-3t for emacs-devel@gnu.org; Thu, 29 Apr 2021 10:03:00 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 88DE58089D; Thu, 29 Apr 2021 10:02:57 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3177380385; Thu, 29 Apr 2021 10:02:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1619704972; bh=p6Gk8xY3Mfz3nNdBej2o7PQEgRzsyU52gQlF8BDmWfU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=WcSd4CJPhDCRrE8JVEGjFsQGCuvupXBjElepEWNZOLZOQ8Utj0L/uFxX0bG0sEF6t 42h545ey1jh1ZNNxnbmowAmtGH2Oz2MCwRQvYK2Ou+0wBIrL0dvmo+0xKY22cGUcFf 81OQ9asEm8MbWNIa5rpQvHScmmYe99KPpV9uC7ToUhHxhLIb7veuZAdu4+O+i0kjtx F41Dj0RS9DDY7OWtii4+VibKU+ZftXyTWlR93su3KUXhWntYz6U/d+IEZO92Az1Vho QA00WoOBQet4UYvogBdybQ3i5KXqCZNB3h1f2bYlQpPjCHi9AcTiX09WgwiKlZnRzI Ib+JokH1jdnIA== Original-Received: from alfajor (unknown [157.52.10.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C1DAC1202DB; Thu, 29 Apr 2021 10:02:51 -0400 (EDT) In-Reply-To: <87eeets6jf.fsf@gmail.com> (Augusto Stoffel's message of "Thu, 29 Apr 2021 12:56:36 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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:268614 Archived-At: > So why not make buffer-local process environments an official thing? Sounds fine to me. To fix cases like `compile` or `run-python`, I think patches would be welcome regardless of what is decided in this discussion: those behaviors look like plain bugs to me. > # Local Variables: > # path: "~/path/to/some/virtualenv/bin" > # env: "VIRTUAL_ENV=$HOME/path/to/some/virtualenv" > # env: "LANG=C" > # End: A few comments: - I don't much like "special local vars" (like `eval` and `mode`), so if we can find a more general solution (i.e. one that can be useful for other settings), that would be better. Maybe # push exec-path: "~/path/to/some/virtualenv/bin" - both `exec-path` and `process-environment` are "dangerous" variables, so encouraging such uses sounds rather risky. - I'd write `path` above as `exec-path` or `PATH`, or even `$PATH`, otherwise it's unclear which "path" is meant. > --- a/lisp/progmodes/compile.el > +++ b/lisp/progmodes/compile.el > @@ -1779,6 +1779,8 @@ compilation-start > (replace-regexp-in-string "-mode\\'" "" (symbol-name mode)))) > (thisdir default-directory) > (thisenv compilation-environment) > + (this-process-environment process-environment) > + (env-buffer (when (local-variable-p 'process-environment) (buffer-name))) > outwin outbuf) > (with-current-buffer > (setq outbuf > @@ -1856,6 +1858,9 @@ compilation-start > "; default-directory: " > (prin1-to-string (abbreviate-file-name default-directory)) > " -*-\n" > + (if env-buffer > + (format "Process environment is local to buffer `%s'\n" env-buffer) > + "") > (format "%s started at %s\n\n" > mode-name > (substring (current-time-string) 0 19)) > @@ -1875,7 +1880,7 @@ compilation-start > (and (derived-mode-p 'comint-mode) > (comint-term-environment)) > (list (format "INSIDE_EMACS=%s,compile" emacs-version)) > - (copy-sequence process-environment)))) > + (copy-sequence this-process-environment)))) > (setq-local compilation-arguments > (list command mode name-function highlight-regexp)) > (setq-local revert-buffer-function 'compilation-revert-buffer) Does this work correctly when you `M-x recompile`? Stefan