emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* templating with Org?
@ 2015-08-08  4:48 Eric Abrahamsen
  2015-08-08 18:11 ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Abrahamsen @ 2015-08-08  4:48 UTC (permalink / raw)
  To: emacs-orgmode

Exporting org files and subtrees is awfully flexible, given all the
possible customizations, but for a long while I've occasionally felt the
need to come at the "export" process from the other direction: instead
of customizing the export appearance of a series of headings, instead
starting with a common block of export text, and interpolating values
from the headings into that text -- ie, templating.

I've felt this need off and on for a couple of years, most recently when
organizing a small literary festival. I really need to keep all the
information about the events in a single place, otherwise I know that
information will go stale right away. But I need the information in a
series of such wildly-varying formats that I can't imagine setting up
(and switching between) export filters in a way that wouldn't make me
cry. Not to mention that the different "export" use-cases all have their
own per-heading boilerplate text, and there's no way I'm going to repeat
all that different boilerplate under each heading.

Obviously there's many ways this could be done. I could somehow hijack
the export process -- in many cases it would be nice too make use of the
skeleton document structures that export provides.

Or maybe dynamic blocks? I've never used them before. Or maybe just a
plain old `org-map-entries', which reads the template text from an
external file and then steals some of the macro expansion functions to
fill out the values.

Has anyone wanted to do this before? Has anyone actually done it? Any
thoughts or suggestions would be much appreciated!

Yours,
Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: templating with Org?
  2015-08-08  4:48 templating with Org? Eric Abrahamsen
@ 2015-08-08 18:11 ` John Kitchin
  2015-08-10  5:49   ` Eric Abrahamsen
  0 siblings, 1 reply; 6+ messages in thread
From: John Kitchin @ 2015-08-08 18:11 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2714 bytes --]

I don't have the impression you would need to hijack the export process. It
seems like you would need to call a function that gets data from some
source (e.g the org document) and then populates a template with that data,
and once that is done, call a regular export function. There are a  number
of template solutions: http://www.emacswiki.org/emacs/CategoryTemplates. I
am not sure these are too easy to adapt to what you describe.

I played around with some ideas for this here:

http://kitchingroup.cheme.cmu.edu/blog/2014/01/20/Alternatives-to-long-complex-format-statements-in-emacs-lisp/
http://kitchingroup.cheme.cmu.edu/blog/2014/01/26/Another-alternative-to-string-templates/

Something like these could be used to populate a template I think.

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Sat, Aug 8, 2015 at 12:48 AM, Eric Abrahamsen <eric@ericabrahamsen.net>
wrote:

> Exporting org files and subtrees is awfully flexible, given all the
> possible customizations, but for a long while I've occasionally felt the
> need to come at the "export" process from the other direction: instead
> of customizing the export appearance of a series of headings, instead
> starting with a common block of export text, and interpolating values
> from the headings into that text -- ie, templating.
>
> I've felt this need off and on for a couple of years, most recently when
> organizing a small literary festival. I really need to keep all the
> information about the events in a single place, otherwise I know that
> information will go stale right away. But I need the information in a
> series of such wildly-varying formats that I can't imagine setting up
> (and switching between) export filters in a way that wouldn't make me
> cry. Not to mention that the different "export" use-cases all have their
> own per-heading boilerplate text, and there's no way I'm going to repeat
> all that different boilerplate under each heading.
>
> Obviously there's many ways this could be done. I could somehow hijack
> the export process -- in many cases it would be nice too make use of the
> skeleton document structures that export provides.
>
> Or maybe dynamic blocks? I've never used them before. Or maybe just a
> plain old `org-map-entries', which reads the template text from an
> external file and then steals some of the macro expansion functions to
> fill out the values.
>
> Has anyone wanted to do this before? Has anyone actually done it? Any
> thoughts or suggestions would be much appreciated!
>
> Yours,
> Eric
>
>
>

