From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#66567: [PATCH] use-package: Add ignored-files support to :vc keyword Date: Wed, 01 Nov 2023 16:38:53 +0000 Message-ID: <871qd91l9e.fsf@posteo.net> References: <877cnn4z2v.fsf@hyperspace> <87ttq5u9fj.fsf@posteo.net> <87ttq5bx2y.fsf@hyperspace> <87r0l91vww.fsf@posteo.net> <87r0l9fsl1.fsf@hyperspace> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12152"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, 66567@debbugs.gnu.org To: Tony Zorman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 01 17:39:53 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qyEG1-0002xY-1X for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Nov 2023 17:39:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyEFd-0003r5-VH; Wed, 01 Nov 2023 12:39:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyEFc-0003pE-7T for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 12:39:28 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyEFb-00075k-Vf for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 12:39:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyEGA-0000Ow-0J for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Nov 2023 16:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66567 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66567-submit@debbugs.gnu.org id=B66567.16988567841507 (code B ref 66567); Wed, 01 Nov 2023 16:40:01 +0000 Original-Received: (at 66567) by debbugs.gnu.org; 1 Nov 2023 16:39:44 +0000 Original-Received: from localhost ([127.0.0.1]:52267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyEFo-0000O9-JX for submit@debbugs.gnu.org; Wed, 01 Nov 2023 12:39:44 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:39661) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyEFj-0000No-90 for 66567@debbugs.gnu.org; Wed, 01 Nov 2023 12:39:39 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A4155240029 for <66567@debbugs.gnu.org>; Wed, 1 Nov 2023 17:38:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698856734; bh=xhrBen5umZk2USpew4RsVl90HwDa8lGiINq9Tt8GmYk=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=nGUcG4vgRu8VU2VZbw7bCX0B5uMvft4CIs7s0MS++cBKJZoSHtT1as9W/EKZkLWw4 M2Tbu5pTd0xXsMjxB8SnlU0nNPBZjLJ7IQ0lByjE9EtJPofKIJeYFMzG24NVzyJQIL nV/zl/IUuC1gT0Ofs5p/c6UBadEyL3spf19B8bE1YEEqPaUG/JFoNBIb/xDXlsbzYZ PqMrkMxChp/IY0L3NqRFnUdGvXuug8Zwk/KqJZDV4m8c18u07trSCep6nLifY80jWF rFn0mJ5BLStaI6yMzsnUBcAlpGQkG5PpbqacOrm9x/gmGDOomwX7LRwPmuplimRTX/ /SsWQ6melOR/g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SLCPn6YBNz9rxL; Wed, 1 Nov 2023 17:38:53 +0100 (CET) In-Reply-To: <87r0l9fsl1.fsf@hyperspace> (Tony Zorman's message of "Wed, 01 Nov 2023 15:36:58 +0100") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273610 Archived-At: Tony Zorman writes: > On Wed, Nov 01 2023 12:48, Philip Kaludercic wrote: >> Tony Zorman writes: >> >>> On Wed, Nov 01 2023 09:09, Philip Kaludercic wrote: >>>>> diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/= use-package-core.el >>>>> index 34c45b7aec..5d0d554baf 100644 >>>>> --- a/lisp/use-package/use-package-core.el >>>>> +++ b/lisp/use-package/use-package-core.el >>>>> @@ -1654,7 +1654,8 @@ use-package-normalize--vc-arg >>>>> (t (ensure-string v)))) >>>>> (:vc-backend (ensure-symbol v)) >>>>> (_ (ensure-string v))))) >>>>> - (pcase-let ((valid-kws '(:url :branch :lisp-dir :main-file :vc-b= ackend :rev)) >>>>> + (pcase-let ((valid-kws '( :url :branch :lisp-dir :main-file :vc-= backend :rev >>>>> + :shell-command :make)) >>>> >>>> Why is use-package checking for valid keywords in the first place? >>> >>> Better error messages, mostly. Especially people switching from >>> quelpa/straight/vc-use-package might be surprised that :vc is not a >>> drop-in replacement for those packages. I feel like alerting them to >>> this fact sooner rather than later makes for a better experience. >> >> IIUC this would raise an error when an unknown keyword is encountered, >> right? > > Yes, a declaration like > > (use-package foo > :vc (:url "url" :blargh "123")) > > would result in the following message > > =E2=9B=94 Error (use-package): Failed to parse package foo: use-packa= ge: Keyword :vc received unknown argument: :blargh. Supported keywords are:= (:url :branch :lisp-dir :main-file :vc-backend :rev :shell-command :make := ignored-files) > > Things get a bit muddier if ':blargh' would be passed down to > package-vc-install. What I was wondering, was if it would make sense to raise an warning instead. > now that you mention it, I noticed a tiny mistake (resulting in a worse > error message!) in the second of the original patches. I've attached a > corrected version. 1+ >>>>> I will cheekily bump this, and also Cc. Philip as the most likely >>>>> reviewer. >>>> >>>> I don't use use-package nor am I familiar with the code base, so I >>>> wouldn't value my input that much. >>> >>> Oh, fair enough. In either case, I couldn't think of anyone else=E2=80= =94sorry >>> for the noise :) >> >> I think that Stefan Kangas would probably be the best to ask, since he >> was the one responsible for merging use-package into the core. > > Thanks! I have Cc'd Stefan, hoping to not come across as too pushy :) That should be fine (I hope). > Tony > > From f8590d37b29a96a7984d8acae2d6c2b557e0dc59 Mon Sep 17 00:00:00 2001 > From: Tony Zorman > Date: Sun, 15 Oct 2023 16:51:00 +0200 > Subject: [PATCH] use-package: Add :ignored-files support to :vc keyword > > * lisp/use-package/use-package-core.el (use-package-split-when): > New utility function to split a list whenever a specified predicate > returns t. > (use-package-vc-valid-keywords): A new defconst to gather all allowed > keywords. > (use-package-normalize--vc-arg): Properly normalize the :ignored-files > keyword, in that the following are all valid ways of entering files: > :ignored-files "a" > :ignored-files ("a") > :ignored-files "a" "b" "c" > :ignored-files ("a" "b" "c") > (use-package-normalize/:vc): Adjust normalization, now that we do not > necessarily receive a valid plist as an input. > > * test/lisp/use-package/use-package-tests.el (use-package-test-normalize/= :vc): > Add tests for :ignored-files keyword. > --- > lisp/use-package/use-package-core.el | 60 ++++++++++++++++------ > test/lisp/use-package/use-package-tests.el | 10 +++- > 2 files changed, 52 insertions(+), 18 deletions(-) > > diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-= package-core.el > index 5d0d554baf..974059a850 100644 > --- a/lisp/use-package/use-package-core.el > +++ b/lisp/use-package/use-package-core.el > @@ -521,6 +521,24 @@ use-package-split-list-at-keys > (let ((xs (use-package-split-list (apply-partially #'eq key) lst)= )) > (cons (car xs) (use-package-split-list-at-keys key (cddr xs))))= )) >=20=20 > +(defun use-package-split-when (pred xs) > + "Repeatedly split a list according to PRED. > +Split XS every time PRED returns t. Keep the delimiters, and > +arrange the result in an alist. For example: > + > + (use-package-split-when #\\=3D'keywordp \\=3D'(:a 1 :b 2 3 4 :c 5)) > + ;; =3D> \\=3D'((:a 1) (:b 2 3 4) (:c 5)) > + > + (use-package-split-when (lambda (x) (> x 2)) \\=3D'(10 1 3 2 4 -1 8 9)) > + ;; =3D> \\=3D'((10 1) (3 2) (4 -1) (8) (9))" > + (unless (seq-empty-p xs) > + (pcase-let* ((`(,first . ,rest) (if (funcall pred (car xs)) > + (cons (car xs) (cdr xs)) > + (use-package-split-list pred xs))) > + (`(,val . ,recur) (use-package-split-list pred rest))) > + (cons (cons first val) > + (use-package-split-when pred recur))))) > + > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;; > ;; > ;;; Keywords > @@ -1634,6 +1652,12 @@ use-package-handler/:vc > (push `(use-package-vc-install ',arg ,local-path) body)) ; runti= me > body)) >=20=20 > +(defconst use-package-vc-valid-keywords > + '( :url :branch :lisp-dir :main-file :vc-backend :rev > + :shell-command :make :ignored-files) > + "Valid keywords for the `:vc' keyword, see the Info > +node `(emacs)Fetching Package Sources'.") > + > (defun use-package-normalize--vc-arg (arg) > "Normalize possible arguments to the `:vc' keyword. > ARG is a cons-cell of approximately the form that > @@ -1653,24 +1677,26 @@ use-package-normalize--vc-arg > ((eq v :newest) nil) > (t (ensure-string v)))) > (:vc-backend (ensure-symbol v)) > + (:ignored-files (if (listp v) v (list v))) > (_ (ensure-string v))))) > - (pcase-let ((valid-kws '( :url :branch :lisp-dir :main-file :vc-back= end :rev > - :shell-command :make)) > - (`(,name . ,opts) arg)) > + (pcase-let* ((`(,name . ,opts) arg)) > (if (stringp opts) ; (NAME . VERSION-STRING) ? > (list name opts) > - ;; Error handling > - (cl-loop for (k _) on opts by #'cddr > - if (not (member k valid-kws)) > - do (use-package-error > - (format "Keyword :vc received unknown argument: %s.= Supported keywords are: %s" > - k valid-kws))) > - ;; Actual normalization > - (list name > - (cl-loop for (k v) on opts by #'cddr > - if (not (eq k :rev)) > - nconc (list k (normalize k v))) > - (normalize :rev (plist-get opts :rev))))))) > + (let ((opts (use-package-split-when > + (lambda (el) (and (keywordp el) (not (equal :newest= el)))) > + opts))) > + ;; Error handling > + (cl-loop for (k . _) in opts > + if (not (member k use-package-vc-valid-keywords)) > + do (use-package-error > + (format "Keyword :vc received unknown argument: %= s. Supported keywords are: %s" > + k use-package-vc-valid-keywords))) > + ;; Actual normalization > + (list name > + (cl-loop for (k . v) in opts > + if (not (eq k :rev)) > + nconc (list k (normalize k (if (length=3D v 1) = (car v) v)))) > + (normalize :rev (car (alist-get :rev opts))))))))) >=20=20 > (defun use-package-normalize/:vc (name _keyword args) > "Normalize possible arguments to the `:vc' keyword. > @@ -1686,9 +1712,9 @@ use-package-normalize/:vc > ((or 'nil 't) (list name)) ; guess name > ((pred symbolp) (list arg)) ; use this name > ((pred stringp) (list name arg)) ; version string + gues= s name > - ((pred plistp) ; plist + guess name > + (`(,(pred keywordp) . ,(pred listp)) ; list + guess name > (use-package-normalize--vc-arg (cons name arg))) > - (`(,(pred symbolp) . ,(or (pred plistp) ; plist/version string = + name > + (`(,(pred symbolp) . ,(or (pred listp) ; list/version string += name > (pred stringp))) > (use-package-normalize--vc-arg arg)) > (_ (use-package-error "Unrecognised argument to :vc.\ > diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-p= ackage/use-package-tests.el > index 9181a8171a..5636ba8a4f 100644 > --- a/test/lisp/use-package/use-package-tests.el > +++ b/test/lisp/use-package/use-package-tests.el > @@ -2014,7 +2014,15 @@ use-package-test-normalize/:vc > (should (equal '(foo) > (use-package-normalize/:vc 'foo :vc nil))) > (should (equal '(bar) > - (use-package-normalize/:vc 'foo :vc '(bar))))) > + (use-package-normalize/:vc 'foo :vc '(bar)))) > + (should (equal > + '(foo (:ignored-files ("a" "b" "c")) :last-release) > + (use-package-normalize/:vc 'foo :vc '((:ignored-files "a" "b"= "c"))))) > + (should (equal > + (use-package-normalize/:vc 'foo :vc '((:ignored-files "a"))) > + (use-package-normalize/:vc 'foo :vc '((:ignored-files ("a")))= ))) > + (should (equal (use-package-normalize/:vc 'foo :vc '((:ignored-files "= a" "b" "c"))) > + (use-package-normalize/:vc 'foo :vc '((:ignored-files (= "a" "b" "c"))))))) >=20=20 > ;; Local Variables: > ;; no-byte-compile: t > --=20 > 2.42.0