emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Including file from a macro?


From: Berry, Charles
Subject: Re: [O] Including file from a macro?
Date: Wed, 27 Jun 2018 16:42:42 +0000


> On Jun 27, 2018, at 2:28 AM, Diego Zamboni <address@hidden> wrote:
> 
> Hi Nicolas,
> 
> (sorry for repeat- resending reply to list)
> 
> Thanks for the clarification. Do you think there could be a way to achieve 
> 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.
> 


You can do this:

#+MACRO: include (eval (org-export-string-as (concat "#+include: " $1 "\n") 
'org t))

and then 

{{{include("myfile.org" :lines "1-10")}}}

will drop those lines into the file as the output of an export to `org'. You 
will need to customize export backends to include `org'. Or you can use some 
other backend if you put the macro call inside an export block.

However, the results may be surprising - macros defined in the main document 
will not function in the included document unless you also defined them there, 
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 some 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, it 
may not offer you all that you want.

HTH,

Chuck


> Thanks for any ideas.
> --Diego
> 
> 
> On Wed, Jun 27, 2018 at 10:01 AM, Nicolas Goaziou <address@hidden> wrote:
> Hello,
> 
> Diego Zamboni <address@hidden> writes:
> 
> > Is it possible to use "#+include" from within a macro?
> 
> No, it isn't. Include keywords are expanded before macros.
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]