From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8EjBNwtNgGD9gwAAgWs5BA (envelope-from ) for ; Wed, 21 Apr 2021 18:04: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 mp0 with LMTPS id AFF2MwtNgGC0ZwAA1q6Kng (envelope-from ) for ; Wed, 21 Apr 2021 16:04:27 +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 7633B197C8 for ; Wed, 21 Apr 2021 18:04:27 +0200 (CEST) Received: from localhost ([::1]:55500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZFL0-000245-HG for larch@yhetil.org; Wed, 21 Apr 2021 12:04:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZFIT-0008GM-5w for emacs-orgmode@gnu.org; Wed, 21 Apr 2021 12:01:49 -0400 Received: from mout01.posteo.de ([185.67.36.65]:46395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZFIO-0007bc-KL for emacs-orgmode@gnu.org; Wed, 21 Apr 2021 12:01:48 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 1D50C24002A for ; Wed, 21 Apr 2021 18:01:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1619020900; bh=pPiwU3yFkf8R/F+s/Pwx4zI6YIf2jsgHbNAIk98hnCE=; h=From:To:Cc:Subject:Date:From; b=kehIoB6a2RSdpk1De8VLuCQC0dypytBPIRqHHHQ0gvKHwDg5adBXgy0/NQGRfolgA JcWf5FsRQckBtKmSvUGqnzZBeWkz4AboUKOVh/NIVRNQ7lzRnlhwPAAvRqqU60y7AL 3y3VHrInUzQeDk51X5P1ltpbSbfaEn4XzkyP+FyilCFsCCDWiwGuEOYXyJdyQM+LH6 W9Nssyi70XoeGuWb4Gny/np4PGS+HP1hoD11W+RiAiGj2AcdL3mZHA5f2BjXmIuIBE SmLQ5CUgDvPhgCpWx9JITr1gEB4IhpckZqVGQE9oN0kRv421ONWLr0ABByZTkBcduW ez5Xw8ogOeEeA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FQQKF6n5cz6tmc; Wed, 21 Apr 2021 18:01:37 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Nicolas Goaziou Subject: Re: [PATCH] Startup option to separate macros arguments with an alternative string References: <87blchl4id.fsf@posteo.net> <87o8ead42u.fsf@nicolasgoaziou.fr> Date: Wed, 21 Apr 2021 16:01:35 +0000 In-Reply-To: <87o8ead42u.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Mon, 19 Apr 2021 11:19:21 +0200") Message-ID: <875z0fzkww.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=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=1619021067; 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=D9/e17SmabSlUPz5w4tzZFwN1lvvOtqpzBXWgLIAvGY=; b=a1uafXwK/h0N0wTNnqWfWfuiuQXfOwbkAOLeSecBjVWXi6dslIqfJEE9H5Y/pA8WwFcMwj Au+NXjvEBcFs7vkd8W8/Pv/q9gTk2uLR/jyZqqP5g1ZKGgAL+7duIXQIqRohQtdeUiMiSq 4TRyzA/NYsszxJTPC2nn26bIOGWkVtT8+f+X7ZtoFE7PEztRSrTrQZRmyz7L8Jd6+qQqaV VDdj9PGmthnEN9I4xqqdUqFsCEroVtHn2RMztTTvLIJEC8hwyaVlFdQLe4wj7Pug0zFQ+v X/h4X8tWM6QYHeLaEQqDMhmRz/NoS12LST2T6+CuNnhyz4+ln5HRzeZYmaC0sg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619021067; a=rsa-sha256; cv=none; b=tz5UqfwoyGlkiwNOgUuKPss60nvhgqzw6K0blg4Ix1PfL5KOmGh2/7SzwhuSiIX9GiqhZP TY1Kf0C/uxMLgb8V4sYxy4Qi9d/R42ATX9I/Ff6QHc88WCbD2OPAX5f2saQxDkUxvbM6Nm AjB5RMsP7Gya25ZWq3ZiNCHTYsXQ3hwPmlNcAwV3AVb4T2UNrBhOinA85tDrA0Ae2oMwP6 EH8/tT3C/9/SP+v5CX2q3RC/ZgYEysmbPcJ40Nycd0OpvpjgYtkaa9/t92NnpfPSSWz+Yd bkANu2T33kX6+aWufydLl34J0YaApiPc+XqvQBCr92EkZq2E38E2fGrxyLhbCQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=kehIoB6a; 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-Spam-Score: -3.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=kehIoB6a; 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: 7633B197C8 X-Spam-Score: -3.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: GVpeIIjpyV1s Hello again. I forgot to answer this question on your previous message, sorry... Nicolas Goaziou writes: > That being said, we can discuss syntax that is not depending upon some > variable. For example macro names are written with a limited set of > characters (alphanumeric, dash, underscore). We might allow the optional > argument separator to be located right before the opening parenthesis, > e.g., > > {{{macroname@(latin@Lorem ipsum dolor sit amet, ...)}}} > {{{macroname|(latin|Lorem ipsum dolor sit amet, ...)}}} I think it's a very interesting idea. I've made this sketch (at least as a proof of concept), what do you think of the approach? Example (and code below): #+macro: foo (eval (format "%s and %s" $1 $2)) {{{foo(xxx,zzz\, yyy)}}} {{{foo|(xxx|zzz, aaa)}}} {{{foo@(xxx@zzz, sss)}}} {{{foo|(xxx|zzz\| aaa)}}} {{{foo@(xxx@zzz\@ sss)}}} #+begin_src emacs-lisp (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 `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" (format "%s" sep))))) s nil t) "\000")) (defun org-element-macro-parser () "Parse macro at point, if any. When at a macro, return a list whose car is `macro' and cdr a plist with `:key', `:args', `:begin', `:end', `:value' and `:post-blank' as keywords. Otherwise, return nil. Assume point is at the macro." (save-excursion (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\([^a-zA-Z]*[^-a-zA-Z0-9_]*\\)\\((\\([^\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)) (args (pcase (match-string-no-properties 4) (`nil nil) (a (org-macro-extract-arguments (if (not (equal (match-string-no-properties 2) "")) (match-string-no-properties 2) ",") (replace-regexp-in-string "[ \t\r\n]+" " " (org-trim a))))))) (list 'macro (list :key key :value value :args args :begin begin :end end :post-blank post-blank)))))) (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 `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" (format "%s" sep))))) s nil t) "\000")) #+end_src