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: Tue, 29 Nov 2022 21:07:34 +0200 Message-ID: <09e92342-edfa-ebdb-f6ee-09154c7feeac@yandex.ru> References: <87zgcq68zp.fsf@ericabrahamsen.net> <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> <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> 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="21033"; 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 Tue Nov 29 20:08:36 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 1p05y7-0005DN-UL for ged-emacs-devel@m.gmane-mx.org; Tue, 29 Nov 2022 20:08:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p05xH-00044d-Sc; Tue, 29 Nov 2022 14:07:43 -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 1p05xF-00044G-Kw for emacs-devel@gnu.org; Tue, 29 Nov 2022 14:07:41 -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 1p05xC-00082H-RT for emacs-devel@gnu.org; Tue, 29 Nov 2022 14:07:41 -0500 Original-Received: by mail-wm1-x334.google.com with SMTP id o30so11675180wms.2 for ; Tue, 29 Nov 2022 11:07:38 -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=cBzdWBS1UWk6GHbpSgQGscmZRrEIizTYdYO/x6EJzI0=; b=VFH6nIEjW1t8p0a7mPq2IAMXn4qxWRJKoooPw5Z9cZm6f9d6hUuV7icsntYsAXHEYm OFbTf/Cdx1njSCc/iHXTRCPCIhP63+PmD02+CXbSAcAP1zc5PxC66nlcxkNT1MOZGSYS x0lSSIDy1TY+a/h2TL7bRCq2bREn7VJX0m++zOp7v8kp7R5DaywPbcPfaf/BxGwhwdoY v+OFE+9+G3ER8Xu2/eQJvCLotqze3uT/x4aNUmxDGPR/fKRreNjaxr6lzKcnCcXqLT9r hYXRP9dFueSVE350QB/aagwSKI+rNHUKtG2XWr3X+i2OjZ6+CUbxmu6r0R+r9cF4s98t Iw1A== 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=cBzdWBS1UWk6GHbpSgQGscmZRrEIizTYdYO/x6EJzI0=; b=J/fVVHCZutMlVA2lzGIrmU+z1afHy2CMrrU1Kky6HtHcfU+vbqJyT8b/+3eQrZ51wO ZgCfWBCgv3lQTTYBuF/En9yBaxj3joCc0ZIiuOidBoOK6whQLIDBk0oDGQoQNpzTxwFC dnprNEqskj9idVqsizcpMEgDJjEUReJLVd+U+zkKygKMSEfX0L2c1rMxmUCCnHpGwXDm R1jNxX59yOBQSdqly7WuW1mRraSm2xpx2x7HKAjeTF9IbT3q7oDAxTusAS6BzyvjI+8N DwQPaYbbAWm7w0FKG2pHN4B5heMCuZ8CrdKfc3qaDioBHB9flNVHBsfBmDb50fXhIKSC EWaA== X-Gm-Message-State: ANoB5pmW9i/ur68EqO+YaZCmho3kAnhxj9LvWsIagj1Rps6TXNDEvOGK lkd3jdy1njU96+lDJfwQNkE= X-Google-Smtp-Source: AA0mqf4n1QcxRy7YgdBWEYahEoun5e6b+6jimP2PQJFH8n6xVNMmom3Unpu2t7uUV9GC3VOq/Ae35w== X-Received: by 2002:a05:600c:1d9c:b0:3c6:bf1e:ebb9 with SMTP id p28-20020a05600c1d9c00b003c6bf1eebb9mr45155818wms.173.1669748857224; Tue, 29 Nov 2022 11:07:37 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id co29-20020a0560000a1d00b00236e834f050sm14866992wrb.35.2022.11.29.11.07.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Nov 2022 11:07:36 -0800 (PST) Content-Language: en-US In-Reply-To: <87r0xmqd2g.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:300722 Archived-At: On 29/11/2022 12:17, João Távora wrote: > Sorry I hit "send" before I wanted to. This line of course be > > (interactive (list (project-current t))) > > And the docstring should be > > "Run `compile' in PROJECT's root." > > 'project-current', when called with MAYBE-PROMPT, is running in an > interactive setting. It could then consult the value of the prefix > argument and decide to prompt the user about which project to use > (including super-projects). > > You can use this technique to a add PROJECT argument to all the other > relevant project-* operations without breaking backward compatibility, > even for non-interactive Lisp uses. What do you mean, without breaking compatibility? Adding a new required argument means it will break any Lisp code that calls this function. At least that's how I understand our standard criteria for this thing. 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. That will actually require *fewer* changes, as you might have noticed now. > In cases where a "P" prefix argument is already in use, like C-x p f, > we'd have to repurpose the "negative prefix" part to_not_ mean > INCLUDE-ALL. You'd affect only the people who are currently using M-- > C-x p f instead of C-u C-x p f. This hints that the choice of whether to use the parent or not should be made inside the command implementation. Perhaps inside the 'interactive' form, but not inside 'project-current'. The principle of separation of concerns suggests the same. Something like: 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)))