From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id QDzfHDPSJmWcSwAAauVa8A:P1 (envelope-from ) for ; Wed, 11 Oct 2023 18:49:55 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QDzfHDPSJmWcSwAAauVa8A (envelope-from ) for ; Wed, 11 Oct 2023 18:49:55 +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 7BF27D2F4 for ; Wed, 11 Oct 2023 18:49:54 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=IsKlXDbe; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697042995; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=WrTRrGN5J87hU86tkml5ZTqURhc1d4j7xJpQ3mZLtZg=; b=hL+704AC3SMP1gKFLnoKlmI8oBV0CD5Z77zPu0c+GgpxNxEQubPbaI9JsXKnO+or3RCnGH P547nTvKF1pSgUfqk3kQA5byaimKVsk8vViDPy1Tp8bsaXaKA27yhG3PtzM/1SscNccLsF 2844IcnOos4wc7LKDf0UzqwZJNl2qxQ6SBLxEOeA0ORPyeUlTjJkGJr8iIfIlr+TTsPtqT LXcNaJb64lDjHSbh2k5nE+E/FJltvAKw9As2el+8LeDDRDRt/pvi88lN4VUIwsx7RuCFH3 ifQt8qFrOWTSMmAdjcnmSWb41pHXUI40M0yFjqVGkafQ/JDBdTUu1neIGpDcXQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697042995; a=rsa-sha256; cv=none; b=jgTPDCqnOclNSVonHVJmCT+i8cSp0GAF/L5mbG5srYfPnoE2XpFJcuPhQj9KspUf757vy/ O6jWxgWq3GQ2HOj+ljyV7pSLgCUYDFlWkewEEYxEApDRY1J4KMCql1JZZd2WTmj3dJ3bNb w9O9s36Ynq6pHjmu53tKg9nlC5bzJW+QQQLKTiz+YfAKGwwx8T1MKU22R3x7MIvtZ79nGS IVKE7vcuipoJkONRbddyBZIs9yW9plwkWlIDBwDcmwDRQBbWae2D7LrQYL5Yn/YTXYnJ4P 3QkOfpRcMfpHUV6vs4hiDpK79LNFLRzj5w5XsoJPLTDYiDHqFeKKTe84mBvQ5A== 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=IsKlXDbe; 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"; dmarc=pass (policy=none) header.from=gnu.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqcOz-0007GR-Eb; Wed, 11 Oct 2023 12:49:41 -0400 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 1qqcOy-0007G2-Bd for guix-patches@gnu.org; Wed, 11 Oct 2023 12:49:40 -0400 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 1qqcOy-00007z-3F for guix-patches@gnu.org; Wed, 11 Oct 2023 12:49:40 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qqcPJ-0008As-LV for guix-patches@gnu.org; Wed, 11 Oct 2023 12:50:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64620] [PATCH] gnu: home: Add home-emacs-service-type. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 11 Oct 2023 16:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64620 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: fernseed@fernseed.me Cc: Josselin Poiret , Tobias Geerinckx-Rice , Simon Tournier , paren@disroot.org, Christopher Baines , 64620@debbugs.gnu.org, Andrew Tropin , Ricardo Wurmus , Mathieu Othacehe Received: via spool by 64620-submit@debbugs.gnu.org id=B64620.169704297931379 (code B ref 64620); Wed, 11 Oct 2023 16:50:01 +0000 Received: (at 64620) by debbugs.gnu.org; 11 Oct 2023 16:49:39 +0000 Received: from localhost ([127.0.0.1]:39923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqcOx-0008A3-73 for submit@debbugs.gnu.org; Wed, 11 Oct 2023 12:49:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqcOs-00089f-4b for 64620@debbugs.gnu.org; Wed, 11 Oct 2023 12:49:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qqcOM-0008Uf-KJ; Wed, 11 Oct 2023 12:49:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=WrTRrGN5J87hU86tkml5ZTqURhc1d4j7xJpQ3mZLtZg=; b=IsKlXDbeYVnjVImijP2n 4wIqJoxhoAMKhhY46cTGyZfefFa+xaAys2CaDQpL+lBFMlUisbUA3LMNoO5Hn09bwnSN79csi3aM7 LYsvMARAA8MtqjqXZVvENJqYHOfebf+3/A+gwaONaLXLSnBu35lzHYesNKihaC5UfheAJS7HZsWXg 3L5AsixzroNgP2n9iju8PtE8P5RRva1RH3C4Wh+kQwKGF6+uJermIJ4JQ5xCO0JzJO2Ef2iwaVKnn VJtxzkESU+RvivpCWN5g+XIedLVRSD8n2Hqe2CnOYzF1YxFmrYz7BFSKqNYvOW8YR3D8an37Pu71H Utjf5aT6VfbVVA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <0173e076aafb6ec389a7ebca5d56b7f4e8a02b6e.1689347338.git.fernseed@fernseed.me> (fernseed@fernseed.me's message of "Fri, 14 Jul 2023 11:12:31 -0400") References: <0173e076aafb6ec389a7ebca5d56b7f4e8a02b6e.1689347338.git.fernseed@fernseed.me> Date: Wed, 11 Oct 2023 18:48:59 +0200 Message-ID: <87lec9t890.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -5.40 X-Migadu-Queue-Id: 7BF27D2F4 X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -5.40 X-TUID: xQMInOcJpLSm So, here is a short review of the parts I=E2=80=99m most familiar with. fernseed@fernseed.me skribis: [...] > +(define-module (gnu home services emacs) > + #:use-module (gnu home services) [...] > + #:re-export (blank? > + > + vertical-space > + vertical-space? Why re-export these things from here? Sounds surprising because we=E2=80= =99re in a service module. [...] > +(define* (elisp->file-builder exps #:key (special-forms '())) > + "Return a G-expression that builds a file containing the Elisp > +expressions ( objects or s-expressions) or G-epxressions in list = EXPS. > +See `elisp-file' for a description of SPECIAL-FORMS." [...] > + (with-imported-modules (source-module-closure > + '((guix read-print))) > + (gexp (begin > + (use-modules (guix read-print)) > + (call-with-output-file (ungexp output "out") > + (lambda (port) For clarity/conciseness, you can use #~ and #$ in this code. > +(define-gexp-compiler (elisp-file-compiler (elisp-file ) > + system target) > + (match-record elisp-file > + (name gexp) > + (with-monad %store-monad > + (gexp->derivation name gexp > + #:system system > + #:target target > + #:local-build? #t > + #:substitutable? #f)))) > + > +(define* (elisp-file* name exps #:key (special-forms '())) > + "Return as a monadic value a derivation that builds an Elisp file name= d NAME > +containing the expressions in EXPS, a list of Elisp expression objects or > +G-expressions. > + > +This is the monadic counterpart of `elisp-file', which see for a descrip= tion > +of SPECIAL-FORMS," > + (define builder > + (elisp->file-builder exps > + #:special-forms special-forms)) > + > + (gexp->derivation name builder > + #:local-build? #t > + #:substitutable? #f)) I think you don=E2=80=99t need to fiddle with the monadic interface. I=E2= =80=99d suggest removing the type and gexp compiler and instead defining =E2=80=98elisp-file=E2=80=99 in terms of =E2=80=98computed-file=E2= =80=99. WDYT? > +(define (record-value rec field) > + "Return the value of field named FIELD in record REC." > + ((record-accessor (record-type-descriptor rec) field) rec)) > + > +(define-syntax extend-record > + ;; Extend record ORIGINAL by creating a new copy using CONSTRUCTOR, > + ;; replacing each field specified by ORIG-FIELD with the evaluation of= (PROC > + ;; ORIG-VAL EXT-VALS), where ORIG-VAL is the value of ORIG-FIELD in OR= IGINAL > + ;; and EXT-VALS is the list of values of EXT-FIELD in EXTENSIONS. > + (lambda (s) > + (syntax-case s () > + ((_ constructor original extensions (proc orig-field ext-field) ..= .) > + (with-syntax (((field-specs ...) > + (map > + (lambda (spec) > + (syntax-case spec () > + ((proc orig-field ext-field) > + #'(orig-field > + (apply > + proc > + (list > + (record-value original 'orig-field) I would advice against accessing record fields by name, with run-time field name resolution. The spirit of records, unlike alists, is that there=E2=80=99s a statically-defined mapping of fields to their offsets in the struct; without having access to record accessors, you=E2=80=99re not supposed to be able to access the record (I know Guile has =E2=80=98struct-ref=E2=80=99, =E2=80=98record-accessor=E2=80=99, etc., but these are abstraction-breaking= primitives that should be avoided IMO). How could this code be adjusted accordingly? I guess you=E2=80=99re lookin= g for a way to iterate over fields? > +;;; Elisp reader extension. > +;;; > + > +(eval-when (expand load eval) > + > + (define (read-elisp-extended port) > + (read-with-comments port > + #:blank-line? #f > + #:elisp? #t > + #:unelisp-extensions? #t)) > + > + (define (read-elisp-expression chr port) > + `(elisp ,(read-elisp-extended port))) > + > + (read-hash-extend #\% read-elisp-expression)) I=E2=80=99d lean towards not having a reader extension because they don=E2= =80=99t compose and it=E2=80=99s easy to end up colliding with another, unrelated extension. I think it=E2=80=99s okay if people write: (elisp =E2=80=A6) rather than: #%(=E2=80=A6) It=E2=80=99s also arguably easier to understand for a newcomer. > +++ b/guix/read-print.scm This part is the most =E2=80=9Cproblematic=E2=80=9D for me: I=E2=80=99m alr= eady dissatisfied with the current state of things (the pretty-printer in particular is too complex and hard to work with), and this change brings more complexity and lacks orthogonality. What I=E2=80=99d like to see, ideally, is a clear separation between elisp concerns and Scheme concerns in the reader and in the pretty printer. Probably, a preliminary step (I could look into it) would be to rewrite the pretty printer based on Wadler=E2=80=99s =E2=80=9Cprettier printer=E2= =80=9D paper and/or Shinn=E2=80=99s formatting combinators=C2=B9. WDYT? Thanks, Ludo=E2=80=99. =C2=B9 https://srfi.schemers.org/srfi-159/srfi-159.html