From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Rogoff Subject: Re: macro replacement in code block? Date: Tue, 31 Oct 2017 20:21:44 -0700 Message-ID: References: <17470BC7-0FB7-458A-AE92-30EC6A7A303F@therogoffs.com> Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_F183086B-92B8-47B9-B991-9B6D1E6110EE" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9jgb-0000Nb-09 for emacs-orgmode@gnu.org; Tue, 31 Oct 2017 23:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9jgW-0001AR-1p for emacs-orgmode@gnu.org; Tue, 31 Oct 2017 23:27:25 -0400 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:54855) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e9jgV-00017h-KB for emacs-orgmode@gnu.org; Tue, 31 Oct 2017 23:27:19 -0400 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 62EFC140745 for ; Tue, 31 Oct 2017 21:21:53 -0600 (MDT) 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: Kaushal Modi Cc: emacs-org list --Apple-Mail=_F183086B-92B8-47B9-B991-9B6D1E6110EE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 31, 2017, at 5:32 PM, Kaushal Modi = wrote: >=20 > On Tue, Oct 31, 2017, 7:14 PM David Rogoff > wrote: > Hi. >=20 > Hello.=20 >=20 > I=E2=80=99m trying to clean it up by using orgmode macros. However, = it seems like these are not replaced when inside code blocks.=20 >=20 > Do you have a minimal example of what you'd like to "macrofy" in the = verilog code blocks? Pretty simple text substitution. Something like this: #+MACRO: SEC_HDR1 // --------------------------- #+MACRO: SEC_HDR2 //=20 #+MACRO: SEC_TITLE This section declares local types and constants * File 1 ** Section 1: {{{SEC_TITLE}}} #+BEGIN_SRC verilog {{{SEC_HDR1}}} {{{SEC_HDR2}}} {{{SEC_TITLE}}} parameter A =3D 1; #+END_SRC So SEC_TITLE expands in the headline and also as a comment in the = tangled verilog code. It would be really great to be able to embed newlines in the macro to it = could be one line / macro in the src block. >=20 > Probably the solution is to use noweb references with arguments? See = the Org manual.=20 Thanks - I=E2=80=99ll have to look into noweb. I=E2=80=99m not familiar = with it. David --Apple-Mail=_F183086B-92B8-47B9-B991-9B6D1E6110EE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Oct 31, 2017, at 5:32 PM, Kaushal Modi <kaushal.modi@gmail.com> wrote:

On Tue, Oct 31, 2017, = 7:14 PM David Rogoff <david@therogoffs.com> wrote:
Hi.

Hello. 

 I=E2=80=99m = trying to clean it up by using orgmode macros.  However, it seems = like these are not replaced when inside code blocks. 

Do you have a minimal example of what you'd like to "macrofy" = in the verilog code blocks?

Pretty simple text substitution.  Something = like this:

    #+MACRO: = SEC_HDR1 // ---------------------------
    #+MACRO: = SEC_HDR2 // 

    = #+MACRO: SEC_TITLE This section declares local types and = constants

    * File = 1
    ** Section 1: {{{SEC_TITLE}}}
  =       #+BEGIN_SRC verilog
      =       {{{SEC_HDR1}}}
      =       {{{SEC_HDR2}}} {{{SEC_TITLE}}}
  =           parameter A =3D 1;
  =       #+END_SRC

So = SEC_TITLE expands in the headline and also as a comment in the tangled = verilog code.
It would be really great to be able to embed = newlines in the macro to it could be one line / macro in the src = block.


Probably the solution is to use noweb references with = arguments? See the Org manual. 

Thanks - = I=E2=80=99ll have to look into noweb.  I=E2=80=99m not familiar = with it.

 David

= --Apple-Mail=_F183086B-92B8-47B9-B991-9B6D1E6110EE--