emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Berry, Charles" <ccberry@ucsd.edu>
To: Diego Zamboni <diego@zzamboni.org>
Cc: Org-mode <emacs-orgmode@gnu.org>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: Including file from a macro?
Date: Wed, 27 Jun 2018 16:42:42 +0000	[thread overview]
Message-ID: <80F84BD4-6250-48AB-B1DC-5E07BF599DD7@ucsd.edu> (raw)
In-Reply-To: <CAGY83Ec1ao3ct3QsTtosbLLbDrU+p7vrc9+oYThFegNYj7dEJw@mail.gmail.com>



> On Jun 27, 2018, at 2:28 AM, Diego Zamboni <diego@zzamboni.org> 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 <mail@nicolasgoaziou.fr> wrote:
> Hello,
> 
> Diego Zamboni <diego@zzamboni.org> 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	other threads:[~2018-06-27 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27  7:57 Including file from a macro? Diego Zamboni
2018-06-27  8:01 ` Nicolas Goaziou
2018-06-27  9:28   ` Diego Zamboni
2018-06-27 16:42     ` Berry, Charles [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80F84BD4-6250-48AB-B1DC-5E07BF599DD7@ucsd.edu \
    --to=ccberry@ucsd.edu \
    --cc=diego@zzamboni.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).