From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Mon, 8 May 2023 16:42:12 +0800 Message-ID: <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> References: <87pm7b7up0.fsf@breatheoutbreathe.in> Reply-To: Ruijie Yu Mime-Version: 1.0 (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="19057"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63336@debbugs.gnu.org, Philip Kaludercic To: Joseph Turner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 08 10:43:30 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 1pvwSw-0004nK-HT for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 May 2023 10:43:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pvwSW-0002J6-N2; Mon, 08 May 2023 04:43:04 -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 1pvwSU-0002IH-FU for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 04:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pvwSU-0006ZT-6K for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 04:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pvwSU-000207-28 for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 04:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 May 2023 08:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63336 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63336-submit@debbugs.gnu.org id=B63336.16835353567648 (code B ref 63336); Mon, 08 May 2023 08:43:02 +0000 Original-Received: (at 63336) by debbugs.gnu.org; 8 May 2023 08:42:36 +0000 Original-Received: from localhost ([127.0.0.1]:39112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvwS4-0001zG-7s for submit@debbugs.gnu.org; Mon, 08 May 2023 04:42:36 -0400 Original-Received: from netyu.xyz ([152.44.41.246]:54132 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvwS2-0001yy-12 for 63336@debbugs.gnu.org; Mon, 08 May 2023 04:42:35 -0400 Original-Received: from smtpclient.apple ( [112.97.61.182]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 463d990d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 8 May 2023 08:42:33 +0000 (UTC) In-Reply-To: <87pm7b7up0.fsf@breatheoutbreathe.in> X-Mailer: iPhone Mail (20E252) 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:261297 Archived-At: Hello Joseph,=20 On mobile so please excuse my brevity and top-posting.=20 Minor remark on the defcustom type: I think you should move the current tag f= rom "symbol" to its outer "repeat", and optionally tag "symbol" as something= like "package name". WDYT?=20 -- Best,=20 RY > On May 8, 2023, at 04:29, Joseph Turner via Bug reports for GNU Emacs, the= Swiss army knife of text editors wrote: >=20 > =EF=BB=BFThanks for the review! >=20 > Philip Kaludercic writes: >=20 >> Joseph Turner writes: >>=20 >>> Hello! >>>=20 >>> Here's a patch to support :make and :shell-command args as discussed: >>>=20 >>> https://lists.gnu.org/archive/html/help-gnu-emacs/2023-04/msg00263.html >>=20 >> Thanks! >>=20 >>> Best, >>>=20 >>> Joseph >>>=20 >>> =46rom c51161c51f11e6ffcba17758424596fe44f9d42a Mon Sep 17 00:00:00 2001= >>> From: Joseph Turner >>> Date: Sat, 6 May 2023 13:44:32 -0700 >>> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >>>=20 >>> --- >>> lisp/emacs-lisp/package-vc.el | 32 ++++++++++++++++++++++++++++++++ >>> 1 file changed, 32 insertions(+) >>>=20 >>> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.= el >>> index 421947b528d..489610e2a1e 100644 >>> --- a/lisp/emacs-lisp/package-vc.el >>> +++ b/lisp/emacs-lisp/package-vc.el >>> @@ -344,6 +344,35 @@ asynchronously." >>> "\n") >>> nil pkg-file nil 'silent)))) >>>=20 >>> +(defcustom package-vc-process-make nil >>> + "If non-nil, process :make and :shell-command spec arguments. >>> +Package specs are loaded from trusted package archives." >>> + :type 'boolean) >>=20 >> As this patch is going to be added to Emacs 30, we should add >>=20 >> :version "30.1" >>=20 >> tags to this user option. >=20 > Fixed. >=20 >>> +(defun package-vc--call (destination program &rest args) >>> + "Like =E2=80=98call-process=E2=80=99 for PROGRAM, DESTINATION, ARGS. >> ^ >> You should replace these quotation marks with regular ASCII `marks', so >> avoid byte-compiler warnings. >=20 > Good catch. >=20 >>> +The INFILE and DISPLAY arguments are fixed as nil." >>> + (apply #'call-process program nil destination nil (delq nil args))) >>=20 >> What is the motivation for this function? Is this where >> process-isolation would be added in the future? >=20 > In the attached patch, package-vc--call is replaced with call-process. >=20 >>> +(defun package-vc--make (pkg-spec dir) >>> + "Process :make and :shell-command spec arguments." >>> + (let ((target (plist-get pkg-spec :make)) >>> + (cmd (plist-get pkg-spec :shell-command))) >>> + (when (or cmd target) >>> + (with-current-buffer (get-buffer-create " *package-vc make*") >> ^ >> should the package name >> be mentioned here? >=20 > I like this idea, but IIUC package-vc--make would then need to take an > extra arg, since pkg-spec doesn't contain the :name of the package. We > could also add :name to the pkg-spec plist? >=20 > For comparison, package-vc--build-documentation creates a buffer called > " *package-vc doc*" without the package name. >=20 >>> + (erase-buffer) >>> + (when (and cmd >>> + (/=3D 0 (package-vc--call t shell-file-name >>> + shell-command-switch >>> + cmd))) >>> + (message "Failed to run %s, see buffer %S" >>=20 >> Could `warn' be a better candidate here, instead of `message'? >=20 > Done. >=20 >>> + cmd (buffer-name))) >>> + (when (and target >>> + (/=3D 0 (apply #'package-vc--call t "make" >>> + (if (consp target) target (list target)= )))) >>> + (message "Failed to make %s, see buffer %S" >=20 > And this message is changed to warn also. >=20 >>> + target (buffer-name))))))) >>> + >>> (declare-function org-export-to-file "ox" (backend file)) >>>=20 >>> (defun package-vc--build-documentation (pkg-desc file) >>> @@ -486,6 +515,9 @@ documentation and marking the package as installed."= >>> ;; Generate package file >>> (package-vc--generate-description-file pkg-desc pkg-file) >>>=20 >>> + ;; Process :make and :shell-command arguments before building doc= umentation >>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)= ) >>=20 >> Wasn't the plan to allow `package-vc-process-make' to either be a >> generic "build-anything" or a selective listing of packages where we >> allow :make and :shell-command to be executed? >=20 > Let me know if the attached commit accomplishes what you had in mind. >=20 >>> + >>> ;; Detect a manual >>> (when (executable-find "install-info") >>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >>=20 >> Otherwise this looks good, but I haven't tried it out yet. >=20 > I fixed up a couple other issues: >=20 > - removed unnecessary dir arg to package-vc--make > - added function arg to the docstring for package-vc--make >=20 > I'm not sure if the customization type for package-vc-process-make is > correct. Please double check that. >=20 > Also, should users be able to run :make and :shell-command args defined > in a spec passed into package-vc-install? >=20 > Best, >=20 > Joseph >=20 > <0001-package-vc-Process-make-and-shell-command-spec-args.patch>