emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: feng shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: #+call split into multiple lines?
Date: Fri, 29 Mar 2013 17:34:07 +0800	[thread overview]
Message-ID: <84li9635yo.fsf@gmail.com> (raw)
In-Reply-To: <3741EDEB-8A94-4402-85D3-D74236811F97@nf.mpg.de> (Stefan Vollmar's message of "Fri, 29 Mar 2013 09:24:19 +0100")

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

-- 

  parent reply	other threads:[~2013-03-29  9:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=84li9635yo.fsf@gmail.com \
    --to=tumashu@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).