emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* #+call split into multiple lines?
@ 2013-03-28 20:49 Stefan Vollmar
  2013-03-28 21:17 ` Thomas S. Dye
  2013-03-29  7:18 ` Achim Gratz
  0 siblings, 2 replies; 11+ messages in thread
From: Stefan Vollmar @ 2013-03-28 20:49 UTC (permalink / raw)
  To: Org Mode Mailing List

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

Hallo,

I am a new Org-Babel convert (thanks, Nicolas!) and our first project replaces a MACRO (raw HTML template) with 12+ arguments and is a major improvement as we can now use named arguments.

This short example works:

#+call: mhead-hcard(cname="Dr. Stefan Vollmar",gname="Stefan",prefix="Dr.",web="stefan-vollmar.html",photo="stefan-vollmar.jpg") :results html

However, this only uses only four of 12+ arguments and - from my point of view - already suffers from being written in one line.

We have listed some of our attempts to increase readability (none of them works with release_8.0-pre-193-gaa7b1e).

(1) "natural" multi-line

#+call: mhead-hcard(
cname="Dr. Stefan Vollmar",   # full name for title
gname="Stefan",               # given name 
photo="stefan-vollmar.jpg",   # can be jpg or png
...)

(2) Attempt in keeping with a multi-line #+header construct

#+call: mhead-hcard(
#+call:  cname="Dr. Stefan Vollmar",   # full name for headline
#+call:  gname="Stefan",               # given name 
#+call:  photo="stefan-vollmar.jpg",   # can be jpg or png
...

(3) Using a "line continuation marker"

#+call: mhead-hcard(
 cname="Dr. Stefan Vollmar",\
 gname="Stefan",\
 photo="stefan-vollmar.jpg",\
...)

Maybe even with optional comments:

#+call: mhead-hcard(
 cname="Dr. Stefan Vollmar",\  # full name for headline
 gname="Stefan",\              # given name 
 photo="stefan-vollmar.jpg",\  # can be jpg or png
...)

Maybe there already is a good solution to increase readability? Maybe the "line continuation marker" (3) would be a general solution for all cases in org where now no line breaks are possible?

Many thanks for any help with this.
Warm regards,
 Stefan
-- 
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: vollmar@nf.mpg.de   http://www.nf.mpg.de




[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4409 bytes --]

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

* Re: #+call split into multiple lines?
  2013-03-28 20:49 #+call split into multiple lines? Stefan Vollmar
@ 2013-03-28 21:17 ` Thomas S. Dye
  2013-03-28 21:27   ` Sebastien Vauban
  2013-03-29  7:18 ` Achim Gratz
  1 sibling, 1 reply; 11+ messages in thread
From: Thomas S. Dye @ 2013-03-28 21:17 UTC (permalink / raw)
  To: Stefan Vollmar; +Cc: Org Mode Mailing List

Aloha Stefan,

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.

hth,
Tom

Stefan Vollmar <vollmar@nf.mpg.de> writes:

> Hallo,
>
> I am a new Org-Babel convert (thanks, Nicolas!) and our first project
> replaces a MACRO (raw HTML template) with 12+ arguments and is a major
> improvement as we can now use named arguments.
>
> This short example works:
>
> #+call: mhead-hcard(cname="Dr. Stefan Vollmar",gname="Stefan",prefix="Dr.",web="stefan-vollmar.html",photo="stefan-vollmar.jpg") :results html
>
> However, this only uses only four of 12+ arguments and - from my point
> of view - already suffers from being written in one line.
>
> We have listed some of our attempts to increase readability (none of
> them works with release_8.0-pre-193-gaa7b1e).
>
> (1) "natural" multi-line
>
> #+call: mhead-hcard(
> cname="Dr. Stefan Vollmar",   # full name for title
> gname="Stefan",               # given name 
> photo="stefan-vollmar.jpg",   # can be jpg or png
> ...)
>
> (2) Attempt in keeping with a multi-line #+header construct
>
> #+call: mhead-hcard(
> #+call:  cname="Dr. Stefan Vollmar",   # full name for headline
> #+call:  gname="Stefan",               # given name 
> #+call:  photo="stefan-vollmar.jpg",   # can be jpg or png
> ...
>
> (3) Using a "line continuation marker"
>
> #+call: mhead-hcard(
>  cname="Dr. Stefan Vollmar",\
>  gname="Stefan",\
>  photo="stefan-vollmar.jpg",\
> ...)
>
> Maybe even with optional comments:
>
> #+call: mhead-hcard(
>  cname="Dr. Stefan Vollmar",\  # full name for headline
>  gname="Stefan",\              # given name 
>  photo="stefan-vollmar.jpg",\  # can be jpg or png
> ...)
>
> Maybe there already is a good solution to increase readability? Maybe
> the "line continuation marker" (3) would be a general solution for all
> cases in org where now no line breaks are possible?
>
> Many thanks for any help with this.
> Warm regards,
>  Stefan

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: #+call split into multiple lines?
  2013-03-28 21:17 ` Thomas S. Dye
