emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 72ab5dc0b4b 2/3: ; Refine 'defcustom' types in 'package-vc'


From: Philip Kaludercic
Subject: master 72ab5dc0b4b 2/3: ; Refine 'defcustom' types in 'package-vc'
Date: Tue, 29 Aug 2023 04:42:08 -0400 (EDT)

branch: master
commit 72ab5dc0b4b6fab7427b808b3e5d54484b983ed5
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Philip Kaludercic <philipk@posteo.net>

    ; 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--backend-type): New constant.
    (package-vc-heuristic-alist, package-vc-default-backend): Use it.  
(Bug#65386)
---
 lisp/emacs-lisp/package-vc.el | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index b653e3184b6..d225e61646c 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -62,6 +62,18 @@
 (defconst package-vc--elpa-packages-version 1
   "Version number of the package specification format understood by 
package-vc.")
 
+(defconst package-vc--backend-type
+  `(choice :convert-widget
+           ,(lambda (widget)
+              (let (opts)
+                (dolist (be vc-handled-backends)
+                  (when (or (vc-find-backend-function be 'clone)
+                            (alist-get 'clone (get be 'vc-functions)))
+                    (push (widget-convert (list 'const be)) opts)))
+                (widget-put widget :args opts))
+              widget))
+  "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 +115,7 @@ the first association for which the URL of the repository 
matches
 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 +126,7 @@ the backend nor a repository URL that's recognized via
 
 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]