From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OEeoLSWYLmCUWAAA0tVLHw (envelope-from ) for ; Thu, 18 Feb 2021 16:39:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qGaVKSWYLmAKFwAA1q6Kng (envelope-from ) for ; Thu, 18 Feb 2021 16:39:01 +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 048BD2D8D3 for ; Thu, 18 Feb 2021 17:39:01 +0100 (CET) Received: from localhost ([::1]:51436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCmKS-0000iq-7Y for larch@yhetil.org; Thu, 18 Feb 2021 11:39:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCmFY-0004Fs-FA for emacs-orgmode@gnu.org; Thu, 18 Feb 2021 11:33:56 -0500 Received: from mout02.posteo.de ([185.67.36.66]:36053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCmFT-0001YT-P6 for emacs-orgmode@gnu.org; Thu, 18 Feb 2021 11:33:56 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 8534E2400FE for ; Thu, 18 Feb 2021 17:33:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1613666027; bh=nGQ3cRZtApMy3f5JH/OLYfIMNqt31QMKZB+YuLAtiTU=; h=From:To:Subject:Date:From; b=qnAYJrqY5dpmDHUHNbcuOkAQSLb0SB9q2C8oxejEjSVE0TlDuegIVzC84Mbw42Emi 0AEUJSUL2bAV0omeKn5AG5wDmVcw7mjf6nP9kTtXYl2XyOH628mrawjBmSa78JM9ec 1etZOJEmjvu+iPGdoQpm7nfIAgnn9IQvxUK9lr7tGjVoOzv8aI+p2WjOAe2Pi0wGxh zngN1l+BZv50bQo2OCiEImDMhEcNsm1uA1f8iFa5xNZ9Fn2rgHMY1E0hvnMQ0C11VR n1Rn4XAtEouDsHlg5YTmIQ6C6p1yJCohoWQtP4ibbSc5k3JCFaRk/L2DDWcsRRTLSQ AZCWrJ8ETI4hA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DhKyy69nXz9rxB for ; Thu, 18 Feb 2021 17:33:46 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [PATCH] Startup option to separate macros arguments with an alternative string Date: Thu, 18 Feb 2021 17:33:46 +0100 Message-ID: <87blchl4id.fsf@posteo.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.57 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=qnAYJrqY; 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: 048BD2D8D3 X-Spam-Score: -2.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: lJuICzzzBQV1 --=-=-= Content-Type: text/plain Hi, I would like to propose this (possible) patch. With `#+STARTUP: macro-arg-sep-other' the macros arguments can be separated by a string other than comma, whose value is defined in `org-macro-arg-sep-other' (by default it is "'@"). Rationale for this patch: There are many contexts where the comma character can be inappropriate as an argument separator, since it has to be escaped many times. If the patch is relevant, I can take care of writing the documentation and docstrings. Example: #+begin_src org ,#+STARTUP: macro-arg-sep-other ,#+MACRO: lg (eval (if (org-export-derived-backend-p org-export-current-backend 'latex) (concat "@@latex:\\foreignlanguage{@@" $1 "@@latex:}{@@" "\u200B" $2 "\u200B" "@@latex:}@@") $2)) {{{lg(latin'@Lorem ipsum dolor sit amet, consectetuer adipiscing elit, donec hendrerit tempor tellus, donec pretium posuere tellus, proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.)}}} With the escaped character: {{{lg(latin'@Lorem ipsum dolor sit amet \'@)}}} #+end_src Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=org-macro-arg-sep.patch diff --git a/lisp/org-macro.el b/lisp/org-macro.el index f914a33d6..311eaf9a5 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -82,6 +82,8 @@ directly, use instead: #+MACRO: name template") +(defvar org-macro-arg-sep-other "'@") + ;;; Functions (defun org-macro--set-template (name value templates) @@ -277,15 +279,19 @@ 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. + (let ((sep (cond ((eq org-startup-macro-arg-sep 'comma) + ",") + ((eq org-startup-macro-arg-sep 'other) + org-macro-arg-sep-other)))) (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")) + "\000"))) ;;; Helper functions and variables for internal macros diff --git a/lisp/org.el b/lisp/org.el index 7d8733448..a51893ed3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -974,6 +974,15 @@ case it is too late to set the variable `org-startup-truncated'." :group 'org-startup :type 'boolean) +(defcustom org-startup-macro-arg-sep 'comma + "TODO" + :group 'org-startup + :package-version '(Org . "9.0") + :version "26.1" + :type '(choice + (const :tag "comma" comma) + (const :tag "other" other))) + (defcustom org-startup-indented nil "Non-nil means turn on `org-indent-mode' on startup. This can also be configured on a per-file basis by adding one of @@ -4187,7 +4196,8 @@ After a match, the following groups carry important information: ("nohideblocks" org-hide-block-startup nil) ("beamer" org-startup-with-beamer-mode t) ("entitiespretty" org-pretty-entities t) - ("entitiesplain" org-pretty-entities nil)) + ("entitiesplain" org-pretty-entities nil) + ("macro-arg-sep-other" org-startup-macro-arg-sep other)) "Variable associated with STARTUP options for Org. Each element is a list of three items: the startup options (as written in the #+STARTUP line), the corresponding variable, and the value to set --=-=-=--