From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QDmuBWqmMWGCIwAAgWs5BA (envelope-from ) for ; Fri, 03 Sep 2021 06:36:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 0CkeAWqmMWHoQgAAbx9fmQ (envelope-from ) for ; Fri, 03 Sep 2021 04:36:58 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CD7F818C5C for ; Fri, 3 Sep 2021 06:36:56 +0200 (CEST) Received: from localhost ([::1]:49904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM0Ts-0003gX-PQ for larch@yhetil.org; Fri, 03 Sep 2021 00:07:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM0Tn-0003fz-3y for guix-patches@gnu.org; Fri, 03 Sep 2021 00:07:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM0Tm-0004w7-So for guix-patches@gnu.org; Fri, 03 Sep 2021 00:07:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mM0Tm-00036w-Jm for guix-patches@gnu.org; Fri, 03 Sep 2021 00:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50349] [PATCH] packages: Add 'define-package' syntax. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Sep 2021 04:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50349 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50349@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163064199811924 (code B ref -1); Fri, 03 Sep 2021 04:07:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Sep 2021 04:06:38 +0000 Received: from localhost ([127.0.0.1]:42511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mM0TO-00036F-3u for submit@debbugs.gnu.org; Fri, 03 Sep 2021 00:06:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:53296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mM0TM-000367-LI for submit@debbugs.gnu.org; Fri, 03 Sep 2021 00:06:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM0TL-0003eL-LS for guix-patches@gnu.org; Fri, 03 Sep 2021 00:06:36 -0400 Received: from out0.migadu.com ([94.23.1.103]:39653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM0TI-0004Sp-0E for guix-patches@gnu.org; Fri, 03 Sep 2021 00:06:35 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1630641989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CvJCpfvD/KAVUiSNJ0d1E4N2r9otbKVcqE68XxN2hCE=; b=SzB2uPCwny/d2VdiLyh/9NcRDpaRJBrm1vnYGnJBRUoiaVoss3qb6RZ3/L+KwateHJpr1V PvP+Vh3DMBqyCnkVnzSYT4Amyk04iUFXOPEBmsrGGEgz3St+hMaBnNbZ2Y6rNd5+sHzgyf 90XUBQjh7CD/W9NhQ0qysIvFDBrGeAA= From: Sarah Morgensen Date: Thu, 2 Sep 2021 21:06:26 -0700 Message-Id: <15d01b32313f5f2f291b120597719ae92bd26acd.1630639896.git.iskarian@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Auth-User: iskarian@mgsn.dev Received-SPF: pass client-ip=94.23.1.103; envelope-from=iskarian@mgsn.dev; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630643817; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=CvJCpfvD/KAVUiSNJ0d1E4N2r9otbKVcqE68XxN2hCE=; b=hn2KjdlIG7aZq1CLJsz7Medi8SMZu75kMeda173OWq+cJHNR56x82Ic2mVohyWejWY3MVy aSixhSCW4SabXEQ9IMDU0ZndWkODtYTgKa9TmJB0/RD44vkW3E5kZVL49ZHQ0oUHsZ0ryJ +yYwvvgwqeMC1wMVrk+Z8prAczSgJVV0tSpeurXzsqPw04srlHWD1HvhZ8XvzU2eq67CKb gbtP+utzRXY3WH8Vggc1WgSPBuvZv+pqQKrz02oANtnRGF8zKrFVWYEaQM1Y1p3Kp21Mgj ayF8fn4N8+QkvCKc0YHWyWOfZLXBIceeCLORAT/6EKuD9TszQitQu+qj6EHUuQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630643817; a=rsa-sha256; cv=none; b=DQxzXki1QuLY7IXK4+7Ph28dRj15VtFFvmvIz6e+NE+Ib59GLg37zMDdEpr6AetCpWnJSG aS4WYY8Ho8d2O2R2Iyr4ICwoIRD8n696qAu1EzTVNtPFZpzcHs54DSaaa7wjdFAiNt1DDP OmTwPOvZeo9q6zUhjMh/RgZJJxkOIiSYtn9ZYCc+CQxqzHxjCQlbqiHA7X25+IyeLgZPeR zYUYU3S55IRdON5a0GqxRB9/dlRaDiVrkAi2VP+RnIf9pKbQ0pOiH9sLhhQpVaHFyqoTwF MdsdFVkoYJwt2MCX/ugsmHVRi1BPzv483QpRC2zwIwrF+Chs9KPhYRgMC20n1w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=SzB2uPCw; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 1.18 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=SzB2uPCw; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: CD7F818C5C X-Spam-Score: 1.18 X-Migadu-Scanner: scn1.migadu.com X-TUID: i6UatlL0mtDl * guix/packages.scm (define-package): New syntax. * .dir-locals.el: Add indent rule for 'define-package'. * etc/indent-code.el (main): Adjust package search regex accordingly. * etc/snippets/text-mode/guix-commit-message-add-cl-package: Likewise. * etc/snippets/text-mode/guix-commit-message-add-package: Likewise. * etc/snippets/text-mode/guix-commit-message-rename-package: Likewise. * etc/snippets/text-mode/guix-commit-message-update-package: Likewise. --- Hello Guix, This patch adds a shorthand for "(define-public name (package ...))": (define-package my-favorite-package (name "my-favorite-package") ...) The purpose is primarily to save the horizontal indent, but IMO it looks better, and is marginally more clear for newcomers. I think ideally we could eventually transition to using this syntax as the primary syntax and only use 'define-public' when necessary. There are some downsides... it's one more form to keep track of, and 'let' forms can't easily be used with it. Since it's a syntax rule, it doesn't cause packages to rebuild (tested). I've also tested the indentation rules, indent-code.el, and the snippets. This probably deserves a documentation addition, but I wasn't sure where to add it without confusing newcomers. Suggestions welcome! (If this is accepted, we'll also want to make a few changes to emacs-guix/elisp/guix-devel.el, adding 'define-package' to 'guix-devel-keywords' and to 'guix-devel-scheme-indent' with level 1.) What do you all think? -- Sarah .dir-locals.el | 1 + etc/indent-code.el | 2 +- etc/snippets/text-mode/guix-commit-message-add-cl-package | 2 +- etc/snippets/text-mode/guix-commit-message-add-package | 2 +- etc/snippets/text-mode/guix-commit-message-rename-package | 4 ++-- etc/snippets/text-mode/guix-commit-message-update-package | 2 +- guix/packages.scm | 8 ++++++++ 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index aaa48ab552..8141cf4fc2 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -71,6 +71,7 @@ (eval . (put 'with-writable-file 'scheme-indent-function 2)) (eval . (put 'package 'scheme-indent-function 0)) + (eval . (put 'define-package 'scheme-indent-function 1)) (eval . (put 'package/inherit 'scheme-indent-function 1)) (eval . (put 'origin 'scheme-indent-function 0)) (eval . (put 'build-system 'scheme-indent-function 0)) diff --git a/etc/indent-code.el b/etc/indent-code.el index bdea8ee8bf..b83659f2f9 100755 --- a/etc/indent-code.el +++ b/etc/indent-code.el @@ -94,7 +94,7 @@ ;; Indent the definition of PACKAGE-NAME in FILE-NAME. (find-file file-name) (goto-char (point-min)) - (if (re-search-forward (concat "^(define\\(\\|-public\\) +" + (if (re-search-forward (concat "^(define\\(\\|-public\\|-package\\) +" package-name) nil t) (let ((indent-tabs-mode nil)) diff --git a/etc/snippets/text-mode/guix-commit-message-add-cl-package b/etc/snippets/text-mode/guix-commit-message-add-cl-package index e255736b05..eb0de677e7 100644 --- a/etc/snippets/text-mode/guix-commit-message-add-cl-package +++ b/etc/snippets/text-mode/guix-commit-message-add-cl-package @@ -7,7 +7,7 @@ gnu: Add ${1:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") (beginning-of-buffer) - (when (search-forward "+(define-public " nil 'noerror) + (when (re-search-forward "+(define-\\(public\\|package\\) " nil 'noerror) (replace-regexp-in-string "^sbcl-" "" (thing-at-point 'sexp 'no-properties))))`}. diff --git a/etc/snippets/text-mode/guix-commit-message-add-package b/etc/snippets/text-mode/guix-commit-message-add-package index 7cebd4023a..11aeceb129 100644 --- a/etc/snippets/text-mode/guix-commit-message-add-package +++ b/etc/snippets/text-mode/guix-commit-message-add-package @@ -7,7 +7,7 @@ gnu: Add ${1:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") (goto-char (point-min)) - (when (re-search-forward "\\+(define-public \\(\\S-+\\)" nil 'noerror) + (when (re-search-forward "\\+(define-\\(?:public\\|package\\) \\(\\S-+\\)" nil 'noerror) (match-string-no-properties 1)))`}. * `(car (magit-staged-files))` ($1): New variable. \ No newline at end of file diff --git a/etc/snippets/text-mode/guix-commit-message-rename-package b/etc/snippets/text-mode/guix-commit-message-rename-package index 9695ca1b3d..2315443573 100644 --- a/etc/snippets/text-mode/guix-commit-message-rename-package +++ b/etc/snippets/text-mode/guix-commit-message-rename-package @@ -7,12 +7,12 @@ gnu: ${1:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") (beginning-of-buffer) - (when (search-forward "-(define-public " nil 'noerror) + (when (re-search-forward "-(define-\\(public\\|package\\) " nil 'noerror) (thing-at-point 'sexp 'no-properties)))`}: Rename package to ${2:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") (beginning-of-buffer) - (when (search-forward "+(define-public " nil 'noerror) + (when (re-search-forward "+(define-\\(public\\|package\\) " nil 'noerror) (thing-at-point 'sexp 'no-properties)))`}. * `(car (magit-staged-files))` ($1): Define in terms of diff --git a/etc/snippets/text-mode/guix-commit-message-update-package b/etc/snippets/text-mode/guix-commit-message-update-package index f187419aa2..1d39e28b77 100644 --- a/etc/snippets/text-mode/guix-commit-message-update-package +++ b/etc/snippets/text-mode/guix-commit-message-update-package @@ -8,7 +8,7 @@ gnu: ${1:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") (goto-char (point-min)) - (when (re-search-forward "(define-public \\(\\S-+\\)" nil 'noerror) + (when (re-search-forward "(define-\\(?:public\\|package\\) \\(\\S-+\\)" nil 'noerror) (match-string-no-properties 1)))`}: Update to ${2:`(with-temp-buffer (magit-git-wash #'magit-diff-wash-diffs "diff" "--staged") diff --git a/guix/packages.scm b/guix/packages.scm index c825f427d8..ecd0b7e47d 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2017, 2019, 2020 Efraim Flashner ;;; Copyright © 2019 Marius Bakke ;;; Copyright © 2021 Chris Marusich +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -99,6 +100,7 @@ (define-module (guix packages) package-supported-systems package-properties package-location + define-package hidden-package hidden-package? package-superseded @@ -425,6 +427,12 @@ (define-record-type* package) 16))))) +(define-syntax-rule (define-package name body ...) + "Equivalent to (define-public name (package body ...))." + (define-public name + (package + body ...))) + (define-syntax-rule (package/inherit p overrides ...) "Like (package (inherit P) OVERRIDES ...), except that the same transformation is done to the package P's replacement, if any. P must be a bare base-commit: 95c29d2746943733cbe8df7013854d45bb0df413 -- 2.31.1