From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Including file from a macro? Date: Wed, 27 Jun 2018 09:57:44 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000509291056f9af8e6" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY5Kr-0002uV-Ju for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 03:57:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fY5Kl-0002yQ-6P for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 03:57:51 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:43899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fY5Kk-0002xS-Sl for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 03:57:47 -0400 Received: by mail-ed1-x52c.google.com with SMTP id u9-v6so523616eds.10 for ; Wed, 27 Jun 2018 00:57:46 -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 --000000000000509291056f9af8e6 Content-Type: text/plain; charset="UTF-8" Hi, Is it possible to use "#+include" from within a macro? I have the following two files: t1.org: ----- #+MACRO: newline (eval "\n") #+MACRO: module-summary ** $1 {{{newline}}}{{{newline}}}#+include: "./$1.org::file-summary" {{{module-summary(t2)}}} ----- t2.org: ----- * t2 file #+name: file-summary This is the file summary ----- This is another paragraph If I export t1.org to org-mode, I get the following, which, if exported to any other format (I have tested HTML and Markdown), correctly includes the "file-summary" paragraph: t1.org.org: ----- # Created 2018-06-27 Wed 09:26 #+TITLE: #+AUTHOR: Zamboni Diego #+macro: newline (eval "\n") #+macro: module-summary ** $1 {{{newline}}}{{{newline}}}#+include: "./$1.org::file-summary" * t2 #+include: "./t2.org::file-summary" ----- However, if I export t1.org directly to HTML or Markdown, I get only the heading "* t2", but no included contents, as if the #+include line is not being processed correctly. Any ideas if this is possible? Thanks, --Diego --000000000000509291056f9af8e6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Is it possible to use "#+inclu= de" from within a macro?

I have the following= two files:

t1.org:<= /div>
-----
#+MACRO: newline =C2=A0 =C2=A0(eval "\n= ")
#+MACRO: module-summary ** $1 {{{newline}}}{{{newline}}}#= +include: "./$1.org::file-summary"

{{{mo= dule-summary(t2)}}}
-----

-----
* t2 file

#+name: file-summary
This is the file summa= ry
-----

This is another paragraph
=

If I export t1.org = to org-mode, I get the following, which, if exported to any other format (I= have tested HTML and Markdown), correctly includes the "file-summary&= quot; paragraph:

-----
# Created 2018-06-27 Wed 09:26<= /div>
#+TITLE:
#+AUTHOR: Zamboni Diego
#+macro: new= line =C2=A0 =C2=A0(eval "\n")
#+macro: module-summary *= * $1 {{{newline}}}{{{newline}}}#+include: "./$1.org::file-summary"= ;

* t2

#+include: ".= /t2.org::file-summary"
-----

= However, if I export t1.org directly to HTML = or Markdown, I get only the heading "* t2", but no included conte= nts, as if the #+include line is not being processed correctly.
<= br>
Any ideas if this is possible?

Thank= s,
--Diego

--000000000000509291056f9af8e6-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Including file from a macro? Date: Wed, 27 Jun 2018 10:01:13 +0200 Message-ID: <877emkr73q.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY5OI-0004eh-Nv for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 04:01:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fY5O9-0004rM-85 for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 04:01:26 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:46687) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fY5O9-0004pM-1v for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 04:01:17 -0400 In-Reply-To: (Diego Zamboni's message of "Wed, 27 Jun 2018 09:57:44 +0200") 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 Hello, Diego Zamboni writes: > Is it possible to use "#+include" from within a macro? No, it isn't. Include keywords are expanded before macros. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Diego Zamboni Subject: Re: Including file from a macro? Date: Wed, 27 Jun 2018 11:28:47 +0200 Message-ID: References: <877emkr73q.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e81380056f9c3d9e" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY6kv-0001wV-Lo for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 05:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fY6kr-0001BH-P0 for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 05:28:53 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:42365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fY6kr-00019O-GL for emacs-orgmode@gnu.org; Wed, 27 Jun 2018 05:28:49 -0400 Received: by mail-ed1-x535.google.com with SMTP id g12-v6so2665497edi.9 for ; Wed, 27 Jun 2018 02:28:48 -0700 (PDT) In-Reply-To: <877emkr73q.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: Org-mode --000000000000e81380056f9c3d9e Content-Type: text/plain; charset="UTF-8" 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. Thanks for any ideas. --Diego On Wed, Jun 27, 2018 at 10:01 AM, Nicolas Goaziou wrote: > Hello, > > Diego Zamboni writes: > > > Is it possible to use "#+include" from within a macro? > > No, it isn't. Include keywords are expanded before macros. > > Regards, > > -- > Nicolas Goaziou > --000000000000e81380056f9c3d9e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Nicolas,

(sorry for repeat- resending reply to list)

Thanks for the clari= fication. Do you think there could be a way to achieve what I need (basical= ly what was shown in my question). I would to build a summary file with lin= ks and selected paragraphs from multiple other files in the same directory = (use case: I want to automate the creation of README.org at=C2=A0https://git= hub.com/zzamboni/elvish-modules/, among others). I can do the head= line/include by hand (or using YAsnippets maybe), but I thought it would be= much easier to just automate this with macros.

Thanks for any ideas.
--Diego

--000000000000e81380056f9c3d9e-- 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