@ 2013-03-28 21:27   ` Sebastien Vauban
  2013-03-28 21:51     ` Thomas S. Dye
  2013-03-29  2:33     ` Eric Abrahamsen
  0 siblings, 2 replies; 11+ messages in thread
From: Sebastien Vauban @ 2013-03-28 21:27 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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!

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: #+call split into multiple lines?
  2013-03-28 21:27   ` Sebastien Vauban
@ 2013-03-28 21:51     ` Thomas S. Dye
  2013-03-29  8:24       ` Stefan Vollmar
  2013-03-29  2:33     ` Eric Abrahamsen
  1 sibling, 1 reply; 11+ messages in thread
From: Thomas S. Dye @ 2013-03-28 21:51 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Aloha Seb,

"Sebastien Vauban"
<wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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

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

* Re: #+call split into multiple lines?
  2013-03-28 21:27   ` Sebastien Vauban
  2013-03-28 21:51     ` Thomas S. Dye
@ 2013-03-29  2:33     ` Eric Abrahamsen
  2013-03-29  2:43       ` Thomas S. Dye
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Abrahamsen @ 2013-03-29  2:33 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> 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!

I think Thomas means you store *all* your cards in a single table, and
pass that entire table to the mhead-hcard function every time you call
it. The function gets the whole table, and it is responsible for
choosing which card(s) to pick from the table, and what to do with them.
In Thomas' example, you could pass it an extra parameter and use that to
pick a card.

The loop you're talking about happens not outside of the #+call, but
inside the function being #+call'd.

Hope that's clear,

E

PS the (card=card-table[0,]) syntax is new to me, is that a
Babel-specific construct?

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

* Re: #+call split into multiple lines?
  2013-03-29  2:33     ` Eric Abrahamsen
@ 2013-03-29  2:43       ` Thomas S. Dye
  2013-03-29  3:14         ` Eric Abrahamsen
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas S. Dye @ 2013-03-29  2:43 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Aloha Eric,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> PS the (card=card-table[0,]) syntax is new to me, is that a
> Babel-specific construct?

Do you mean the indexing into the table?  That's described here:

http://orgmode.org/manual/var.html#var

in the section `Indexable variable values' near the bottom.

hth,
Tom
-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: #+call split into multiple lines?
  2013-03-29  2:43       ` Thomas S. Dye
@ 2013-03-29  3:14         ` Eric Abrahamsen
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Abrahamsen @ 2013-03-29  3:14 UTC (permalink / raw)
  To: emacs-orgmode

tsd@tsdye.com (Thomas S. Dye) writes:

> Aloha Eric,
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> PS the (card=card-table[0,]) syntax is new to me, is that a
>> Babel-specific construct?
>
> Do you mean the indexing into the table?  That's described here:
>
> http://orgmode.org/manual/var.html#var
>
> in the section `Indexable variable values' near the bottom.

Yes! Thank you. I'm in the process of wrapping my head around this
stuff, and it's hard to keep all the pieces in place...

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

* Re: #+call split into multiple lines?
  2013-03-28 20:49 #+call split into multiple lines? Stefan Vollmar
  2013-03-28 21:17 ` Thomas S. Dye
@ 2013-03-29  7:18 ` Achim Gratz
  1 sibling, 0 replies; 11+ messages in thread
From: Achim Gratz @ 2013-03-29  7:18 UTC (permalink / raw)
  To: emacs-orgmode

Am 28.03.2013 21:49, schrieb Stefan Vollmar:
> (1) "natural" multi-line
>
> #+call: mhead-hcard(
> cname="Dr. Stefan Vollmar",   # full name for title
> gname="Stefan",               # given name
> photo="stefan-vollmar.jpg",   # can be jpg or png
> ...)

This doesn't parse well, so I venture to guess that Nicolas wouldn't 
like that.

> (2) Attempt in keeping with a multi-line #+header construct
>
> #+call: mhead-hcard(
> #+call:  cname="Dr. Stefan Vollmar",   # full name for headline
> #+call:  gname="Stefan",               # given name
> #+call:  photo="stefan-vollmar.jpg",   # can be jpg or png
> ...

See perhaps http://permalink.gmane.org/gmane.emacs.orgmode/68027 
(unanswered so far and was actually meant to solve a different cosmetic 
problem).

> (3) Using a "line continuation marker"
>
> #+call: mhead-hcard(
>   cname="Dr. Stefan Vollmar",\
>   gname="Stefan",\
>   photo="stefan-vollmar.jpg",\
> ...)

See (1).

> Maybe even with optional comments:
>
> #+call: mhead-hcard(
>   cname="Dr. Stefan Vollmar",\  # full name for headline
>   gname="Stefan",\              # given name
>   photo="stefan-vollmar.jpg",\  # can be jpg or png
> ...)

The comments would still be part of the arguments, so a special form of 
trimming would be needed.

> Maybe there already is a good solution to increase readability?
> Maybe the "line continuation marker" (3) would be a general
> solution for all cases in org where now no line breaks are possible?

Line continuation markers are only really useful with line-by-line 
evaluation or if the whole buffer gets preprocessed, so they are not a 
good solution for Org, IMHO.


