From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Berry, Charles" Subject: Re: Including file from a macro? Date: Wed, 27 Jun 2018 16:42:42 +0000 Message-ID: <80F84BD4-6250-48AB-B1DC-5E07BF599DD7@ucsd.edu> References: <877emkr73q.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYDWt-0000e5-BX for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 12:42:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYDWp-0001J9-8Q for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 12:42:51 -0400 Received: from iport-acv8-out.ucsd.edu ([132.239.0.21]:47681) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYDWo-0001E5-Nu for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 12:42:47 -0400 In-Reply-To: Content-Language: en-US Content-ID: <3267BCF4398F2E479DFDC3BEBCCCD592@AD.UCSD.EDU> 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 , Nicolas Goaziou > On Jun 27, 2018, at 2:28 AM, Diego Zamboni wrote: >=20 > Hi Nicolas, >=20 > (sorry for repeat- resending reply to list) >=20 > Thanks for the clarification. Do you think there could be a way to achiev= e what I need (basically what was shown in my question). I would to build a= summary file with links and selected paragraphs from multiple other files = in the same directory (use case: I want to automate the creation of README.= org at https://github.com/zzamboni/elvish-modules/, among others). I can do= the headline/include by hand (or using YAsnippets maybe), but I thought it= would be much easier to just automate this with macros. >=20 You can do this: #+MACRO: include (eval (org-export-string-as (concat "#+include: " $1 "\n")= 'org t)) and then=20 {{{include("myfile.org" :lines "1-10")}}} will drop those lines into the file as the output of an export to `org'. Yo= u will need to customize export backends to include `org'. Or you can use s= ome other backend if you put the macro call inside an export block. However, the results may be surprising - macros defined in the main documen= t will not function in the included document unless you also defined them t= here, babel code will run out of sync with babel in the main document, and = so on. I am not sure how this might affect internal hyperlinks, so try som= e cases if you need that to work before you commit to doing something like = this. So unless what you are doing inside the included document is pretty tame, i= t may not offer you all that you want. HTH, Chuck > Thanks for any ideas. > --Diego >=20 >=20 > On Wed, Jun 27, 2018 at 10:01 AM, Nicolas Goaziou wrote: > Hello, >=20 > Diego Zamboni writes: >=20 > > Is it possible to use "#+include" from within a macro? >=20 > No, it isn't. Include keywords are expanded before macros. >=20 > Regards, >=20 > --=20 > Nicolas Goaziou >=20