From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "T.F. Torrey" <tftorrey@tftorrey.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Macro expansion in new exporter
Date: Fri, 15 Feb 2013 14:05:03 +0100 [thread overview]
Message-ID: <87mwv57mo0.fsf@gmail.com> (raw)
In-Reply-To: <87txpdj2rj.fsf@lapcat.tftorrey.com> (T. F. Torrey's message of "Fri, 15 Feb 2013 03:21:52 -0700")
tftorrey@tftorrey.com (T.F. Torrey) writes:
> Perhaps. We still know of no easy/straightforward way at all to
> replicate using babel the behavior I had (creating '<p
> class="foo">bar</p>' with a macro), let alone in a pair of single
> lines.
Here is an example. Babel specialists can help you further.
--8<---------------cut here---------------start------------->8---
Define your Babel macro.
#+name: html-foo
#+begin_src org :exports none :results raw :var data=""
,#+HTML: <p class="foo">$data</p>
#+end_src
Now, use it anywhere in the code, any number of times.
#+CALL: html-foo(data="bar") :results raw
--8<---------------cut here---------------end--------------->8---
There are many, often shorter, other ways to do it.
> Macros are so straightforward compared to babel, I wonder how much
> trouble they /could/ generate.
Not as much as Babel, obviously. But since blank lines are significant
in Org, allowing blank lines in macros could change structure.
> I wonder if an entry in the (underused) Library of Babel could replicate
> the macro functionality and eliminate the need for macros as separate
> things. I will have to look into that when I have more time.
You can install the example given above in you Library of Babel.
> I'm pretty sure I could replicate (and even expand) the old macro
> functionality by hooking an expansion function into
> org-export-before-parsing-hook. Maybe I will write an extension to
> try.
I'd rather have users use macros for short replacements, which is where
they really shine, and Babel for programmable ones. Your extension
wouldn't help at that. But that's your call, obviously.
For the record, I have had to rewrite the macro code two times. This is
to say it is difficult to get them right, if possible at all.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2013-02-15 13:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 23:08 Macro expansion in new exporter T.F. Torrey
2013-02-09 8:04 ` Nicolas Goaziou
2013-02-12 10:00 ` T.F. Torrey
2013-02-12 17:56 ` Nicolas Goaziou
2013-02-12 20:30 ` T.F. Torrey
2013-02-13 16:36 ` Nicolas Goaziou
2013-02-15 10:21 ` T.F. Torrey
2013-02-15 13:05 ` Nicolas Goaziou [this message]
2013-02-15 20:42 ` T.F. Torrey
2013-02-15 21:17 ` Nicolas Goaziou
2013-02-15 22:37 ` T.F. Torrey
2013-02-15 21:26 ` Nick Dokos
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=87mwv57mo0.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tftorrey@tftorrey.com \
/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).