From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id OKo3CbcJnWLPNQAAbAwnHQ (envelope-from ) for ; Sun, 05 Jun 2022 21:53:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id WP8hCbcJnWJnyAAAauVa8A (envelope-from ) for ; Sun, 05 Jun 2022 21:53:27 +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 AE0121908 for ; Sun, 5 Jun 2022 21:53:26 +0200 (CEST) Received: from localhost ([::1]:51968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxwJR-0003pO-52 for larch@yhetil.org; Sun, 05 Jun 2022 15:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxwJ4-0003o9-V9 for guix-patches@gnu.org; Sun, 05 Jun 2022 15:53:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39669) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxwJ4-0003n7-MD for guix-patches@gnu.org; Sun, 05 Jun 2022 15:53:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nxwJ4-0007Lt-L5 for guix-patches@gnu.org; Sun, 05 Jun 2022 15:53:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55420] [PATCH v3 2/2] guix: emacs-utils: Add emacs-header-parse. Resent-From: Fredrik Salomonsson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 05 Jun 2022 19:53:02 +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: 55420@debbugs.gnu.org Cc: Fredrik Salomonsson Received: via spool by 55420-submit@debbugs.gnu.org id=B55420.165445872728186 (code B ref 55420); Sun, 05 Jun 2022 19:53:02 +0000 Received: (at 55420) by debbugs.gnu.org; 5 Jun 2022 19:52:07 +0000 Received: from localhost ([127.0.0.1]:33565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxwIB-0007KY-1s for submit@debbugs.gnu.org; Sun, 05 Jun 2022 15:52:07 -0400 Received: from mout02.posteo.de ([185.67.36.66]:44129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxwI8-0007Jr-GI for 55420@debbugs.gnu.org; Sun, 05 Jun 2022 15:52:06 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 4BD52240108 for <55420@debbugs.gnu.org>; Sun, 5 Jun 2022 21:51:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1654458718; bh=m6E9CYvuzXSeGSIOwwmLxc66Q6NBctPOrCvzoGgZAgM=; h=From:To:Cc:Subject:Date:From; b=UlAzeJEdOkbG97qOoMh97KLGBXYtstHNxv4i1FtRK4+G437y+3e/+GSS2yw1Hnajg yP+Uu18BNo5BrcSNFnXzqs4uJGykaR42EmGMaGgSdg7iY+FOiIjg2u/pooWLY4nMA+ iZPE/mWY8DjiKahvn3oo5Hz0M5KofDy7kZtmpGPRbZ3pXzkbwANctZt/5aqhV8+nJx M64n3b5pxHglpcRna39LcmVTkFSmGaohjDNExsRX/JBXJa0D6ReCmX082xcP+FVUGW JzxNNOk+WQdFyT7s3wpoh2rK2BV4fBi87Kxi2ySgGUWJ5PesraQoxDSSHuYNxV8FIQ AT5pgM0wJQ1tA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LGS1n2X5Wz6tmp; Sun, 5 Jun 2022 21:51:57 +0200 (CEST) From: Fredrik Salomonsson Date: Sun, 5 Jun 2022 19:51:43 +0000 Message-Id: <20220605195143.23591-2-plattfot@posteo.net> In-Reply-To: <20220605195143.23591-1-plattfot@posteo.net> References: <20220605195143.23591-1-plattfot@posteo.net> 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=1654458806; 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=CH6qvluRhMcBk0XlU9z0PUSyvlDO9auVTMhlVxR847w=; b=uYngJRcmjx6CGddXISUp/S+HY/CKdC6UaHdlZdhe3/nCADyEvpc4iIbIlxcaCY8x2Gq74m pHFumiu5zpRFKTkKJl1iguQem7NwJYpJdKaij7YMslcabOdGvlaieosnumwEQcjajsJoSf AqBd1Y0UN+zoA6klNXYjeHd5vsx03apdo+9L2bh1aQCdOV5vdU3UafqMIVXwswhwn0MjgS 1LBYEQAwcsR58xQQPmDMzsM5uornfLfZ/9/ks+St/l9yjOkjG/cYTsiO8IbXnOe1btS63l WIxlnEGTJ9w98MQNrzfTA4jrUG750XS2v9LKj1VmZwg0sJrf8hSwU3ouOIFq/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654458806; a=rsa-sha256; cv=none; b=aIHfFTgtUGvf7WQ9jX9RRfvUjOaCJkPWD4HBuMl3OlLgzpU+sx6FY82anIaL2A540fkUsU +mvgfMKAJm9qw/YbNktjCz70Z7toywe6KUt/xCNB7THhQS+xaBlFUdygEwlzpscGQKthOF hNbtvIAWOubZE6HM7qJWlYr4TRAB5gNgvHqeV1ns7GEuMsSDJnVWmP/OfOuybuRn3+TEcc jlQ9s+6GadwQu6A/vFj9H2J0fVtyIcVGPBZzn+SZoRlQpWW9N7hKmEGRWPjKNf2dlTJg1A Qa0cqyDRJWrlAoceCBIn9HEufpTL3bmZqY2sz+CWujWqM6GLwLpddT4CZE4hOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=UlAzeJEd; 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: 8.79 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=UlAzeJEd; 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: AE0121908 X-Spam-Score: 8.79 X-Migadu-Spam: Yes X-Migadu-Scanner: scn1.migadu.com X-TUID: wDPoz/9+QFAh * guix/build/emacs-utils.scm (emacs-header-parse): New procedure. * tests/build-emacs-utils.scm ("emacs-header-parse: fetch version", "emacs-header-parse: fetch keywords", "emacs-header-parse: fetch nonexistent author"): New tests. --- guix/build/emacs-utils.scm | 9 +++++++++ tests/build-emacs-utils.scm | 27 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm index 1684bf3262..8ee547f2b3 100644 --- a/guix/build/emacs-utils.scm +++ b/guix/build/emacs-utils.scm @@ -38,6 +38,7 @@ (define-module (guix build emacs-utils) emacs-generate-autoloads emacs-byte-compile-directory + emacs-header-parse as-display emacs-substitute-sexps @@ -114,6 +115,14 @@ (define* (emacs-byte-compile-directory dir) (byte-recompile-directory (file-name-as-directory ,dir) 0 1)))) (emacs-batch-eval expr))) +(define (emacs-header-parse section file) + "Parse the header SECTION in FILE and return it as a string." + (emacs-batch-script + `(progn + (require 'lisp-mnt) + (find-file ,file) + (princ (lm-header ,section))))) + (define as-display ;syntactic keyword for 'emacs-substitute-sexps' '(as display)) diff --git a/tests/build-emacs-utils.scm b/tests/build-emacs-utils.scm index 27cff46c38..081032285a 100644 --- a/tests/build-emacs-utils.scm +++ b/tests/build-emacs-utils.scm @@ -28,7 +28,7 @@ (define-module (test build-emacs-utils) (test-begin "build-emacs-utils") ;; Only run the following tests if emacs is present. -(test-skip (if (which "emacs") 0 2)) +(test-skip (if (which "emacs") 0 5)) (test-equal "emacs-batch-script: print foo from emacs" "foo" @@ -40,4 +40,29 @@ (define-module (test build-emacs-utils) "Lisp error: (wrong-type-argument numberp \"three\")"))) (emacs-batch-script '(mapcar 'number-to-string (list 1 2 "three"))))) +(call-with-temporary-directory + (lambda (directory) + (let ((mock-elisp-file (string-append directory "/foo.el"))) + (call-with-output-file mock-elisp-file + (lambda (port) + (display ";;; foo --- mock emacs package -*- lexical-binding: t -*- + +;; Created: 4 Jun 2022 +;; Keywords: lisp test +;; Version: 1.0.0 +;;; Commentary: +;;; Code: +;;; foo.el ends here +" + port))) + (test-equal "emacs-header-parse: fetch version" + "1.0.0" + (emacs-header-parse "version" mock-elisp-file)) + (test-equal "emacs-header-parse: fetch keywords" + "lisp test" + (emacs-header-parse "keywords" mock-elisp-file)) + (test-equal "emacs-header-parse: fetch nonexistent author" + "nil" + (emacs-header-parse "author" mock-elisp-file))))) + (test-end "build-emacs-utils") -- 2.36.1