From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 8LLVDoAmmGKGuwAAbAwnHQ (envelope-from ) for ; Thu, 02 Jun 2022 04:54:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ECC8DoAmmGLOLwAAauVa8A (envelope-from ) for ; Thu, 02 Jun 2022 04:54:56 +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 DAC4623E69 for ; Thu, 2 Jun 2022 04:54:55 +0200 (CEST) Received: from localhost ([::1]:42532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwaz8-0007p9-Sl for larch@yhetil.org; Wed, 01 Jun 2022 22:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwayH-0007YH-Te for guix-patches@gnu.org; Wed, 01 Jun 2022 22:54:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwayH-0002Ar-LH for guix-patches@gnu.org; Wed, 01 Jun 2022 22:54:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nwayH-0003SD-Km for guix-patches@gnu.org; Wed, 01 Jun 2022 22:54:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55420] [PATCH 0/2] Add a function to parse emacs elisp's package header Resent-From: Fredrik Salomonsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 02 Jun 2022 02:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55420 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 55420@debbugs.gnu.org Received: via spool by 55420-submit@debbugs.gnu.org id=B55420.165413843413262 (code B ref 55420); Thu, 02 Jun 2022 02:54:01 +0000 Received: (at 55420) by debbugs.gnu.org; 2 Jun 2022 02:53:54 +0000 Received: from localhost ([127.0.0.1]:52273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwayA-0003Rq-0y for submit@debbugs.gnu.org; Wed, 01 Jun 2022 22:53:54 -0400 Received: from mout01.posteo.de ([185.67.36.65]:41079) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nway8-0003Rb-Bt for 55420@debbugs.gnu.org; Wed, 01 Jun 2022 22:53:52 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 58854240026 for <55420@debbugs.gnu.org>; Thu, 2 Jun 2022 04:53:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1654138426; bh=5ZMYTxRibkCvmf7xNATMLXAFRXPHc3ddOGRcu3nvrsw=; h=From:To:Cc:Subject:Date:From; b=DzcatjIZqpBKcEiDtO86i6xoUjL/9l7G3EtWyfyta4stU2P4/sLTP4iADuMJ63sTl KQBVaAWq+kNVU/G6jeqgVs16IIZns+uIkPUihNHKyZuFWB1FzyxhTKz3t4TL5pPQub LVqvQjIul2297jcPvBKIsZtI36Amrw9k8eajcXOnkPeCoKtUpe03SG/xbxR0mYvuVj LPOzYgo4vIosZESJnox+qZ1DrE7GP+QFxUSppdY/brbTsp0KFhQiDaTfKABcIIa1Gg 7p7eAFnjn0uRX3QbL8MI4kfSDpr/BxvgkiqV6JXuQbp8fs1brmejh3jwZNgsu72sK9 j3cx+carCo9zQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LD9ZK1ccsz6tmJ; Thu, 2 Jun 2022 04:53:44 +0200 (CEST) From: Fredrik Salomonsson In-Reply-To: <87ee08t8z5.fsf_-_@gnu.org> References: <20220514230017.27372-1-plattfot@posteo.net> <20220514230508.27885-1-plattfot@posteo.net> <87ee08t8z5.fsf_-_@gnu.org> Date: Thu, 02 Jun 2022 02:53:42 +0000 Message-ID: <87zgivai89.fsf@d2.com> 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" 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=1654138496; 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=2lcIt0a31WoOerfl+aq5CRVgYoyE0MQQ/ol8Cw2aWdI=; b=JljQaYPJcDiCW2M8D5eT2waVQpOgdrROuWYH3WRH7fRm5CQctVG4Vmuh3QQEua5FZUJU2o z10PmXNYABOj2huytxJf+UKQg+4gFqlEOq/PLMZmqkLT9fGOOzRnCOvjul8kn+XwNjduvE 7jMyoAf8cMeqyw8AAWBlDVOVeKMM3PrOQcYbVYn4IPbFAoeZ1cov+UdJFr6e4S0qQJ2JV1 8kJEEAvcGa7OsNUAMibVoUapWFbbvbgFLZlGB+Pic1AQblFJ4WMTasHBq1Y4iuTFHr7U69 mvfQH5yXeqOfv1qlh89XkmfEmDcW71+3uM7FJPjeLY+2tzHAPC9QqlOsUaTNsg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654138496; a=rsa-sha256; cv=none; b=dI8JdAFCOs4MBscGWy9s2nFSFdo2gj/2uRoBi/wsFx4USX+4XdlzhRhIegDf+49GPCvy5u gkJOvX2ECqsH9jyfoorqo4F+dIq5gH0Wco+Oi5n3dW4GmNlNfhYjrprqrs8ifQNmd5480R 83HWHv1UW3UO3nirxCqjdEQoryHcxMYbYL0PlTJq/c3tu6SZCXGcWuz9IQ2iakijGJoQv4 wQCuNOPDUc9XumNl4holgKtSkwiqb5D3C1FklqntNFfksIp5ETvC2jvFpf4xDLshtDh6mW MuaZ8iBzcZQZH8z+Q5/Dj3DIsVGmn+76dnhWlH2LtyVfxF5668ul85btC2B2Gg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=DzcatjIZ; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); 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: 5.17 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=DzcatjIZ; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); 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: DAC4623E69 X-Spam-Score: 5.17 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7ydMOUETEzlO Hi Ludo, Ludovic Court=C3=A8s writes: > Hi Fredrik, > > The patches LGTM modulo cosmetic issues: > > Fredrik Salomonsson skribis: > >> * guix/build/emacs-utils.scm (emacs-batch-script): New procedure. > > [...] > >> +(define (emacs-batch-script expr) >> + "Execute the Elisp code EXPR in Emacs batch mode and return output." >> + (call-with-port >> + (open-pipe* >> + OPEN_READ >> + (%emacs) "--quick" "--batch" >> + (string-append "--eval=3D" (expr->string expr))) >> + read-string)) > > I suggest something like: > > (let* ((pipe (open-pipe* =E2=80=A6)) > (output (read-string pipe)) > (status (close-pipe pipe))) > (unless (zero? status) > ;; Use SRFI-34 + either a &message condition or (better) > ;; a dedicate SRFI-35 condition type for the error. > (raise (condition =E2=80=A6))) > output) > > That way, execution failures would be caught and reported. Thank you for the feedback. I update the procedure to use a dedicated SRFI-35 condition type. But I cannot figure out how to capture the error message from emacs, as I want the condition type to contain both the expression as well as the error you get from emacs. Here is what I have so far: (define-condition-type &emacs-batch-error &error emacs-batch-error? (expression emacs-batch-error-expression) (message emacs-batch-error-message)) =20=20=20=20 (define (emacs-batch-script expr) "Execute the Elisp code EXPR in Emacs batch mode and return output." (let* ((error-pipe (open-output-string)) (pipe (with-error-to-port error-pipe (lambda () (open-pipe* OPEN_READ (%emacs) "--quick" "--batch" (string-append "--eval=3D" (expr->string expr)))))) (output (read-string pipe)) (error (get-output-string error-pipe)) (status (close-pipe pipe))) (unless (zero? status) (raise (condition (&emacs-batch-error (expression expr) (message error))))) output)) Here is the output when I test it out in the guix repl: ---------------------------------------------------------------------------= ----- scheme@(guix-user)> (use-modules (guix build emacs-utils)) (use-modules (guix build emacs-utils)) scheme@(guix-user)> (emacs-batch-script '(prog (princ "hello"))) (emacs-batch-script '(prog (princ "hello"))) ice-9/boot-9.scm:1685:16: In procedure raise-exception: Wrong type (expecting exact integer): #<&emacs-batch-error expression: (pro= g (princ "hello")) message: ""> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guix-user) [1]>=20 ---------------------------------------------------------------------------= ----- Note the message is empty in #<&emacs-batch-error=E2=80=A6>. It should cont= ain: Debugger entered--Lisp error: (void-function prog) (prog (princ "hello")) command-line-1(("--eval=3D(prog (princ \"hello\"))")) command-line() normal-top-level() Any idea what I'm doing wrong? Thanks --=20 s/Fred[re]+i[ck]+/Fredrik/g