From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.devel Subject: Re: Managing environments (Python venv, guix environment, etc.) Date: Sun, 17 Jul 2016 18:41:04 -0400 Message-ID: <87r3arripr.fsf@earth.catern.com> References: <87y453sy0n.fsf@earth.catern.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468795296 20118 80.91.229.3 (17 Jul 2016 22:41:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 Jul 2016 22:41:36 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 18 00:41:28 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bOukZ-0005AG-Cd for ged-emacs-devel@m.gmane.org; Mon, 18 Jul 2016 00:41:27 +0200 Original-Received: from localhost ([::1]:43299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOukY-0002WY-JO for ged-emacs-devel@m.gmane.org; Sun, 17 Jul 2016 18:41:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOukR-0002WI-SM for emacs-devel@gnu.org; Sun, 17 Jul 2016 18:41:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOukL-0003n2-SL for emacs-devel@gnu.org; Sun, 17 Jul 2016 18:41:18 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:52341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOukL-0003my-L1 for emacs-devel@gnu.org; Sun, 17 Jul 2016 18:41:13 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1bOukJ-0004x8-RQ for emacs-devel@gnu.org; Mon, 18 Jul 2016 00:41:12 +0200 Original-Received: from 71-46-80-67.res.bhn.net ([71.46.80.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jul 2016 00:41:11 +0200 Original-Received: from sbaugh by 71-46-80-67.res.bhn.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 18 Jul 2016 00:41:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 71-46-80-67.res.bhn.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:KifywOoNZifF0Zohb1VCxDyK//Y= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:205788 Archived-At: > If M-x compile obeys dir-locals that could work, yes. I checked (by creating a .dir-locals.el containing a setting for the exec-path variable in compliation-mode) and it doesn't seem to read exec-path from dir-locals. > Another option is to use process-file's file-name-handler-alist. So we'd maintain a mapping from visited filenames to the environment that that filename is in, and make sure that visited filenames in a nonstandard environment are present in file-name-handler-alist. Tying environments to filenames in this way makes sense when an environment corresponds to a project which exists in the filesystem. In that case we can just put the project root directory into file-name-handler-alist, and instantly everything in the project works in the new environment. And for running one-off commands (to send my mail, or something else not associated with any project) I've always been able to just wrap the command with a let-binding of exec-path and process-environment. (The environment package could provide a new macro to do that) So then there would be two ways to enter a different environment for Emacs: One for projects and based on file-name-handler-alist, and one for single commands and based on let-binding. I think that would be enough to start. Does this approach (putting project root directories into file-name-handler-alist) sound like something that could be accepted into core Emacs? If so I'll get started. Also, in the future, it would be nice to have the ability to just run (something like) "M-x environment-switch" to switch the current buffer to a new environment, and have an invocation of e.g. "M-x compile" just work. Does anyone have any thoughts about how to eventually support that? Is there a clever way to do it, or will we just have to end up rewriting the world? > And of course, yet another is to advice-add on call-process and > start-process. Yeah, but I'd like to be able to get this into Emacs (hopefully by 26). Thanks for the advice!