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.devel Subject: Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Date: Fri, 25 Nov 2022 00:17:54 +0200 Message-ID: <50bf9e49-23f0-0966-f619-88bcf35479fa@yandex.ru> References: <87zgcq68zp.fsf@ericabrahamsen.net> <84781346-5b88-2be5-38bb-02696fcf1364@yandex.ru> <87o7t2vj19.fsf@dfreeman.email> <877czqtyfy.fsf@dfreeman.email> <87zgcml7g7.fsf@gmail.com> <2ba04533-097a-a1da-ff3f-2c9506fd488e@yandex.ru> <875yf9bbzb.fsf@gmail.com> <87wn7oa0aw.fsf@gmail.com> <7a5b76fd-fb15-8c1e-ea29-bf11f7e0d2ae@yandex.ru> <87bkoya815.fsf@gmail.com> <0024a67d-b8e5-b35c-1b22-82541a170eb3@yandex.ru> <871qptai4d.fsf_-_@gmail.com> <71addecc-373e-b1f0-f190-0ce3531626a8@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="15302"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: Stefan Monnier , Danny Freeman , Eric Abrahamsen , emacs-devel To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 24 23:18:27 2022 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 1oyKY6-0003ii-2A for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Nov 2022 23:18:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyKXk-0004dP-Ap; Thu, 24 Nov 2022 17:18:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyKXi-0004d8-Dl for emacs-devel@gnu.org; Thu, 24 Nov 2022 17:18:02 -0500 Original-Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oyKXe-0002Wi-CF for emacs-devel@gnu.org; Thu, 24 Nov 2022 17:18:00 -0500 Original-Received: by mail-wm1-x32e.google.com with SMTP id 83-20020a1c0256000000b003d03017c6efso4173164wmc.4 for ; Thu, 24 Nov 2022 14:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=yUqbESfGxErpRCbwqyZAT094XR1M0bzOsT83Px6cdPc=; b=PJLmNz0If1X+/7CBtYupEG0Sz6e5xLSwmGpYx1qzjg44sGwRnAEmyH41Pilbf1GqJ/ k2bdMFvluB830XeW9mwcR6mf/32LE65B7GBttZlLauuEq1Gzje1MgqD+Qh+3/X6IzcTg XEWf9a5SRN68JKdFZZX6mC0EPsC2tS9nSNGx4FfZDJjH1Ox4E0WZLXwDocI3AzV0IMvv gaRFvGBeINKn/W871G66SYavw9rNBNnitb484omjqAjP2145ENaTvkZH7Ssfry+f22Br iupywHJ/m4TTkJr12X+076iNa0dNn751mWdZU1KojlDmTwHYk+IJPAP3nx0Lh9ob22zV s1lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yUqbESfGxErpRCbwqyZAT094XR1M0bzOsT83Px6cdPc=; b=UhvwI3O/9Mw92bqHL3wPNhYQ0lYDqmwewSyyrGrangnBEcow0tDxB0Y04LRA4VxYRa CvhyLfVBYevFpjvPOKFY+Gs9JKCF2eqy66qH/ck+2KI6lOkkdmm4NHc0rhWBx38d3DHw 7n/KLmq88mLUr5aJ5JcLF3qIdsmVCshjsMa/Y9c9lIN5RF43cSP6t8LvNkQEj6xmh6Dm ZS1Q+2FwLD9Rtbg+UIOMybf/ah0e3odKv5htF7Yg42AzQxGuNdYrl3PqS7nk8gk86hnO 21uKnoGByrbB1FY+3T0R0DXGEIbgYZK0NnncNSuXyrf268ZMDd3KtkA2yR7hymqFu3J2 v0aA== X-Gm-Message-State: ANoB5pnqZ5WXZisbxVIClIjuBgYmYkshRyzfmmzIuTu6PdV6bro4/QfO nzqdd6KN+d7QOyfOLBmySLo= X-Google-Smtp-Source: AA0mqf5997plCPddnvyrKYMqdCjAu0AgJqNbMvTGISnOL3G3qRgKarrpkmlXn8Bo0oe2WiKIfDMslw== X-Received: by 2002:a05:600c:688:b0:3cf:a18d:39a4 with SMTP id a8-20020a05600c068800b003cfa18d39a4mr24530701wmn.125.1669328276861; Thu, 24 Nov 2022 14:17:56 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id q10-20020a05600c46ca00b003c6bd91caa5sm3351328wmo.17.2022.11.24.14.17.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Nov 2022 14:17:56 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32e.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.209, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300449 Archived-At: On 24/11/22 10:42, João Távora wrote: > On Thu, Nov 24, 2022 at 2:49 AM Dmitry Gutov > wrote: > > On 23/11/22 22:33, João Távora wrote: > > For my idea to work, project-current would have to be changed to > > > > 1. Call all members of project-find-functions: return the innermost > >     project found thus far. > > 2. Not call project-find-functions recursively when called from > within a > > function > >     in project-find-functions, just return the innermost project > found > >     thus far. > > > > I don't see any big performance problems in this alternative. > > Might not be much of a difference in a simple configuration, but going > up and down dirs is not free even on a fast SSD, especially as the > number of the elements on this hook grows. > > But where you will definitely see a difference, is when using this with > Tramp. > > > Have you seen the code I posted? You'll notice that it doesn't do > any file system operations, it just does file name operations. And > those run in CPU/memory, not file system. So I cannot understand > your argument.  But I am happy to measure performance in different > scenarios, if you'd like to suggest a particularly problematic one. I am commenting here on the idea to "Call all members of project-find-functions". Members of project-find-functions do file system operations. And that's what your piece of code does (call all members): +(defvar project--overriding-projects nil) + (defun project--find-in-directory (dir) - (run-hook-with-args-until-success 'project-find-functions dir)) + "Find projects that directory DIR belongs to. +Return them as a list. If more than one is found, the first is +usually the innermost." + (or project--overriding-projects + (let (projects) + (run-hook-wrapped + 'project-find-functions + (lambda (fn) + (let* ((project--overriding-projects projects) + (prj (funcall fn dir))) + (when prj (push prj projects))) + nil)) + projects)))