From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kPnfMahw9V+4ZAAA0tVLHw (envelope-from ) for ; Wed, 06 Jan 2021 08:11:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wOK7Lahw9V+ibwAA1q6Kng (envelope-from ) for ; Wed, 06 Jan 2021 08:11:20 +0000 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 8DDAD940414 for ; Wed, 6 Jan 2021 08:11:20 +0000 (UTC) Received: from localhost ([::1]:58438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kx3uZ-0006C8-DF for larch@yhetil.org; Wed, 06 Jan 2021 03:11:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx3uQ-0006Bx-3D for guix-devel@gnu.org; Wed, 06 Jan 2021 03:11:10 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:60744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx3uM-00009g-KK for guix-devel@gnu.org; Wed, 06 Jan 2021 03:11:09 -0500 Received: from nijino.local (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4D9hrg1hD4z1LBF8; Wed, 6 Jan 2021 09:10:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4D9hrg1hD4z1LBF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609920659; bh=JYPYNJ7D65xUoRYcxstcFnUJpf5IHvRCt/RwJni/04E=; h=Subject:From:To:Cc:Date:In-Reply-To:From; b=MPTQ0YGk8Ih1TeRR8falZjfFC6W2REUabPHx/sFyj0dGPXCFY8eA6U0gZqElx/Bx2 YL7ixe9ohRlyJiPEop65EhzmjXvcrV//Nl6Z9Wiywp+BzApPAc/VHQxp4z3LBY36C3 5Bps6vgxhmD0CUQJXQ9MVwI+1lIOAipozrC7zYIM= Message-ID: <4bc2714885700ada6c72e19771789fda0ee634be.camel@student.tugraz.at> Subject: [Outreachy] Strategy to implement guix git log --pretty= From: Leo Prikler To: magalilemes00@gmail.com Date: Wed, 06 Jan 2021 09:10:58 +0100 In-Reply-To: c2de6cf1-b8af-5008-ebbd-d1c587ce1064@gmail.com Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 Received-SPF: pass client-ip=129.27.2.202; envelope-from=leo.prikler@student.tugraz.at; helo=mailrelay.tugraz.at X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=tugraz.at header.s=mailrelay header.b=MPTQ0YGk; dmarc=pass (policy=none) header.from=student.tugraz.at; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 8DDAD940414 X-Spam-Score: -3.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: NUtgg1lHB2mv Hello Magali, have you looked into (ice-9 peg)? An easy pretty grammar, that would catch your example would be the following: --8<---------------cut here---------------start------------->8--- (use-modules (ice-9 peg)) (define-peg-pattern commit-hash all (ignore "%h")) (define-peg-pattern subject all (ignore "%s")) (define-peg-pattern pretty body (* (or commit-hash subject (* (and (not-followed-by "%") peg-any))))) (peg:tree (match-pattern pretty "%h %s")) ;; => (commit-hash " " subject) --8<---------------cut here---------------end--------------->8--- Of course you have to extend it with all the other percent escapes. Then you simply map a match-lambda over the "tree", which if given a symbol returns a string containng the actual value and if given a string returns the string unchanged. Finally you string-concatenate them. Naturally, you have to check whether the string was valid as well -- a lone "%" should not match, for instance. Cheers, Leo