From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Vararg macros, and code block as macro? Date: Thu, 26 Jul 2018 16:33:31 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000274b4e0571e7e113" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fihKj-00052B-5i for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 10:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fihKg-00067H-6L for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 10:33:37 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:41734) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fihKf-00066V-SP for emacs-orgmode@gnu.org; Thu, 26 Jul 2018 10:33:34 -0400 Received: by mail-ed1-x52f.google.com with SMTP id s24-v6so1609256edr.8 for ; Thu, 26 Jul 2018 07:33:33 -0700 (PDT) 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: Org-mode --000000000000274b4e0571e7e113 Content-Type: text/plain; charset="UTF-8" Hi, I have two somewhat related questions: 1. Is there a way for macros to check how many arguments were passed, and change its output depending on this? At the moment I found a solution using an =(eval...)= macro, which checks the values of $1, $2, etc. and produces the appropriate string. It works, but I wonder if there's a more org-native way. 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. If anyone is interested, here's my current code: https://raw.githubusercontent.com/zzamboni/zzamboni.org/master/content-org/zzamboni.org. You can see the "hsapi" macro, and a source block right below its definition, with the code, which for now has been joined together in the macro line. Thanks! --Diego --000000000000274b4e0571e7e113 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I have two somewhat related questio= ns:

1. Is there a way for macros to check how many= arguments were passed, and change its output depending on this? At the mom= ent I found a solution using an =3D(eval...)=3D macro, which checks the val= ues of $1, $2, etc. and produces the appropriate string. It works, but I wo= nder if there's a more org-native way.

2. Rela= ted 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 who= le elisp block into a single line for the macro definition, but I would lov= e to have it in a proper source block so I can edit it properly, have inden= tation and syntax highlighting, etc.

If anyone is = interested, here's my current code:=C2=A0https= ://raw.githubusercontent.com/zzamboni/zzamboni.org/master/content-org/zzamb= oni.org. You can see the "hsapi" macro, and a source block ri= ght below its definition, with the code, which for now has been joined toge= ther in the macro line.

Thanks!
--Diego<= /div>

--000000000000274b4e0571e7e113--