GNU bug report logs -
#65386
[PATCH] ; Refine some 'package-vc' docstrings
Previous Next
Reported by: Eshel Yaron <me <at> eshelyaron.com>
Date: Sat, 19 Aug 2023 18:08:02 UTC
Severity: normal
Tags: patch
Fixed in version 30.1
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Eshel Yaron <me <at> eshelyaron.com> writes:
> Philip Kaludercic <philipk <at> posteo.net> writes:
>
>> Mauro Aranda <maurooaranda <at> gmail.com> 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. 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).
I have slightly modified it to remove the helper functions. As
mentioned before. Hope you are fine with it:
[Message part 2 (text/plain, inline)]
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index bf4cad4f319..dfaedbcc84c 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -62,6 +62,18 @@ package-vc
(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 @@ 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 +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))
+ :type package-vc--backend-type
:version "29.1")
(defcustom package-vc-register-as-project t
This bug report was last modified 1 year and 359 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.