From patchwork Wed Nov 17 14:43:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 34575 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 68AE327BBE3; Wed, 17 Nov 2021 14:45:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2FF8427BBE1 for ; Wed, 17 Nov 2021 14:45:25 +0000 (GMT) Received: from localhost ([::1]:51952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnMBg-00008c-8N for patchwork@mira.cbaines.net; Wed, 17 Nov 2021 09:45:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnMBL-00005k-Qx for guix-patches@gnu.org; Wed, 17 Nov 2021 09:45:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mnMBK-0000QP-IT for guix-patches@gnu.org; Wed, 17 Nov 2021 09:45:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mnMBK-0005Yf-G6 for guix-patches@gnu.org; Wed, 17 Nov 2021 09:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51922] [PATCH 1/2] guix: Add syntax to capture arguments' syntax-properties. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 17 Nov 2021 14:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51922 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51922@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 51922-submit@debbugs.gnu.org id=B51922.163716025021252 (code B ref 51922); Wed, 17 Nov 2021 14:45:02 +0000 Received: (at 51922) by debbugs.gnu.org; 17 Nov 2021 14:44:10 +0000 Received: from localhost ([127.0.0.1]:60588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnMAT-0005Wi-US for submit@debbugs.gnu.org; Wed, 17 Nov 2021 09:44:10 -0500 Received: from jpoiret.xyz ([206.189.101.64]:38756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mnMAE-0005VO-KV for 51922@debbugs.gnu.org; Wed, 17 Nov 2021 09:44:09 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 90EC7184F27; Wed, 17 Nov 2021 14:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1637160233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=USvYSL062ojHkz9dUzW/1zoI/XnS8Kkpuy1Y4EwS+ps=; b=uDcOycI5hyqjnNV/7m7jqt+h2RXBdcvucm0ntlPHiW2hNaP6m9huVxfdv2Q0wWeuVIWRd5 w+3fGXpeLjBCZKJI1owNO4dJIxNXJbQkmyhRfS9X9TgrPk7XW+2GXYh3V9W0TmuSNRaZWj yEj+O8Oz0hSnWAdK09Ztiox0cThUVenJY/8978UMc3F/w8mphEeG4dbs8ATV28OK5iohmu j3HRypfaBc1WTg+GYg7ATWNnMwaHcZd+qYF0Mt/9GoTivaCkc/xGJlVkxbNvdK1NbVYn0Y bNQEnAG0eOSrEvFdUP3Uv60e4AJZmFlNZKCvvTNv4qzC+Zx058ixKvlVrdsMBA== Date: Wed, 17 Nov 2021 14:43:47 +0000 Message-Id: <20211117144348.17090-1-dev@jpoiret.xyz> In-Reply-To: <20211117144028.16722-1-dev@jpoiret.xyz> References: <20211117144028.16722-1-dev@jpoiret.xyz> MIME-Version: 1.0 X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * guix/diagnostics.scm (define-with-syntax-properties): Add it. --- guix/diagnostics.scm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 6a792febd4..337a73c1a2 100644 --- a/guix/diagnostics.scm +++ b/guix/diagnostics.scm @@ -54,7 +54,9 @@ (define-module (guix diagnostics) condition-fix-hint guix-warning-port - program-name)) + program-name + + define-with-syntax-properties)) ;;; Commentary: ;;; @@ -331,3 +333,37 @@ (define guix-warning-port (define program-name ;; Name of the command-line program currently executing, or #f. (make-parameter #f)) + + +(define-syntax define-with-syntax-properties + (lambda (x) + "Define BINDING to be a syntax form replacing each VALUE-IDENTIFIER and +SYNTAX-PROPERTIES-IDENTIFIER in body by the syntax and syntax-properties, +respectively, of each ensuing syntax object." + (syntax-case x () + ((_ (binding (value-identifier syntax-properties-identifier) + ...) + body ...) + (and (and-map identifier? #'(value-identifier ...)) + (and-map identifier? #'(syntax-properties-identifier ...))) + #'(define-syntax binding + (lambda (y) + (with-ellipsis ::: + (syntax-case y () + ((_ value-identifier ...) + (with-syntax ((syntax-properties-identifier + #`'#,(datum->syntax y + (syntax-source + #'value-identifier))) + ...) + #'(begin body ...))) + (_ + (syntax-violation #f (format #f + "Expected (~a~{ ~a~})" + 'binding + '(value-identifier ...)) + y))))))) + (_ + (syntax-violation #f "Expected a definition of the form \ +(define-with-syntax-properties (binding (value syntax-properties) \ +...) body ...)" x)))))