From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0AicIR/8m2J9gwEAbAwnHQ (envelope-from ) for ; Sun, 05 Jun 2022 02:43:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id wBynIR/8m2IwWAAA9RJhRA (envelope-from ) for ; Sun, 05 Jun 2022 02:43:11 +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 4B5DA106A9 for ; Sun, 5 Jun 2022 02:43:11 +0200 (CEST) Received: from localhost ([::1]:49276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxeMH-0002BD-WE for larch@yhetil.org; Sat, 04 Jun 2022 20:43:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxeMA-0002B3-Bq for guix-patches@gnu.org; Sat, 04 Jun 2022 20:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxeMA-0008LL-3C for guix-patches@gnu.org; Sat, 04 Jun 2022 20:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nxeM9-00020D-V5 for guix-patches@gnu.org; Sat, 04 Jun 2022 20:43: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: Sun, 05 Jun 2022 00:43: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.16543897657675 (code B ref 55420); Sun, 05 Jun 2022 00:43:01 +0000 Received: (at 55420) by debbugs.gnu.org; 5 Jun 2022 00:42:45 +0000 Received: from localhost ([127.0.0.1]:59809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxeLt-0001zi-68 for submit@debbugs.gnu.org; Sat, 04 Jun 2022 20:42:45 -0400 Received: from mout01.posteo.de ([185.67.36.65]:40567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxeLr-0001zU-CD for 55420@debbugs.gnu.org; Sat, 04 Jun 2022 20:42:44 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 4BE9C240027 for <55420@debbugs.gnu.org>; Sun, 5 Jun 2022 02:42:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1654389757; bh=nma+Bhc72gT9U4UfoaTkNnjeiQHmGYP08R1saaWkjUs=; h=From:To:Cc:Subject:Date:From; b=rWmuYzsFgj4JG0XKVBAmLQ9mjj/tB8Ap8+IhkYS0dJ7QVyxHX5POkulwcMaFUQRh/ A3o0WsWoGw0eVxJpltPDPM+zyRK2tBBVOTfJAQv8YzOVAZR/rBKYK43CwAuFE/PWXx UHXKvj8742zHwYmjOdvL3P97t006w57vVViCOyVAdOy1TSa1d5RiJhqMeJ1mmZKr8C wXqU5Az2NjbBAYsRI0mpX7wwtuVG03TzkbH9j85P+42aIg3uRbQ9YO5zguotooLugX Ge44v6L/ocMuxk9KIzDsPjPak4pdoxgDEFkGCc3I5KSTR4lDaVPZTaqSw4ImiMqzn0 0BpcjAKIWsx8Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LFyWc18vnz6tmh; Sun, 5 Jun 2022 02:42:35 +0200 (CEST) From: Fredrik Salomonsson In-Reply-To: <87fsknp4bu.fsf@gnu.org> References: <20220514230017.27372-1-plattfot@posteo.net> <20220514230508.27885-1-plattfot@posteo.net> <87ee08t8z5.fsf_-_@gnu.org> <87zgivai89.fsf@d2.com> <87fsknp4bu.fsf@gnu.org> Date: Sun, 05 Jun 2022 00:42:34 +0000 Message-ID: <87h750rldx.fsf@posteo.net> 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=1654389791; 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=LMrGeTo3zcqe2AL+brYLfceksiuKy1OOos7JbNV4t4Y=; b=MUDvnlz4hX6W7viiibzQSfgS8W5tXUlQkNcBGAl/607hUuG84GdYWa4fUEhPVV/iN63ukq TCvn5u3dqIetpfzRs61ShO0/U/iO774oCgUTPgmDQ51QJzxOxcEgRSjrEaHNnz/5Dli/NG ek5RcMBkT6EUXqjl8EZ3ThhjFWb0l2qs2u9TyYz5F7X4DAekZlcO7I5wmJ57zuiI/mNCtl PPl6xHJvoyvt0BYSv+rqZbT/XO2YGsYS8cD55nLv5H6JotAK5uXIS/0MAj/uRXGKiZWc8g a3J5hdrSDDMdtxo0ewucMJl6kFIMusJboXehF64zAgXyzq8oszckdkMkLvOvsg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654389791; a=rsa-sha256; cv=none; b=K5m4gzP9zlJGk2mDprbOqPGZLHmDLI8EAIiKg0peNAulu3OddrJETW1z2/yaXxoD5ANgEt qlzsHG0KYdD4AFG0XUiTCpTsh19TBfiHinHGjtLbNA5Au6OJCsOofdPC374YNVTolZJxS+ Sopgwy2ZsLHSw8EOP/bm9GGn78fDGYzf+/1SXtTnC/0K5vGchT/mCO3vOHZyWeraTQDfq3 SHqwPSC1+KXgHvafy36jKw8SusKQppcjDzw6H6xv1eCkz5JEHt0OivXeRkvur9CUIbE4x+ AE+Q7ZVKMFiFQmddqxIuMBvkJmiZ/bOkmNj2o9lYZnKmtLuBUu4b0ahfAsc4Kg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=rWmuYzsF; 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: 6.98 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=rWmuYzsF; 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: 4B5DA106A9 X-Spam-Score: 6.98 X-Migadu-Scanner: scn0.migadu.com X-TUID: RWGyv3zVA3B0 Hi Ludo, Ludovic Court=C3=A8s writes: > Hi, > > Fredrik Salomonsson skribis: > >> 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=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)) > > Unfortunately =E2=80=98open-pipe*=E2=80=99 is not smart enough to redirec= t stderr to a > non-file port (a string port in this case). > > One way around it would be to merge stdout and stderr, like so: > > (parameterize ((current-error-port (current-output-port))) > (open-pipe* =E2=80=A6)) > > but then you get both on the same stream, which could be a problem for > instance if Emacs emits warnings and such. > > You could work around it by establishing a second pipe: > > (match (pipe) > ((stderr-input . stderr-output) > (parameterize ((current-error-port stderr-output)) > (open-pipe* =E2=80=A6)))) > > Here you should be able to read, in the parent process, from > =E2=80=98stderr-input=E2=80=99. > > Another option is to not try to capture stderr: after all, that=E2=80=99l= l get > printed on the screen anyway. I just sent in v2 of the patches. Changes are: - emacs-batch-script will now raise an &emacs-batch-error if emacs batch script fails. I opted to capture the stderr and package that up in the condition. Thank you for the pointers! I removed the expression slot I had in my prototype. It felt redundant, emacs error message should be enough. - tests/build-emacs-utils.scm: I added tests for the two new procedures. It was good that I added the tests as I had missed to use (srfi srfi-34) in build/emacs-utils.scm during my prototyping and that generated the cryptic error: Wrong type (expecting exact integer): #<&emacs-batch-error=E2=80=A6> Took me a while to figure that one out. But now all is good. The tests are passing. Thanks again. --=20 s/Fred[re]+i[ck]+/Fredrik/g