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 Date: Tue, 29 Nov 2022 22:52:22 +0000 Message-ID: <87edtlqspl.fsf@gmail.com> References: <87zgcq68zp.fsf@ericabrahamsen.net> <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> <33292672-2a59-ba63-05ab-a7995118a822@yandex.ru> <87pmdau6wo.fsf@gmail.com> <87zgcesg8l.fsf@gmail.com> <79a17a5c-d1c1-ce69-d29a-9127150fb1d7@yandex.ru> <87edtqrr0b.fsf@gmail.com> <0323877a-2198-c295-61c1-5fcb1813f409@yandex.ru> <87r0xmqd2g.fsf@gmail.com> <09e92342-edfa-ebdb-f6ee-09154c7feeac@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39169"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , Danny Freeman , Eric Abrahamsen , emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 29 23:51:50 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 1p09SA-000A1r-8j for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Nov 2022 23:51:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p09RX-0003gA-FO; Tue, 29 Nov 2022 17:51:11 -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 1p09RV-0003fr-DY for emacs-devel@gnu.org; Tue, 29 Nov 2022 17:51:09 -0500 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p09RT-00014r-JS for emacs-devel@gnu.org; Tue, 29 Nov 2022 17:51:09 -0500 Original-Received: by mail-wr1-x42e.google.com with SMTP id f18so2349654wrj.5 for ; Tue, 29 Nov 2022 14:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7jhoO3R9TdUOrI83c0NFJVpgnsCaV+GHPzZiteUYkcA=; b=PdBtId9WVcY1a1/vJiDuQNvjcplWcKV3leAC0neoF0mwyobwHbWuSJiLm053PhiXhD hU3KrCouA7PFlKyXC43CMYKY3ryWw/Yw0TUUONXeGh+8kMWzmaLuDCKTu5SnI25dvLS2 zHAeQ92y+OXWJob0znttKvlz9Tp6sc3+8DidgPuOdYnzCdmZIfHzvIDYhrAXjMVJ8H5X ewFLLCxdPCJ02aXvQ20hAZs3fNN5sQUCdXLd5BUf604bwY1WWyqfy1jVFstCN9IcK2pN u9RgfO96igXFSvouNY/00t8GwwxcQ1JVos1SVR9l+mAnc+ZDwQ3cMLE6iQMcBLO5h+Rz PZGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7jhoO3R9TdUOrI83c0NFJVpgnsCaV+GHPzZiteUYkcA=; b=YKiSr4yACYraPygkmIltxEjScx0PsEFVQzIz22yWeiHsd0U5zJCSF082oXZoHyCPW8 BNCrnK4SbrG/Z7+5P3FNuUxR4AxhucNexPa3RsXDyRBcpfoNRo7b3uErVZwVD2UwKhAg GtkuqALA8+iQ32tVylLfqmXeaC/iP1oq9B/ZaT3yGO3P7CY3FhPkhH7jXTwwubI2v3be N8lqw5ILvYZKw1mxnHJHYAK0nT7LblMLz8tVUaXJuNFQBXTTbSiITA5a4z4/yfKdOI/6 Y/tYaAp6+KOg5xcJ3X4bJR5M45tOILXK5MRoxHSnU1y8VT/Ws68aiN1XSUPqNzK7vjFz X4iQ== X-Gm-Message-State: ANoB5pmW8boR2JJqaFK10mId2s32Cl/gXX+dnLbDrIuEq1t7LhJfT71h MVsZZPl06E+t1Cp3DrlEDBxuJ6PRFCw= X-Google-Smtp-Source: AA0mqf4j+HFzkyFg5eQgSt2c86nwiDeBuONdcCgpueg8ixAJMvM8TfF0erAmwzz4edMEZU03NJCpnw== X-Received: by 2002:adf:fb44:0:b0:236:87f4:75d with SMTP id c4-20020adffb44000000b0023687f4075dmr34501433wrs.447.1669762265941; Tue, 29 Nov 2022 14:51:05 -0800 (PST) Original-Received: from krug (87-196-72-71.net.novis.pt. [87.196.72.71]) by smtp.gmail.com with ESMTPSA id x10-20020a5d60ca000000b0024216d2e386sm6898903wrt.16.2022.11.29.14.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 14:51:05 -0800 (PST) In-Reply-To: <09e92342-edfa-ebdb-f6ee-09154c7feeac@yandex.ru> (Dmitry Gutov's message of "Tue, 29 Nov 2022 21:07:34 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=joaotavora@gmail.com; helo=mail-wr1-x42e.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, 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:300732 Archived-At: Dmitry Gutov writes: > What do you mean, without breaking compatibility? Adding a new > required argument means it will break any Lisp code that calls this > function. The example I gave you was for a function explicitly marked "interactive only", so it's not a problem. In fact all these functions should be "interactive only". But in other cases, make that argument optional. > And it's probably not that big a deal if we had no other choice, but > we do. Update the commands to call a different new function.=20 As I explain below, you'll be littering the code with non-idiomatic Elisp.=20=20 > That will actually require *fewer* changes, as you might have noticed > now. Not sure about that. > diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el > index c1245704bcc..9e5fcfe0b06 100644 > --- a/lisp/progmodes/project.el > +++ b/lisp/progmodes/project.el > @@ -1139,6 +1139,19 @@ project-prefixed-buffer-name > (downcase mode) > "*")) > > +(defun project-parent (project) > + (project-current nil (file-name-as-directory > + (file-name-directory > + (directory-file-name (project-root project)))))) > + > +(defun project-current-or-parent (lookup-parent) > + (let ((project (project-current t))) > + (when lookup-parent > + (setq project (project-parent project))) > + (unless project > + (user-error "No parent project")) > + project)) > + > (defcustom project-compilation-buffer-name-function nil > "Function to compute the name of a project compilation buffer. > If non-nil, it overrides `compilation-buffer-name-function' for > @@ -1155,7 +1168,8 @@ project-compile > "Run `compile' in the project root." > (declare (interactive-only compile)) > (interactive) > - (let ((default-directory (project-root (project-current t))) > + (let ((default-directory (project-root (project-current-or-parent > + (eq current-prefix-arg '-)))) > (compilation-buffer-name-function > (or project-compilation-buffer-name-function > compilation-buffer-name-function))) Sounds more complicated that it needs to be, and no reason why project-current-or-parent shouldn't be just project-current, with another optional argument at most. Anyway my idea to add PROJECT is nothing exotic: it's the standard idiomatic Elisp solution used in such basic functionality as M-x display-buffer, find-file, etc. There's no reason to stray from that. Jo=C3=A3o