From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iJLDF3HMmmBTKAEAgWs5BA (envelope-from ) for ; Tue, 11 May 2021 20:26:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 2CZSE3HMmmDeeAAAB5/wlQ (envelope-from ) for ; Tue, 11 May 2021 18:26:57 +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 93D75175CE for ; Tue, 11 May 2021 20:26:56 +0200 (CEST) Received: from localhost ([::1]:52182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgX5q-0008Io-EV for larch@yhetil.org; Tue, 11 May 2021 14:26:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgX4Z-0008FS-G6 for emacs-orgmode@gnu.org; Tue, 11 May 2021 14:25:36 -0400 Received: from mout01.posteo.de ([185.67.36.65]:35075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgX4U-00048R-Hw for emacs-orgmode@gnu.org; Tue, 11 May 2021 14:25:35 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 044FA240029 for ; Tue, 11 May 2021 20:25:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1620757527; bh=iGujMn3kXLHkbIRUljZMKY54kb5fij1cj4AnTkBuBq8=; h=From:To:Cc:Subject:Date:From; b=d8wnQOm0bCQ4fX6hnOsyBX6NIZsb0mB+me9N2PObWS1ljAezlQgtKM/cZJ8k4YEUA 5wpniksvKbivs62DWHNaXsDMzYQvGL3QtiqsuPYvwsyteJ4UKDFCjwCHjXLJixb4EP DgMEW1giUA49mmnavIvO2xBE/l0yVrzD+t8jD5OF0p50laQTGBAHbQKUJaDy+E/DxL 7wfPOjI9kL1if6kwc1qITeErU0WJQloOEEBGNmCVUIIrMYNFGDSeeUNDTJ1kTLiSIN z9EmfuvM5fNZqC/UUHtqYeDD3cTjQjV/drRtIx/mlwZwNuWkeWQUsyRsvd9HI8haf9 ndoE+AQrVZS+A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FfmYy1XCWz6tmJ; Tue, 11 May 2021 20:25:25 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Eric S Fraga Subject: Re: [PATCH] Possibility of using alternative separators in macros References: <87wnsjx5rs.fsf@posteo.net> <87r1id7cwb.fsf@ucl.ac.uk> <8735ut8d2c.fsf@posteo.net> <87im3prvz8.fsf@ucl.ac.uk> Date: Tue, 11 May 2021 18:25:24 +0000 In-Reply-To: <87im3prvz8.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Tue, 11 May 2021 19:00:59 +0100") Message-ID: <87h7j95drf.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620757616; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sRT9fiPpar6JE5a0bfoYzAKpZRk0fMW9hIbawLqKoBE=; b=hLJOtNkS5peeviXwuZyaTnpwfqvOWxug72c1jtsZAU1EFHVLHdtNBX6rrGA2mFjBHKHNE+ IBE2kgG1nAq1eLyc1XpN2oj9XcywXRrI6SEuhPGBvVVEW61lYJl2RhUhUbZvufIFhenyKW UQv7ZGON0y5RCScLjWWNIm6/gserhSL1eS4U1ILfY6irZqbdq0qtm9T3RX+iuXZLHr6eu3 wtv9lJs+9hn79BjuFLexOO9iS6/zPpw7vhdliZr4frtIHeYCjQvkJqWP7wagKUHp17HyC4 uPiy+7TdsC1zrmKUbzZlof7BDrqrdr7FQroDIzz9Xc34h3YJe7E7BD4i5+CvAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620757616; a=rsa-sha256; cv=none; b=lzSsCC3PdCZRa1jA6lPCzFTxkwjcDgT0fb3D1iETwR5c7ODv82mJzHcS1wOyfie4Sh5P6t AkkBCcj5u47cM3/zOKy5yyVGVs1l2QbouuNZQoTbqClOXkZZUspOnnjyAMQ6m147+pAXsn GCIbxh9XdDQL0aAeJFFA9XTOiS896sfrf6UB8qI0KmX2ToZTrRD3KlNZwRajlnA7Siyakx HDjfr9RzaW1h+Fipk9OgMysvSabUMorOHr8vPt/kJcx/gK0wxTC2SdtBnUlBTMJVr4LPil LIqoAMzhZMvLL8VeTdDXdiLYXCAYXA6B/jD4U03ZlXxf01p5HnktfiuGMStTFw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=d8wnQOm0; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.15 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=d8wnQOm0; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 93D75175CE X-Spam-Score: -3.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: VQrCBh7Aw+x4 --=-=-= Content-Type: text/plain Here is the fixed version of the patch. Best regards, Juan Manuel Eric S Fraga writes: > Could you create a new patch so I can try this easily? > > gracias, > eric --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Alternative-args-separator-for-replacement-macros_fixed.patch Content-Transfer-Encoding: quoted-printable >From 4aae61c3600fba136dfa101d54011c0aef9169a3 Mon Sep 17 00:00:00 2001 From: Juan Manuel Mac=C3=ADas Date: Tue, 11 May 2021 18:41:34 +0200 Subject: [PATCH] Alternative args separator for replacement macros --- lisp/org-element.el | 11 ++++++++--- lisp/org-macro.el | 9 +++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index a675bf512..da4035689 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3279,21 +3279,25 @@ CONTENTS is the contents of the object, or nil." "Parse macro at point, if any. =20 When at a macro, return a list whose car is `macro' and cdr -a plist with `:key', `:args', `:begin', `:end', `:value' and +a plist with `:key', `:args', `:begin', `:end', `:sep', `:value' and `:post-blank' as keywords. Otherwise, return nil. =20 Assume point is at the macro." (save-excursion - (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))= \\)?}}}") - (let ((begin (point)) + (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\([^a-zA-Z\s()]*[^-= a-zA-Z0-9_\s]*\\)\\((\\([^\000]*?\\))\\)?}}}") + (let* ((begin (point)) (key (downcase (match-string-no-properties 1))) (value (match-string-no-properties 0)) (post-blank (progn (goto-char (match-end 0)) (skip-chars-forward " \t"))) (end (point)) + (sep (if (not (equal (match-string-no-properties 2) "")) + (match-string-no-properties 2) + ",")) (args (pcase (match-string-no-properties 3) (`nil nil) (a (org-macro-extract-arguments + sep (replace-regexp-in-string "[ \t\r\n]+" " " (org-trim a))))))) (list 'macro @@ -3302,6 +3306,7 @@ Assume point is at the macro." :args args :begin begin :end end + :sep sep :post-blank post-blank)))))) =20 (defun org-element-macro-interpreter (macro _) diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 29c403658..e047cd78e 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -294,20 +294,21 @@ of `org-macro-extract-arguments'." nil t) s))))) =20 -(defun org-macro-extract-arguments (s) +(defun org-macro-extract-arguments (sep s) "Extract macro arguments from string S. S is a string containing comma separated values properly escaped. -Return a list of arguments, as strings. This is the opposite of +SEP is the character used to separate arguments. Return a list +of arguments, as strings. This is the opposite of `org-macro-escape-arguments'." ;; Do not use `org-split-string' since empty strings are ;; meaningful here. (split-string (replace-regexp-in-string - "\\(\\\\*\\)," + (format "\\(\\\\*\\)%s" sep) (lambda (str) (let ((len (length (match-string 1 str)))) (concat (make-string (/ len 2) ?\\) - (if (zerop (mod len 2)) "\000" ",")))) + (if (zerop (mod len 2)) "\000" (format "%s" sep))))) s nil t) "\000")) =20 --=20 2.26.0 --=-=-=--