From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Philip Kaludercic <philipk@posteo.net>
Cc: Eli Zaretskii <eliz@gnu.org>,
Mauro Aranda <maurooaranda@gmail.com>,
65386@debbugs.gnu.org
Subject: bug#65386: [PATCH] ; Refine some 'package-vc' docstrings
Date: Mon, 21 Aug 2023 10:16:59 +0200 [thread overview]
Message-ID: <m1pm3g95dw.fsf@eshelyaron.com> (raw)
In-Reply-To: <87pm3hsb8t.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 20 Aug 2023 20:35:30 +0000")
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]
Philip Kaludercic <philipk@posteo.net> writes:
> Mauro Aranda <maurooaranda@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).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-Refine-defcustom-types-in-package-vc.patch --]
[-- Type: text/x-patch, Size: 2894 bytes --]
From 0550c73148b23135de47229435205914d8080786 Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
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
next prev parent reply other threads:[~2023-08-21 8:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-19 18:07 bug#65386: [PATCH] ; Refine some 'package-vc' docstrings Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-19 19:47 ` Eli Zaretskii
2023-08-19 20:42 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 6:05 ` Eli Zaretskii
2023-08-20 7:15 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 8:32 ` Philip Kaludercic
2023-08-20 10:14 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 12:18 ` Philip Kaludercic
2023-08-20 14:44 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 16:04 ` Philip Kaludercic
2023-08-20 16:22 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 18:33 ` Philip Kaludercic
2023-08-20 10:31 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 8:13 ` Philip Kaludercic
2023-08-20 19:24 ` Mauro Aranda
2023-08-20 20:35 ` Philip Kaludercic
2023-08-21 8:16 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-21 9:27 ` Philip Kaludercic
2023-08-21 10:22 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] <87ledwipkb.fsf@posteo.net>
2023-08-27 17:18 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-29 8:43 ` Philip Kaludercic
2023-08-29 9:10 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1pm3g95dw.fsf@eshelyaron.com \
--to=bug-gnu-emacs@gnu.org \
--cc=65386@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=maurooaranda@gmail.com \
--cc=me@eshelyaron.com \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).