From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Vararg macros, and code block as macro? Date: Thu, 26 Jul 2018 11:21:19 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c497770571e88c7d" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fii5D-0005tl-3o for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 11:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fii57-00041h-Cc for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 11:21:39 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:39189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fii57-00041B-4C for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 11:21:33 -0400 Received: by mail-lj1-x22f.google.com with SMTP id l15-v6so1846157lji.6 for ; Thu, 26 Jul 2018 08:21:33 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Diego Zamboni Cc: Org-mode --000000000000c497770571e88c7d Content-Type: text/plain; charset="UTF-8" Hello Diego, I can try to answer your second question. On Thu, Jul 26, 2018 at 10:35 AM Diego Zamboni wrote: > > 2. Related to my workaround above, I am wondering if there's a way to > refer to a source block as the macro definition. At the moment I just > joined my whole elisp block into a single line for the macro definition, > but I would love to have it in a proper source block so I can edit it > properly, have indentation and syntax highlighting, etc. > How about adding this to your emacs config: (defun my/org-macro-keys-code (str) "Split STR at spaces and wrap each element with `~' char, separated by `+'." (mapconcat (lambda (s) (concat "~" s "~")) (split-string str) (concat (string ?\u200B) "+" (string ?\u200B)))) Make sure that that always evaluates before you do Org exports, and then simply use this in your Org files: #+macro: keys (eval (my/org-macro-keys-code $1)) {{{keys("Ctrl c Ctrl e H H")}}} PS: Thanks for sharing that code! You are following the vision of ox-hugo.. replacing Hugo shortcodes with Org macros :+1: :) -- Kaushal Modi --000000000000c497770571e88c7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Diego,

I can try to answer yo= ur second question.

On Thu, Jul 26, 2018 at 10:35 AM Diego Zamboni <diego@zzamboni.org> wrote:

2. Related to my worka= round above, I am wondering if there's a way to refer to a source block= as the macro definition. At the moment I just joined my whole elisp block = into a single line for the macro definition, but I would love to have it in= a proper source block so I can edit it properly, have indentation and synt= ax highlighting, etc.

How about= adding this to your emacs config:

(defun my/org-m= acro-keys-code (str)
=C2=A0 "Split STR at spaces and wrap each elem= ent with `~' char, separated by `+'."
=C2=A0 (mapconcat (la= mbda (s)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (concat "~" s "~"))
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (split-stri= ng str)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (concat (string ?\u200B) "+" (string ?\u200B))))
<= div>
Make sure that that always evaluates before you do Org e= xports, and then simply use this in your Org files:

#+macro: keys (eval (my/org-macro-keys-code $1))
{{{= keys("Ctrl c Ctrl e H H")}}}

PS: Thanks = for sharing that code! You are following the vision of ox-hugo.. replacing = Hugo shortcodes with Org macros :+1: :)
--
=

Kaushal Modi

--000000000000c497770571e88c7d--