From 8a339d3bffe81f80e7e968505c40855d6598b8ac Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 20 Aug 2023 16:20:54 +0200 Subject: [PATCH] ; 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'. * lisp/emacs-lisp/package-vc.el (package-vc--cloning-backend-p) (package-vc--backends): New functions. (package-vc-heuristic-alist, package-vc-default-backend): Use it. --- lisp/emacs-lisp/package-vc.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index a3762d252b0..44a4624e49f 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -62,6 +62,15 @@ 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--backends () + "Return a list of VC backends suitable for cloning package VCS repositories." + (seq-filter #'package-vc--cloning-backend-p vc-handled-backends)) + (defcustom package-vc-heuristic-alist `((,(rx bos "http" (? "s") "://" (or (: (? "www.") "github.com" @@ -105,7 +114,7 @@ package-vc-heuristic-alist :type `(alist :key-type (regexp :tag "Regular expression matching URLs") :value-type (choice :tag "VC Backend" ,@(mapcar (lambda (b) `(const ,b)) - vc-handled-backends))) + (package-vc--backends)))) :version "29.1") (defcustom package-vc-default-backend 'Git @@ -117,7 +126,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)) + (package-vc--backends))) :version "29.1") (defcustom package-vc-register-as-project t -- 2.41.0