Subject: 30; Invalid use-package-vc-valid-keywords value and validation

From: Jonas Bernoulli <[email-masked]>
Date: Tue, 25 Feb 2025 14:43:16 +0100

A Forge user reported that

  (use-package forge
    :demand t
    :vc ( :url "https://github.com/magit/forge.git"
          :lisp-dir "lisp"
          :doc "docs/forge.texi"))

results in this weird error

  Error (use-package): Failed to parse package forge: Wrong type \
  argument: symbolp, ("lisp" :doc "docs/forge.texi")

This has two causes:

1. :doc should, but is not, a member of use-package-vc-valid-keywords.

2. First the plist-but-not-really user input is converted to an alist,
   which makes it impossible to afterwards check the validity of the
   encountered keywords, which is what is being attempted.

   Due to the first issue, the alist looks like

     ((:url "https://github.com/magit/forge.git")
      (:lisp-dir "lisp" :doc "docs/forge.texi"))

   but the subsequent check (reasonably) assumes it would get to look at
   this instead:
   
     ((:url "https://github.com/magit/forge.git")
      (:lisp-dir "lisp")
      (:doc "docs/forge.texi"))

   Possible fixes:

   - Maybe the plist-but-not-really is in fact a plist, and it can just
     be treated as such.

     *use-package* sometimes uses this weirdness (:keyA val1 val2 :keyB
     val3), but would that actually ever be valid :vc (...HERE...) too?

   - If no keyword can actually have another keyword as part of its
     value, then it probably would be appropriate to use #'keywordp as
     argument to use-package-split-when.

And also

3. use-package-vc-valid-keywords contains :ignored-files but that is not
   mentioned at (info "(emacs) Fetching Package Sources").

Regards,
Jonas