From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments) Date: Thu, 24 Nov 2022 09:01:36 +0000 Message-ID: References: <87zgcq68zp.fsf@ericabrahamsen.net> <878rkale3l.fsf@dfreeman.email> <4c5f4b07-3df6-d700-83f8-9a9d1b684afc@yandex.ru> <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> <83o7swyipe.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001efd6505ee33a35b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32448"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dgutov@yandex.ru, 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 Thu Nov 24 10:01:48 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 1oy87A-0008Ad-3H for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Nov 2022 10:01:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oy869-0004rr-Ln; Thu, 24 Nov 2022 04:00:45 -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 1oy860-0004pt-FB for emacs-devel@gnu.org; Thu, 24 Nov 2022 04:00:37 -0500 Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0: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 1oy85w-0007eq-TA; Thu, 24 Nov 2022 04:00:35 -0500 Original-Received: by mail-ot1-x32f.google.com with SMTP id a13-20020a9d6e8d000000b00668d65fc44fso561516otr.9; Thu, 24 Nov 2022 01:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=I9OvmuEkhgJJbbizwgI+P4LIpb3MTYgMW1QYpnFdprQ=; b=X13I5r07PAxLtCHFEYz2rmook8quWvVDQdAqqx9/WCtgkv7lfocTTNbTpL0eim6bfZ oqxRF9VILPlkRD7H2RAIsK3bFTHxTe1CUDxEBqHKovx78Bh2HQRes7PJtH6Xh9maTurY wKhuAmcezN+ShzEHQrNEDBfQbfTCkcc7cIhbLsEJU3bU0qgUR5I3hk0atm7/FKWtjwpt n5kNAE002qB+CkUn/Exf3KxiF31O8Ax4Uo16nOkU18ZYeiY6fFTMkCzuKV9kyED9WZj4 O+riMBbhE7vIlA/GzpuTgAoGlTR0Bb4gNLym25G5Ninb31kX5NQ6BXVOC/4aFizjGkYM WQFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I9OvmuEkhgJJbbizwgI+P4LIpb3MTYgMW1QYpnFdprQ=; b=G70GJnmZfLN9ouUpfldV0v5V2H2lvXNjxC0WxDsP1O+/VgVcEDzKowQ2TKAD5SKZNk qLg01Qzza59bNrCRvWg21f+5jE1H2oDLq4NgMhUNS+BgKlNpZN4sa3rncIUDoZYyY6ye ARti0LHvZDyRvHAgSWNvwqLzIoaJ3L2g1xfQqqt3W6slVeU9S5vGz6hIjFl1v9o6LeNU G+INAPWYfZP2wxlL4C4m/ZWWSmQPgj8b+otFm0wuQWA1OfsB17w28h2/jBBlPLaB/xW2 mIICRf77vZtOrh8EVjBrTXAJqZxWa9IzYWP+kxPM5UI8BCIge4XDPq4cyWd/3imFx1WL qsbA== X-Gm-Message-State: ANoB5pkzq01pd2fOLuX7eK4n6daYpcXRZUgFiaIUkrwHMPy0NQnbIdRP 3M9DYa++9C0+rhVUbfI2xgSZ8oyfj+O5vnDB0XyeZLDljWHh3g== X-Google-Smtp-Source: AA0mqf55Wx10fANljYEyodb/3lbmwlmiDn0G7L9Au8bvBHd5atoJbr130mYaqFXIBZCUAXEKlRz701grNntn6qfAxNg= X-Received: by 2002:a9d:4f07:0:b0:66c:64d6:1bb4 with SMTP id d7-20020a9d4f07000000b0066c64d61bb4mr16283368otl.201.1669280431011; Thu, 24 Nov 2022 01:00:31 -0800 (PST) In-Reply-To: <83o7swyipe.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::32f; envelope-from=joaotavora@gmail.com; helo=mail-ot1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, 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:300434 Archived-At: --0000000000001efd6505ee33a35b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Nov 24, 2022 at 6:22 AM Eli Zaretskii wrote: > > From: Jo=C3=A3o T=C3=A1vora > > Date: Wed, 23 Nov 2022 20:33:04 +0000 > > Cc: Stefan Monnier , > > Danny Freeman , > > Eric Abrahamsen , emacs-devel < > emacs-devel@gnu.org> > > > > (defun joaot/sub-projects (dir) > > (let* ((super (project-current)) > > (super-root (project-root super)) > > (relative (file-relative-name dir super-root)) > > (d (car (split-string relative "/")))) > > (when (member d '("lisp" "src")) > > (cons 'transient (expand-file-name (concat d "/") super-root)))= )) > > Is this okay for code outside project.el to know the internal structure o= f > a > project object in general, and in particular cons "by hand" a 'transient' > project object? I thought this was a closely-guarded implementation deta= il > that even doc strings are not allowed to divulge? > I don't think it's okay, no. But I don't think project.el offers constructors for project objects (if it does, then I am happy to use them), so I used this (cons 'transient...) as a placeholder and a demonstration. Another very similar way to go about this would be for joaot/sub-projects to be named project-sub-products and live in project.el, where it would be free to access its own internals. (defvar project-sub-project-prefixes nil "List of strings designating sub-projects. This variable should be set directory-locally.") (defun project-sub-projects (dir) (let* ((super (project-current)) (super-root (project-root super)) (relative (file-relative-name dir super-root)) (d (car (split-string relative "/")))) (cl-loop for prefix in project-sub-project-prefixes when (string-prefix-p prefix relative) return (cons 'transient (expand-file-name prefix super-root))))) Then it would be a question of setting project-sub-project-prefixes to, say, '("lisp/progmodes" "test" "doc" "src") in Emacs's .dir-locals (or using dir-locals-set-class-variables as an alternative). Jo=C3=A3o --0000000000001efd6505ee33a35b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Nov 24, 2022 at 6:22 AM Eli = Zaretskii <eliz@gnu.org> wrote:
> From: Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com>
> Date: Wed, 23 Nov 2022 20:33:04 +0000
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>=C2=A0 Danny Freeman <danny@dfreeman.email>,
>=C2=A0 Eric Abrahamsen <eric@ericabrahamsen.net>, emacs-devel <emacs-devel@gnu.org&g= t;
>
>=C2=A0 =C2=A0(defun joaot/sub-projects (dir)
>=C2=A0 =C2=A0 =C2=A0(let* ((super (project-current))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (super-root (project-root sup= er))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (relative (file-relative-name= dir super-root))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (d (car (split-string relativ= e "/"))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (member d '("lisp" "= ;src"))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cons 'transient (expand-file-nam= e (concat d "/") super-root)))))

Is this okay for code outside project.el to know the internal structure of = a
project object in general, and in particular cons "by hand" a = 9;transient'
project object?=C2=A0 I thought this was a closely-guarded implementation d= etail
that even doc strings are not allowed to divulge?

=
I don't think it's okay, no.=C2=A0 But I don't think= project.el offers constructors
for project objects (if it does, = then I am happy to use them), so I used
this (cons 'transient= ...) as a placeholder and a demonstration.

Another= very similar way to go about this would be for joaot/sub-projects
to be named project-sub-products and live in project.el, where it would
be free to access its own internals.

(defvar project-sub-project-prefixes nil
=C2=A0 "List of strings d= esignating sub-projects.
This variable should be set directory-locally.&= quot;)

(defun project-sub-projects (dir)
=C2=A0 (let* ((super (pr= oject-current))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(super-root (project-r= oot super))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(relative (file-relative-n= ame dir super-root))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(d (car (split-st= ring relative "/"))))
=C2=A0 =C2=A0 (cl-loop for prefix in pro= ject-sub-project-prefixes
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0when (string-prefix-p prefix relative)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0return (cons 'transient (expand-file-name prefix su= per-root)))))

Then it would be a question of setti= ng project-sub-project-prefixes
to, say, '("lisp/progmod= es" "test" "doc" "src") in Emacs's .= dir-locals
(or using dir-locals-set-class-variables as an alterna= tive).

Jo=C3=A3o
--0000000000001efd6505ee33a35b--