From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iFaRIRLBm2AZXAEAgWs5BA (envelope-from ) for ; Wed, 12 May 2021 13:50:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iJIiHRLBm2AtewAAB5/wlQ (envelope-from ) for ; Wed, 12 May 2021 11:50:42 +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 F156AA30C for ; Wed, 12 May 2021 13:50:41 +0200 (CEST) Received: from localhost ([::1]:50808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgnNw-000101-PO for larch@yhetil.org; Wed, 12 May 2021 07:50:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgnMv-0000zg-HX for emacs-orgmode@gnu.org; Wed, 12 May 2021 07:49:37 -0400 Received: from ciao.gmane.io ([116.202.254.214]:40180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgnMs-0005nd-5d for emacs-orgmode@gnu.org; Wed, 12 May 2021 07:49:37 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lgnMp-0004qC-IM for emacs-orgmode@gnu.org; Wed, 12 May 2021 13:49:31 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Maxim Nikulin Subject: Re: [PATCH] Possibility of using alternative separators in macros Date: Wed, 12 May 2021 18:49:25 +0700 Message-ID: References: <87wnsjx5rs.fsf@posteo.net> <87o8duyhxr.fsf@bzg.fr> <87sg36u5wa.fsf@nicolasgoaziou.fr> <87k0oinmy2.fsf@posteo.net> <87h7jkdesz.fsf@christianmoe.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 In-Reply-To: <87h7jkdesz.fsf@christianmoe.com> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , 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=1620820242; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TU/YDia7B2cyklbGj48Srtt8VaL1vbF0037yX59NJPc=; b=VKynkxA8woO6zpza+c+v5HgoSOebj3pKt8fjryLXNcTtNM0oZZ4MNEJdcoDnFkuxP9MiMr EOx2HyJPINOUcssqSH4e/YEuaYrdeHrFYOKYVZ6QpPrqOUphIEGKNPDfs/+a6SDYI4RLTg nn3BAJcrYCbdzevxqZKXAcQMOjg7YlLU1GZsuIxQLjFiBTupi3v+DXo+AEtp/QRAayRn8n Nn7ErsG77OyfqFarlOrxvYDqqIVORuSsY1N/Kdsr+uY9nz6+oSHSPi7ta10BKA9IGSN0DP xF/jg6Y19kCl5Ri7+13VkKfmZt5syKQ5jOhmo9sc+t/pitzuCqjnh2GhKSswCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620820242; a=rsa-sha256; cv=none; b=Qx7maRPfWTiqkAVToBW+2GBwsOqjLeFwUPbVknxEUW/qg8O5Zs1ClAoqEIZUqVUeQ0dlJB xIsuZh7dM1LzjGTYA8qCz+F3SQlXxpr/3t2KvGWtdaeMi/5Qq9ytW01Mm/jByaG+hKcROu 1GNP2L/a1FO8C8o+V+AC7YGx30uCS+KwJaVPPFt86vq9q9cIYSfGa/MMr4gzYlU6gxOv3w 2mCFzMQs6Tkk1OFxjJZYHkEDuiHRpk37DMajpMHr8jh2ehKsi0VjUSrkZhhtYmph2Ashk9 qqi8mGSHyrFDMUjj2MRvCYMbTtW82Mazj4wHP8SmQ932siDKeviyeQbqdue2cA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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: -1.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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: F156AA30C X-Spam-Score: -1.85 X-Migadu-Scanner: scn0.migadu.com X-TUID: CudeM3QmzIoo On 03/05/2021 04:08, Christian Moe wrote: > > I frequently need to escape commas in macros, which is a bit of a pain > and easy to forget. Maybe it is not convenient, but if unescaped comma is a real pain, you could detect it and report an error # single line may be wrapped by mailer #+MACRO: extraerror (eval (if (not $2) (concat "*" $1 "*") (error (format "%s: unescaped comma %S" (line-number-at-pos) $2)))) {{{extraerror(valid)}}} {{{extraerror(valid\, with escaped comma)}}} {{{extraerror(missed, comma)}}} Org gurus might suggest a recipe how to convert error into warning, that is easily noticeable but still not fatal, to get all problems after single export attempt. Preferably it should act similar to compiler errors allowing to jump between problem points. Org 9.3 requires a bit different macro #MACRO: extraerror (eval (if (equal "" $2) (concat "*" $1 "*") (error (format "%s: unescaped comma %S" (line-number-at-pos) $2)))) > Another point: Something that would help, without adding new syntax, is > making macro expansion smart enough to *ignore* separators when the > macro definition contains only *one* argument anyway, as in the cases > above. I think, this is an idea of the best approach. Unsure concerning precise form. Maybe e.g. "$_" could expand into all arguments greater than maximum referenced number. No promise of forward compatibility of the following hack since it relies on undocumented implementation details. #+MACRO: allargshack (eval (format "- /%s/ :: %s" $1 (mapconcat #'identity _ ","))) {{{allargshack(one, two, three)}}} I do not know if Eric can swap order of arguments of his credits macro. Extracting namely last argument requires a bit more lisp code.