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, 2 Dec 2022 17:37:17 +0200 Message-ID: <00845da6-345e-d598-8215-568c7b452207@yandex.ru> References: <87zgcq68zp.fsf@ericabrahamsen.net> <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> <83o7swyipe.fsf@gnu.org> <83sfi7v6dj.fsf@gnu.org> <45549e6b-942f-ee99-9123-8176545a159e@yandex.ru> <83zgceu8ch.fsf@gnu.org> <7c34024e-c2b6-033f-ff37-a0fdfc9f0cdb@yandex.ru> <83v8n2tbur.fsf@gnu.org> <83cz91gaaw.fsf@gnu.org> <0094a6f2-796e-bc8d-bee0-13ecb069d7e6@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9559"; 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: monnier@iro.umontreal.ca, danny@dfreeman.email, eric@ericabrahamsen.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 02 16:38: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 1p187P-0002JZ-3z for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Dec 2022 16:38:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p186a-0000cm-Ma; Fri, 02 Dec 2022 10:37:36 -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 1p186Y-0000cS-Fl for emacs-devel@gnu.org; Fri, 02 Dec 2022 10:37:34 -0500 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p186W-0004sR-Gt; Fri, 02 Dec 2022 10:37:34 -0500 Original-Received: by mail-wm1-x32f.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso4578765wmo.1; Fri, 02 Dec 2022 07:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=v+u6Lo+IGXRMwqafTCmdvgewufBJ6zkvzu3qCozDs5g=; b=FC0jF/aQVNg41noveM7WKHGHNZxS9CkXXfAVbszFuJ6b46lPSWqcg2xwnhzYtwjU9J +vWoAvrH2ozAVBnodkfWygaasgJfCgBY41uYJYtTWRsuW5oe3faXEqhcm8ujoWOokFBE qTAZWxIiZZD7y/yu43vjWNwNeBdq/89Aj+En4ghlXU7FuxGhPiTD91VTUQ7NPW84/fh5 D7FLLkiNPrMTbK1++G3xIvUm1yPLoLXX9jRJwz5SXRdYF515l694Rc3biVwOass0yb3W ccGz+wsBH2/24/pQMg/1/wvngzKuiQOOxvisMZg2ll/H4ZuRHGiXEpMln+mrNxbhyzaz cqDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :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=v+u6Lo+IGXRMwqafTCmdvgewufBJ6zkvzu3qCozDs5g=; b=6pqdX8vlMapWVdgDPhxu4ktHqEZjqfsH/90isjowjcA0p6Hy8jzT5ph8pCLkd8MlbE 0RqScM2eKZfzt5fqU3wqCNjjPFoaXd0QOjdjWHhtwHZ671GNdkUx4u47WCnhFA6M/94j 37yjxL9wV5ylkF94Bs4GviWhWgVmn2wQ1JNVzs7Fbv/WRlMV20DxjirojXlBKrMe0TED GzfAOU7Wynn9xtnSF01/tZPz0mUnX3ISNrTHJ0AB7GiCoJX1vNnIiGY7fHdl2Am8EMi+ MXmxiis0VImkWcvnKRKvrnfpoIku96qCY3F5V9ObC1hChB8eslpxazqNo8wyizo4UDgn nNKA== X-Gm-Message-State: ANoB5pmHRhXZkvG3Pr0ZfDHjrOYl97u1lGo+aLqR6bm3qq4t4DyGP1Tj Nr3Kpa84/4zR8mFQ6Nb62zLnrYCw2HE= X-Google-Smtp-Source: AA0mqf6HRhF9mzU1tBV8RcOjsHUO2jTHGIBXadb8ABR5MhVltjHsqIQycMFeCs1ho0M1wVcJ/zatRQ== X-Received: by 2002:a05:600c:3d98:b0:3cf:e9a4:325f with SMTP id bi24-20020a05600c3d9800b003cfe9a4325fmr51622732wmb.98.1669995439645; Fri, 02 Dec 2022 07:37:19 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n3-20020a05600c3b8300b003cfbbd54178sm15108507wms.2.2022.12.02.07.37.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 02 Dec 2022 07:37:19 -0800 (PST) Content-Language: en-US In-Reply-To: <0094a6f2-796e-bc8d-bee0-13ecb069d7e6@yandex.ru> 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: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.258, RCVD_IN_DNSWL_NONE=-0.0001, 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.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:300837 Archived-At: On 02/12/2022 17:08, Dmitry Gutov wrote: > project.el strives very hard to be generic, but what > is the use in doing that if extending it by 3rd-party code is so > complicated, and on top of that is not already available? Speaking of "extending is complicated", I have shown the two-line definition of 'transient', right? A custom type can look just as short (or not; depending on its needs). So it's more of a matter of understanding how the pieces fit. For instance, using the new type will require plugging it into project-find-functions. And for the VC-aware type, its element is one of the more complex pieces of its implementation. Which makes sense: that's where domain complexity lies. So how one would be able to reuse both it and the existing logic? Here's an example of overriding the 'project-name' with a new type without requiring a public constructor for the VC-aware type: (defun project-try-my-type (dir) (let ((vc-instance (project-try-vc dir)))) (cons 'my-type vc-instance)) (cl-defmethod project-root ((project (head my-type))) (project-root (cdr project))) (cl-defmethod project-external-roots ((project (head my-type))) (project-external-roots (cdr project))) (cl-defmethod project-files ((project (head my-type)) &optional dirs) (project-files (cdr project) dirs)) (cl-defmethod project-ignores ((project (head my-type)) dir) (project-ignores (cdr project) dir)) (cl-defmethod project-buffers ((project (head my-type))) (project-buffers (cdr project))) (cl-defmethod project-name ((project (head my-type))) ;; Do something different here ) I suppose it does look a little verbose... A defclass or defstruct would allow to declare automatic inheritance between types. I wonder if there are any other options that don't imply structural inheritance, or if we can simply say "inheriting is fine, but please don't rely on the fields staying the same".