Regards,
-- 
Achim.

(on the road :-)

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

* Re: #+call split into multiple lines?
  2013-03-28 21:51     ` Thomas S. Dye
@ 2013-03-29  8:24       ` Stefan Vollmar
  2013-03-29  9:25         ` Achim Gratz
  2013-03-29  9:34         ` feng shu
  0 siblings, 2 replies; 11+ messages in thread
From: Stefan Vollmar @ 2013-03-29  8:24 UTC (permalink / raw)
  To: Thomas S. Dye, Sebastien Vauban, Achim Gratz, Nicolas Goaziou
  Cc: Org Mode Mailing List

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

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"
> <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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: vollmar@nf.mpg.de   http://www.nf.mpg.de









[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4490 bytes --]

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

* Re: #+call split into multiple lines?
  2013-03-29  8:24       ` Stefan Vollmar
@ 2013-03-29  9:25         ` Achim Gratz
  2013-03-29  9:34         ` feng shu
  1 sibling, 0 replies; 11+ messages in thread
From: Achim Gratz @ 2013-03-29  9:25 UTC (permalink / raw)
  To: emacs-orgmode

Am 29.03.2013 09:24, schrieb Stefan Vollmar:
[...]
> 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

It does, see:
http://orgmode.org/manual/Evaluating-code-blocks.html#Evaluating-code-blocks

----->8-----
* Data								   :noexport:
#+name: card-table
| cname | Dr. Stefan Vollmar |
| gname | Stefan             |
| photo | stefan-vollmar.jpg |

#+name: get_named_table_row
#+header: :var key="cname"
#+header: :var table=card-table
#+begin_src emacs-lisp
(cadr (assoc key table))
#+end_src

#+name: mhead-hcard
#+header: :var cname=get_named_table_row(key="cname")
#+header: :var gname=get_named_table_row(key="gname")
#+header: :var photo=get_named_table_row(key="photo")
#+header: :var prefix=""
#+header: :var web="web-page.html"
#+begin_src org :exports none
<div id="contact" class="vcard">
   <p>
     <table style="margin-left:0;margin-right:auto">
       <tr style="text-align: left;margin-left: 2em">
         <td style="padding: 5px">
           <img width="200px" class="photo" src="images/$photo" 
alt="$cname" />
         </td>
         <td><a style="color:blue;" class="url" 
href="http://www.nf.mpg.de/cv/$web">
           <div class="fn n">
             <span class="honorific-prefix">$prefix</span>
             <span class="given-name">$gname</span>
...
#+end_src


* VCard

#+call: mhead-hcard()

#+RESULTS: mhead-hcard()
#+begin_example
<div id="contact" class="vcard">
   <p>
     <table style="margin-left:0;margin-right:auto">
       <tr style="text-align: left;margin-left: 2em">
         <td style="padding: 5px">
           <img width="200px" class="photo" 
src="images/stefan-vollmar.jpg" alt="Dr. Stefan Vollmar" />
         </td>
         <td><a style="color:blue;" class="url" 
href="http://www.nf.mpg.de/cv/web-page.html">
           <div class="fn n">
             <span class="honorific-prefix"></span>
             <span class="given-name">Stefan</span>
...
#+end_example
-----8<-----

> 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?

Possibly.  You might also want to consider noweb syntax or named results.

> 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?

You already get the table as a list of lists structure when referenced 
as a variable in the call, see above.  The variable indexing might 
reasonably be extended to extract named rows and columns so that the 
helper function would not be needed and something like 
cname=card-table["cname",] would be possible, I'd think.


Regards,
-- 
Achim.

(on the road :-)

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

* Re: #+call split into multiple lines?
  2013-03-29  8:24       ` Stefan Vollmar
  2013-03-29  9:25         ` Achim Gratz
@ 2013-03-29  9:34         ` feng shu
  1 sibling, 0 replies; 11+ messages in thread
From: feng shu @ 2013-03-29  9:34 UTC (permalink / raw)
  To: emacs-orgmode

Stefan Vollmar <vollmar@nf.mpg.de> writes:

> 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:

Is it possible to use the below format?

#+name: lists-table
#+BEGIN_SRC org

- 1
  - cname: Dr. Stefan Vollmar
  - gname: Stefan
  - photo: stefan
- 2
  - cname: ...
  - gname: ...
  - photo: ...

#+END_SRC



> #+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"
>> <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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
>> 
>> 

-- 

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

end of thread, other threads:[~2013-03-29  9:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 20:49 #+call split into multiple lines? Stefan Vollmar
2013-03-28 21:17 ` Thomas S. Dye
2013-03-28 21:27   ` Sebastien Vauban
2013-03-28 21:51     ` Thomas S. Dye
2013-03-29  8:24       ` Stefan Vollmar
2013-03-29  9:25         ` Achim Gratz
2013-03-29  9:34         ` feng shu
2013-03-29  2:33     ` Eric Abrahamsen
2013-03-29  2:43       ` Thomas S. Dye
2013-03-29  3:14         ` Eric Abrahamsen
2013-03-29  7:18 ` Achim Gratz

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