emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] #+call split into multiple lines?


From: Stefan Vollmar
Subject: Re: [O] #+call split into multiple lines?
Date: Fri, 29 Mar 2013 09:24:19 +0100

Dear Thomas,
dear Sebation,
dear Achim,
dear Nicolas,

maybe a misunderstanding: the original idea is to produce a "personal homepage" 
for members of our institute, with one file per person - here is a better 
example http://www.nf.mpg.de/cv-howto/ex3-en.org and here some background 
information http://www.nf.mpg.de/cv-howto/cv-en.html.

As you can see, we used MACROs for our hcard-HTML templates - this currently 
does not work unless all arguments are written in one line. We need 10+ 
arguments and using named arguments is a much better strategy anyway.

The problem is quite general, I think, and a common solution I quite like is a 
key-value structure (preferably with optional comments), one key-value pair per 
line. 

Using a table for a key-value assignment is, of course, possible. Here again 
your example: 

#+name: card-table
| cname                   | gname      | photo                 | etc.|
| Dr. Stefan Vollmar      | Stefan     | stefan-vollmar.jpg    | ... |

Editing a table with many columns is awkward (not everybody uses Emacs for our 
templates). Much easier (to edit) is the transposed version:

#+name: card-table
| cname | Dr. Stefan Vollmar |
| gname | Stefan             |
| photo | stefan-vollmar.jpg |
...

This might work reasonably well - if (1) I could prevent the table from being 
exported to HTML, (2) (probably more difficult) if this kind of thing would 
work:

#+call: hcard(v=card-table) :results html

with

...
<h1>$v["cname"]</h1>
<p><b>Given Name:</b> $v["gname"]</p>
...

inside the hcard-babel-block (org) to reference the named values.

My feeling is (please correct me if I am wrong) that maybe we would want two 
Babel blocks: one for setting a set of variables/an array (elisp?) and one for 
filling the template?

Could I fill a suitable structure/array/set of variables within an elisp block 
and then reference it/them in the org template that only requires replacing 
placeholders?

Many thanks in advance!

Warm regards,
 Stefan


On 28.03.2013, at 22:51, Thomas S. Dye wrote:

> 
> 
> Aloha Seb,
> 
> "Sebastien Vauban"
> <address@hidden> writes:
> 
>> Hi Thomas,
>> 
>> Thomas S. Dye wrote:
>>> In this situation I often put the arguments in a named Org table and
>>> then write the Babel source code block to take a single argument--the
>>> table name--and parse the information passed in that way.  
>>> 
>>> #+name: card-table
>>> | cname                   | gname      | photo                 | etc.|
>>> | Dr. Stefan Vollmar      | Stefan     | stefan-vollmar.jpg    | ... |
>>> | Dr. Stefan Vollmar, Jr. | Stefan Jr. | stefan-vollmar-jr.jpg | ... |
>>> 
>>> 
>>> #+call: mhead-hcard(card=card-table[0,]) for Stefan
>>> 
>>> #+call: mhead-hcard(card=card-table[1,]) for Stefan Jr.
>>> 
>>> If you don't mind writing some extra code for the Babel function, then
>>> 
>>> #+call: mhead-hcard(card=card-table,gname="Stefan")
>>> 
>>> etc.
>> 
>> And do you eventually have a way to write a "for-loop" for all the lines of
>> the tables, not being forced to write as many calls as the number of lines 
>> you
>> do have?
>> 
>> I don't see (immediately) how to do such, but that would really allow to
>> promote such a use case!
> 
> Not sure I understand your question.  Perhaps I misunderstood Stefan's
> use case?
> 
> There are several languages supported by Babel that have loop
> constructs.  I was assuming that Stefan would use one of these when I
> suggested the possibility of writing some extra code.
> 
> All the best,
> Tom
> 
> -- 
> Thomas S. Dye
> http://www.tsdye.com
> 
> 

-- 
Dr. Stefan Vollmar, Dipl.-Phys.
Head of IT group
Max-Planck-Institut für neurologische Forschung
Gleueler Str. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213  FAX +49-221-4726-298
Tel.: +49-221-478-5713  Mobile: 0160-93874279
E-Mail: address@hidden   http://www.nf.mpg.de








Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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