From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: How to use project.el Date: Wed, 25 Nov 2020 03:54:17 +0200 Message-ID: References: <05e31c25-71c8-0973-41a3-0e705370c839@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21622"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: Help Gnu Emacs To: excalamus@tutanota.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 25 02:55:02 2020 Return-path: Envelope-to: geh-help-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 1khk1N-0005U5-4l for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 25 Nov 2020 02:55:01 +0100 Original-Received: from localhost ([::1]:47246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khk1M-0006v9-3q for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 24 Nov 2020 20:55:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khk0m-0006ux-2z for help-gnu-emacs@gnu.org; Tue, 24 Nov 2020 20:54:24 -0500 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:35758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khk0k-0006uR-3d for help-gnu-emacs@gnu.org; Tue, 24 Nov 2020 20:54:23 -0500 Original-Received: by mail-wm1-x32f.google.com with SMTP id w24so724093wmi.0 for ; Tue, 24 Nov 2020 17:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sSf17KlJGW3LqB0LGw8vNUV61JFP/1YbTu5aRzTW/BM=; b=JYKvdGqUJ8CsJQh9Ml26SpLrA7dQlNYrJg4yBuJA6K8mtOO6GHU//AGo654Lt7RR1o vnRHxuIpBM7beHDasvDJxbeePdJuRUW0ncrDM5q+WFTma9ZjU2lBw2yJevAM5WyfBhti rWQpp8lFTXdukp3bOGC8IYHX20FM5sUljU51Pr+S4cHHINmAgK3no/Mi1/maUdAkPADX IHRaXHFQZoW5Cy8+Jc/72o0sAwXWrHvYmO5WyjH4MFK/ChvYgHUlwKslrO0cQtmAQ+2A JBVbudnKD00iS40rVyruurWeBfaAEtOkgCjU0w/TJnlbxLKh5xvDaf6LRfAruriyBaFk 4IaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sSf17KlJGW3LqB0LGw8vNUV61JFP/1YbTu5aRzTW/BM=; b=D5a79ZzJSzO2ZwO7LeK+tr1znupvDVNiW4pmHBCb3HMc41EWk540KXievkEsiYZp4S hrvINHskoMVZy14B+x2FQFsTU3/4Pel367f7Fw1OXIyRYNjMNNv9lb1OtadrS9ny/nna emysI5jS5ZN8KG6G671RJjVK45US+9lwdEUkyLbjistmf6pitnS7BahtbRvSKS6xnC63 tPjTz+cUh92DNZMWT1BO8AeI7FXVCVoMMVpZf7kdbso1qBTqjviYcH9ccshT1qLLbXl8 g/Re2rk1iN0sW3ZJrGl/nq8sDbmNEznDAZsXMypInYPERDcLLGtHMZhizsbKTPOk57Xb EUDg== X-Gm-Message-State: AOAM5308IikfYdrYZwYS3GVYEaVWguQLR4EwpDiEEcxQJKzTxDdij2hV tmf66XTUqNXsGzBTz37pHdL5g+2zqPhKtA== X-Google-Smtp-Source: ABdhPJwqqgWXBMBjKC2so7LRuNvCqJJ0b2Bs1M6IT9oO/a1IYOKUzk+62hXPjDmsQZF/0RLRHJ21UQ== X-Received: by 2002:a1c:e4d4:: with SMTP id b203mr1162053wmh.141.1606269259832; Tue, 24 Nov 2020 17:54:19 -0800 (PST) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id a9sm1416047wrp.21.2020.11.24.17.54.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Nov 2020 17:54:18 -0800 (PST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:125547 Archived-At: On 24.11.2020 05:54, excalamus--- via Users list for the GNU Emacs text editor wrote: > > 23 nov. 2020 à 17:19 de dgutov@yandex.ru: > >> On 23.11.2020 18:22, excalamus--- via Users list for the GNU Emacs text editor wrote: >> >>> >>> 21 nov. 2020 à 21:55 de dgutov@yandex.ru: >>> >>>>  For instance, if you are working on a Python project, shouldn't there be some file in the project root directory which will indicate which virtualenv to use? >>>> >>> Maybe? I've never heard of such a file being used with the venv module or conda environments. >>> >> >> OK, I'm not well-versed in Python ecosystem >> > I sadly am (it's my day job). "Should" is a dangerous assumption for Python. As far as I'm aware there's no unit of project nor standard way to indicate which environment to use or what packages are in that environment. Some people put a bajillion packages into a giant catch all environment to "reduce duplication", others have a 1:1 project to virtual environment relationship. > In practice, a project and virtual environment are separate, although each are determined by a directory (maybe the virtual environment is a subdirectory of the project directory; maybe virtual environments are all co-located in a separate envs/ directory). The user has to remember which virtual environment to activate and where that environment is located. pyenv seems to be one such standard. Though of course it might not be adopted by the projects you use (especially if they are collaborative, and you don't make that decision). > The virtual environment is activated by running some script which sets environment variables for the current shell instance. >> I think the general idea could be implemented in Emacs Lisp: you call (project-root (project-current)) and see if there is a file with a predetermined name inside that root. That file could point to a specific virtualenv which you would then switch to. >> > I could create my own project indicator file, I suppose.  I'm not sure how that would help.  But I'm getting (myself) lost. I may be stuck in my own pattern of solving things. What problem are we trying to solve here? > > My project workflow is: > 1. Create a shell2. Activate a virtual environment > 3. Assign some commonly used commands based on the project (e.g. run this entry point, build according to this spec, etc.) > The trouble is managing several of these simultaneously (e.g. "Hey can you quickly fix this thing in this other project?") while maintaining the state of each. You asked how to maintain a number of "profiles" corresponding to projects, each containing a venv, entry point, and so on. My response is that in my preferred paradigm most or all of that information is inferred from the files that reside in the project's root directory. So to get some of that info you first find the project root, and then read that info from disk. You can subsequently cache it, of course. But if there is no existing standard for most of those things in your projects, you might as well write some registry in Lisp, in your init script, that would map, say, project roots to such profiles. The benefit of having those auto-determined is that you could always have them up-to-date and correspond to the current file you have opened in Emacs (the current buffer). And when you switch to another project, with project-switch-project or even the plain find-file, your profile-finding logic would use the correct profile automatically, without you having to recall which profile corresponds to which project. But that's how I prefer to approach this kind of problem. You might choose to do it differently.