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 Date: Wed, 30 Nov 2022 03:10:44 +0200 Message-ID: <5de1180e-815a-c75c-6593-1e9ef087582a@yandex.ru> 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> <87edtlqspl.fsf@gmail.com> 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="8914"; 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 Wed Nov 30 02:11:31 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 1p0BdL-00027g-28 for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Nov 2022 02:11:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0Bci-0004Yu-Ba; Tue, 29 Nov 2022 20:10:52 -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 1p0Bcg-0004Yk-92 for emacs-devel@gnu.org; Tue, 29 Nov 2022 20:10:50 -0500 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0Bce-0006Xq-8C for emacs-devel@gnu.org; Tue, 29 Nov 2022 20:10:50 -0500 Original-Received: by mail-wm1-x334.google.com with SMTP id 5so12179782wmo.1 for ; Tue, 29 Nov 2022 17:10:47 -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=G9PmMXKfzFy5ZnH/84gsVBLwyAzAKd3YREG2TcVRCjg=; b=NZK5XH5wol4mL47pxpRGxqxdjYmzsSO77M4Ty/UbHc8OxaMPaN30HjAx9mlO2CJQvI nk8uX0uc0nvGYzwTU7EumJ9XQvfuU63EjOQLTG0Ey1eSmFinjqVbrPcWdAT4f1SWwivO R73B9vp+Cxoiks66gs1uirHxSRqSjN0DeY8O1E1SSyVZnPA4sRlUUeFrNSbJAtwJ0wYL 7yHsu+Ss3S88EYoMIo9y/JpcBAsw5b2tOMhqyWZ4DAABKtJqeka7HayPHfWZ8QbzUAVx Rn6WO21sxHfUEr/14nbv17yhT7q+EQSvsaaFUpXlbEs+qTIS4RiWovitUo/zLUuAOXGc B91g== 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=G9PmMXKfzFy5ZnH/84gsVBLwyAzAKd3YREG2TcVRCjg=; b=3uats+VbDn4OCdLs1o1GsUbqrns+2dUTjP0uCMf5hZjOLU45dQ44Js8o6NzLhb0dF9 WnPgRRp7VWmE7rGPlTrSpZv+egD231/znGNoX6ZKeJcM1ngZhOZ2yGkKw30VuMmhEBa0 Auc4r8TNb627GBGIpVnCklH3jtRxmV9xxMT8K8ox6fvcdD3URY8PwP2Uxv7dF2Peh32e 7gMlQg9lxpl4BEVCKn8VTZJ8coxKoh/dqt8uJxHFTIrTjSV3O/H45xjy/tjQQ5CgSL3u cGIqtoig3TdUVi+VMRBJSE1ORKRQ5P3rwDEh0K8AZ7EDsODyc1VtcC7wzjCqXloNsS5O I1/g== X-Gm-Message-State: ANoB5pkdBlzfrwJop7TYYVB8Dw/CJtKWhiREystucqSJXaoAfqaV8D3w VScOcxsCc9/nXH3ovKgun1o= X-Google-Smtp-Source: AA0mqf7KJwOsD38wXsKLeMgqxi1U/OL4jwZN88TwOGJXn5jXn8SEBldvqAT43yPko9B5EJGsYX/qXw== X-Received: by 2002:a05:600c:3583:b0:3b4:6c36:3f59 with SMTP id p3-20020a05600c358300b003b46c363f59mr33242705wmq.100.1669770646379; Tue, 29 Nov 2022 17:10:46 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id s6-20020a5d4ec6000000b0023662245d3csm14771821wrv.95.2022.11.29.17.10.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Nov 2022 17:10:45 -0800 (PST) Content-Language: en-US In-Reply-To: <87edtlqspl.fsf@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=raaahh@gmail.com; helo=mail-wm1-x334.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.249, 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:300741 Archived-At: On 30/11/2022 00:52, João Távora wrote: > 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. The commands that are marked 'interactive-only' are those that we have decided are useless in Lisp programs. Others aren't marked such. >> +(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. If it's a new optional argument vs new function, I can see the benefits of either. OT1H, project-current is shorter. OT2H, some code (or even a person) might like to check (fboundp 'project-current-or-parent). Anyway, I'm not crazy about the name of the argument (lookup-parent), so suggestions are welcome on that.