[-- Attachment #2: Type: text/html, Size: 3808 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: templating with Org?
  2015-08-08 18:11 ` John Kitchin
@ 2015-08-10  5:49   ` Eric Abrahamsen
  2015-08-10 12:01     ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Abrahamsen @ 2015-08-10  5:49 UTC (permalink / raw)
  To: emacs-orgmode

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> I don't have the impression you would need to hijack the export
> process. It seems like you would need to call a function that gets
> data from some source (e.g the org document) and then populates a
> template with that data, and once that is done, call a regular export
> function. There are a number of template solutions:
> http://www.emacswiki.org/emacs/CategoryTemplates. I am not sure these
> are too easy to adapt to what you describe.

That's an interesting idea: going from the base Org file to a massaged
Org buffer, and then exporting that. I'll try that out for a bit. Thanks
for that, and for the links!

> I played around with some ideas for this here:
>
> http://kitchingroup.cheme.cmu.edu/blog/2014/01/20/Alternatives-to-long-complex-format-statements-in-emacs-lisp/
>
> http://kitchingroup.cheme.cmu.edu/blog/2014/01/26/Another-alternative-to-string-templates/
>
>
> Something like these could be used to populate a template I think.
>
> John
>
> -----------------------------------
> Professor John Kitchin 
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
> On Sat, Aug 8, 2015 at 12:48 AM, Eric Abrahamsen
> <eric@ericabrahamsen.net> wrote:
>
>
>     Exporting org files and subtrees is awfully flexible, given all
>     the
>     possible customizations, but for a long while I've occasionally
>     felt the
>     need to come at the "export" process from the other direction:
>     instead
>     of customizing the export appearance of a series of headings,
>     instead
>     starting with a common block of export text, and interpolating
>     values
>     from the headings into that text -- ie, templating.
>
>     I've felt this need off and on for a couple of years, most
>     recently when
>     organizing a small literary festival. I really need to keep all
>     the
>     information about the events in a single place, otherwise I know
>     that
>     information will go stale right away. But I need the information
>     in a
>     series of such wildly-varying formats that I can't imagine setting
>     up
>     (and switching between) export filters in a way that wouldn't make
>     me
>     cry. Not to mention that the different "export" use-cases all have
>     their
>     own per-heading boilerplate text, and there's no way I'm going to
>     repeat
>     all that different boilerplate under each heading.
>
>     Obviously there's many ways this could be done. I could somehow
>     hijack
>     the export process -- in many cases it would be nice too make use
>     of the
>     skeleton document structures that export provides.
>
>     Or maybe dynamic blocks? I've never used them before. Or maybe
>     just a
>     plain old `org-map-entries', which reads the template text from an
>     external file and then steals some of the macro expansion
>     functions to
>     fill out the values.
>
>     Has anyone wanted to do this before? Has anyone actually done it?
>     Any
>     thoughts or suggestions would be much appreciated!
>
>     Yours,
>     Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: templating with Org?
  2015-08-10  5:49   ` Eric Abrahamsen
@ 2015-08-10 12:01     ` John Kitchin
  2015-08-10 12:14       ` Rasmus
  0 siblings, 1 reply; 6+ messages in thread
From: John Kitchin @ 2015-08-10 12:01 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

In reviewing these, I discovered I reinvented (and probably not as
well!) the function s-format from s.el
(https://github.com/magnars/s.el). It might be another option for you.


Eric Abrahamsen writes:

> John Kitchin <jkitchin@andrew.cmu.edu> writes:
>
>> I don't have the impression you would need to hijack the export
>> process. It seems like you would need to call a function that gets
>> data from some source (e.g the org document) and then populates a
>> template with that data, and once that is done, call a regular export
>> function. There are a number of template solutions:
>> http://www.emacswiki.org/emacs/CategoryTemplates. I am not sure these
>> are too easy to adapt to what you describe.
>
> That's an interesting idea: going from the base Org file to a massaged
> Org buffer, and then exporting that. I'll try that out for a bit. Thanks
> for that, and for the links!
>
>> I played around with some ideas for this here:
>>
>> http://kitchingroup.cheme.cmu.edu/blog/2014/01/20/Alternatives-to-long-complex-format-statements-in-emacs-lisp/
>>
>> http://kitchingroup.cheme.cmu.edu/blog/2014/01/26/Another-alternative-to-string-templates/
>>
>>
>> Something like these could be used to populate a template I think.
>>
>> John
>>
>> -----------------------------------
>> Professor John Kitchin
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> @johnkitchin
>> http://kitchingroup.cheme.cmu.edu
>>
>> On Sat, Aug 8, 2015 at 12:48 AM, Eric Abrahamsen
>> <eric@ericabrahamsen.net> wrote:
>>
>>
>>     Exporting org files and subtrees is awfully flexible, given all
>>     the
>>     possible customizations, but for a long while I've occasionally
>>     felt the
>>     need to come at the "export" process from the other direction:
>>     instead
>>     of customizing the export appearance of a series of headings,
>>     instead
>>     starting with a common block of export text, and interpolating
>>     values
>>     from the headings into that text -- ie, templating.
>>
>>     I've felt this need off and on for a couple of years, most
>>     recently when
>>     organizing a small literary festival. I really need to keep all
>>     the
>>     information about the events in a single place, otherwise I know
>>     that
>>     information will go stale right away. But I need the information
>>     in a
>>     series of such wildly-varying formats that I can't imagine setting
>>     up
>>     (and switching between) export filters in a way that wouldn't make
>>     me
>>     cry. Not to mention that the different "export" use-cases all have
>>     their
>>     own per-heading boilerplate text, and there's no way I'm going to
>>     repeat
>>     all that different boilerplate under each heading.
>>
>>     Obviously there's many ways this could be done. I could somehow
>>     hijack
>>     the export process -- in many cases it would be nice too make use
>>     of the
>>     skeleton document structures that export provides.
>>
>>     Or maybe dynamic blocks? I've never used them before. Or maybe
>>     just a
>>     plain old `org-map-entries', which reads the template text from an
>>     external file and then steals some of the macro expansion
>>     functions to
>>     fill out the values.
>>
>>     Has anyone wanted to do this before? Has anyone actually done it?
>>     Any
>>     thoughts or suggestions would be much appreciated!
>>
>>     Yours,
>>     Eric

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: templating with Org?
  2015-08-10 12:01     ` John Kitchin
@ 2015-08-10 12:14       ` Rasmus
  2015-08-10 12:19         ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: Rasmus @ 2015-08-10 12:14 UTC (permalink / raw)
  To: emacs-orgmode

John Kitchin <jkitchin@andrew.cmu.edu> writes:

> In reviewing these, I discovered I reinvented (and probably not as
> well!) the function s-format from s.el
> (https://github.com/magnars/s.el). It might be another option for you.

Aside: Skimming the s-format function, it looks like a re-implementation
of format-spec...

Rasmus

-- 
The second rule of Fight Club is: You do not talk about Fight Club

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: templating with Org?
  2015-08-10 12:14       ` Rasmus
@ 2015-08-10 12:19         ` John Kitchin
  0 siblings, 0 replies; 6+ messages in thread
From: John Kitchin @ 2015-08-10 12:19 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

Haha! Yet another function I didn't know about😉

On Monday, August 10, 2015, Rasmus <rasmus@gmx.us> wrote:

> John Kitchin <jkitchin@andrew.cmu.edu <javascript:;>> writes:
>
> > In reviewing these, I discovered I reinvented (and probably not as
> > well!) the function s-format from s.el
> > (https://github.com/magnars/s.el). It might be another option for you.
>
> Aside: Skimming the s-format function, it looks like a re-implementation
> of format-spec...
>
> Rasmus
>
> --
> The second rule of Fight Club is: You do not talk about Fight Club
>
>
>

-- 
John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

[-- Attachment #2: Type: text/html, Size: 1367 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-10 12:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-08  4:48 templating with Org? Eric Abrahamsen
2015-08-08 18:11 ` John Kitchin
2015-08-10  5:49   ` Eric Abrahamsen
2015-08-10 12:01     ` John Kitchin
2015-08-10 12:14       ` Rasmus
2015-08-10 12:19         ` John Kitchin

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).