From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65386: [PATCH] ; Refine some 'package-vc' docstrings Date: Mon, 21 Aug 2023 10:16:59 +0200 Message-ID: References: <7a0f6dcb-3e56-8009-3f54-bb7b9fb6fce3@gmail.com> <87pm3hsb8t.fsf@posteo.net> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25720"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Mauro Aranda , 65386@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 21 10:18:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qY07G-0006Uv-M6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Aug 2023 10:18:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qY06t-0001tM-9V; Mon, 21 Aug 2023 04:18:03 -0400 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 1qY06r-0001pK-Cb for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 04:18:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qY06p-00074k-Pn for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 04:18:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qY06r-0005M5-RY for bug-gnu-emacs@gnu.org; Mon, 21 Aug 2023 04:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Aug 2023 08:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65386-submit@debbugs.gnu.org id=B65386.169260583020523 (code B ref 65386); Mon, 21 Aug 2023 08:18:01 +0000 Original-Received: (at 65386) by debbugs.gnu.org; 21 Aug 2023 08:17:10 +0000 Original-Received: from localhost ([127.0.0.1]:55489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY061-0005Kx-FP for submit@debbugs.gnu.org; Mon, 21 Aug 2023 04:17:09 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:45466 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY05x-0005Kn-Ur for 65386@debbugs.gnu.org; Mon, 21 Aug 2023 04:17:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1692605822; bh=gPHZVF9gSUW7gPs9F08jYnvPigmwvNFYVZJrTOuYktw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Lm6qk1FqFvxtDsO8xTUFmMKGzqRvlB4R1iDGCB6C+D8ah8LvjhHwVRO0nZFhzf7tX cNG8eAivgbbbtyRGCDx/fsB6IbY1sw6a/pZwKb5u/mIoodzVqGs48xVKLQZEQvkaoX ZNQTc7Btta5HYbIA6+F2OkZIVZ+VXSZEKPz4YznNNLq1sl2NE6hYdywhtW96/WJo4h FywlBZhfrtJY2tYtjHPzTk1jXPtd+xJO1buv1MRIJBi7hUIKGjH7jBcygrRDOfNKQI umPnssUzyxUXR7ALl1vdGo5awkItT31cvkt8uvllv5D6Ilyf/gu5s042NqGetrk4Rg td1aJdhZ/15LA== In-Reply-To: <87pm3hsb8t.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 20 Aug 2023 20:35:30 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268068 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Philip Kaludercic writes: > Mauro Aranda writes: > >> >> I haven't watch this thread closely, but do note that creating dynamic >> choices is quite possible, if I understand correctly what you're looking >> for. >> >> If you can, take a look at the defcustom of completion-styles, in >> minibuffer.el.=C2=A0 Its type uses a choice with a specialized >> :convert-widget function to keep the choices up-to date. > > This might be exactly what we are looking for. It should be possible to > adapt `completion--update-styles-options' pretty much directly to our > example. Mauro, thanks for the great tip. As Philip said, this seems to be exactly what we need here. Accordingly, I'm attaching an updated patch for= the `defcustom` types (the two other patches from my previous message are not affected and remain applicable). --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v2-0001-Refine-defcustom-types-in-package-vc.patch >From 0550c73148b23135de47229435205914d8080786 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 20 Aug 2023 16:20:54 +0200 Subject: [PATCH v2] ; Refine 'defcustom' types in 'package-vc' Only include VC backends that support cloning in the ':type' of 'package-vc-heuristic-alist' and 'package-vc-default-backend', and compute the list of relevant on demand to keep it fresh. * lisp/emacs-lisp/package-vc.el (package-vc--cloning-backend-p) (package-vc--update-backends): New functions. (package-vc--backend-type): New 'defconst'. (package-vc-heuristic-alist, package-vc-default-backend): Use it. --- lisp/emacs-lisp/package-vc.el | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index a3762d252b0..7c60c55d67f 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -62,6 +62,24 @@ package-vc (defconst package-vc--elpa-packages-version 1 "Version number of the package specification format understood by package-vc.") +(defun package-vc--cloning-backend-p (be) + "Return non-nil if the VC backend BE supports cloning repositories." + (or (vc-find-backend-function be 'clone) + (alist-get 'clone (get be 'vc-functions)))) + +(defun package-vc--update-backends (widget) + "Update WIDGET with VC backends suitable for cloning VCS repositories." + (widget-put widget :args + (seq-keep (lambda (be) + (when (package-vc--cloning-backend-p be) + (widget-convert (list 'const be)))) + vc-handled-backends)) + widget) + +(defconst package-vc--backend-type + '(choice :convert-widget package-vc--update-backends) + "The type of VC backends that support cloning package VCS repositories.") + (defcustom package-vc-heuristic-alist `((,(rx bos "http" (? "s") "://" (or (: (? "www.") "github.com" @@ -103,9 +121,7 @@ package-vc-heuristic-alist the URL-REGEXP of the association. If no match is found, `package-vc-install' uses `package-vc-default-backend' instead." :type `(alist :key-type (regexp :tag "Regular expression matching URLs") - :value-type (choice :tag "VC Backend" - ,@(mapcar (lambda (b) `(const ,b)) - vc-handled-backends))) + :value-type ,package-vc--backend-type) :version "29.1") (defcustom package-vc-default-backend 'Git @@ -116,8 +132,7 @@ package-vc-default-backend The value must be a member of `vc-handled-backends' that supports the `clone' VC function." - :type `(choice ,@(mapcar (lambda (b) (list 'const b)) - vc-handled-backends)) + :type package-vc--backend-type :version "29.1") (defcustom package-vc-register-as-project t -- 2.41.0 --=-=-=--