From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YJ+ENfGa6WJ2UAEAbAwnHQ (envelope-from ) for ; Tue, 02 Aug 2022 23:45:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id eKadNPGa6WI2GwAAG6o9tA (envelope-from ) for ; Tue, 02 Aug 2022 23:45:21 +0200 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 883083CFA8 for ; Tue, 2 Aug 2022 23:45:21 +0200 (CEST) Received: from localhost ([::1]:58492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIzhY-0001yV-GG for larch@yhetil.org; Tue, 02 Aug 2022 17:45:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIzhH-0001ui-Fy for guix-patches@gnu.org; Tue, 02 Aug 2022 17:45:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIzhH-0006FX-4M for guix-patches@gnu.org; Tue, 02 Aug 2022 17:45:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oIzhG-00039Y-WE for guix-patches@gnu.org; Tue, 02 Aug 2022 17:45:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56898] [PATCH 04/13] read-print: Introduce parent class of . Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 02 Aug 2022 21:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56898 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56898@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 56898-submit@debbugs.gnu.org id=B56898.165947668011955 (code B ref 56898); Tue, 02 Aug 2022 21:45:02 +0000 Received: (at 56898) by debbugs.gnu.org; 2 Aug 2022 21:44:40 +0000 Received: from localhost ([127.0.0.1]:45275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIzgs-00036c-PR for submit@debbugs.gnu.org; Tue, 02 Aug 2022 17:44:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIzgp-00035R-48 for 56898@debbugs.gnu.org; Tue, 02 Aug 2022 17:44:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIzgj-00069V-Rj; Tue, 02 Aug 2022 17:44:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=pt0sN+GHGiH0RhP9V05jLiSoKT4K+EEgXPIc/+60wFU=; b=YngCfDmdlD4ATBVkgBDe sXOur1PTJwf6F79qubqPZxdZHTbDWLW1bBHXGm/qljW/dDRfjFTmGV30Q91n3M/MbSKmHXp9+py7e tFzE+tHZfEfw2GuUfnnTTcblkrQOOdhSA1In+OZnN85g6IClF2LoIlPu4vM1fzfBOtaTuLyimdg5i 8DOX/svVYWCp7fkoWNQBct1D4Kg1l6oy3Ylto+ICYGrUQtX9HQAM7sAcL9GzNG5Yvxbv9/fxeEyjH aJgnt2/huy7r1jG7RNjuIfguMfazMNVpajLdi/gMfZryXobfi6rndmuFCLttxBYWizgrCxqiUn0EN Ku/4XxmH9odTWQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:52235 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIzgj-0006W4-FL; Tue, 02 Aug 2022 17:44:29 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 2 Aug 2022 23:44:10 +0200 Message-Id: <20220802214419.19013-4-ludo@gnu.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220802214419.19013-1-ludo@gnu.org> References: <20220802214419.19013-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1659476721; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=pt0sN+GHGiH0RhP9V05jLiSoKT4K+EEgXPIc/+60wFU=; b=d6RVtrrAKNBoaao11aiyoumnoT/LiZIJmSZ6qLBvF5HrlP+k71V0ntcwAIX08m+3RytC95 iSnbl97+ibOCT6Anfc2PNu9PXrwPeMrXpuRiZZb4LcA7llESKhwtpSGWyEBZpUt1LA89KM 8NjrFF6LAn1VRztJml2dVkQKYDmKPc+YSMJhtPUVgakTrEC2xcJ2i0VZp9VHpc9cxvPuWm DrD0u4xUIkkls6SlKUy1QC2wHuBuHDsFPKmIPvJ7e3hJ5y1BUW6a8PxyJpPDWqWVd/LcoK /CnBwmY/+s2t9N3g8/KfssoruD21DjwNOCT7FmLKIxKP8Sgf9I2/XEIJupmwOw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659476721; a=rsa-sha256; cv=none; b=CtLMqWl6wXzRsRUhgTJ6n/xAzA+RYgoZAqGjruTLX03SCyBUKkU5JZ9wzStC5MZUbQbR7/ 2SH0j+7HYlVVC8JVEuzTZH+cD//0v5tWbVNg25fdGpsb/jhWi4ylZ50gZuIGSU9GhHOEij SIjtpaug+ms2xUxEizyxFuX8bQ7lfOTIeXrG9EDTzPakPWfTu28RilvhOQaToNokLQRJ5e BTH/8RDMeSIqubksnyPi7/02YjW57UbAhex3Kj7vBsw0j5Jzlis6pHBNCSwDyfn07R4f5K BgyaIYo2EbixS4e2xAsMZXQ/ft3TX1QRsP78dXzSwK7zUgKp3SEpmIXbHsAmJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=YngCfDmd; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.82 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=YngCfDmd; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 883083CFA8 X-Spam-Score: -2.82 X-Migadu-Scanner: scn0.migadu.com X-TUID: Q9Gx2xUFjPZJ * guix/read-print.scm (, blank?): New record type. (): Redefine using the record interface. (read-with-comments, pretty-print-with-comments): Change some uses of 'comment?' to 'blank?'. * guix/scripts/style.scm (simplify-inputs)[simplify-expressions]: Use 'blank?' instead of 'comment?'. --- guix/read-print.scm | 37 ++++++++++++++++++++++++++----------- guix/scripts/style.scm | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/guix/read-print.scm b/guix/read-print.scm index 5281878504..732d0dc1f8 100644 --- a/guix/read-print.scm +++ b/guix/read-print.scm @@ -22,13 +22,14 @@ (define-module (guix read-print) #:use-module (ice-9 rdelim) #:use-module (ice-9 vlist) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-9) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:export (pretty-print-with-comments read-with-comments object->string* + blank? + comment comment? comment->string @@ -47,12 +48,26 @@ (define-module (guix read-print) ;;; Comment-preserving reader. ;;; -;; A comment. -(define-record-type - (string->comment str margin?) - comment? - (str comment->string) - (margin? comment-margin?)) +(define + ;; The parent class for "blanks". + (make-record-type ' '() + (lambda (obj port) + (format port "#" + (number->string (object-address obj) 16))) + #:extensible? #t)) + +(define blank? (record-predicate )) + +(define + ;; Comments. + (make-record-type ' '(str margin?) + #:parent + #:extensible? #f)) + +(define comment? (record-predicate )) +(define string->comment (record-type-constructor )) +(define comment->string (record-accessor 'str)) +(define comment-margin? (record-accessor 'margin?)) (define* (comment str #:optional margin?) "Return a new comment made from STR. When MARGIN? is true, return a margin @@ -66,7 +81,7 @@ (define* (comment str #:optional margin?) (string->comment str margin?)) (define (read-with-comments port) - "Like 'read', but include objects when they're encountered." + "Like 'read', but include objects when they're encountered." ;; Note: Instead of implementing this functionality in 'read' proper, which ;; is the best approach long-term, this code is a layer on top of 'read', ;; such that we don't have to rely on a specific Guile version. @@ -99,7 +114,7 @@ (define (reverse/dot lst) (let/ec return (let liip ((lst '())) (liip (cons (loop (match lst - (((? comment?) . _) #t) + (((? blank?) . _) #t) (_ #f)) (lambda () (return (reverse/dot lst)))) @@ -327,7 +342,7 @@ (define newline? (and (keyword? item) (not (eq? item #:allow-other-keys)))) (not first?) (not delimited?) - (not (comment? item)))) + (not (blank? item)))) (when newline? (newline port) @@ -335,7 +350,7 @@ (define newline? (let ((column (if newline? indent column))) (print tail (keyword? item) ;keep #:key value next to one another - (comment? item) + (blank? item) (loop indent column (or newline? delimited?) context diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index e2530e80c0..5c0ecc0896 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -108,7 +108,7 @@ (define (simplify-expressions exp inputs return) (exp exp) (inputs inputs)) (match exp - (((? comment? head) . rest) + (((? blank? head) . rest) (loop (cons head result) rest inputs)) ((head . rest) (match inputs -- 2.37.1