Perry Smith <[email protected]> writes:

> So I developed include-if and omit-if macros and thought I would share what I 
> did:

Thanks for sharing!

>> [...]
>> # A macro to incude the second argument if the first argument is a
>> # selected tag.
>> #+MACRO: include-if (eval (if (member $1 (plist-get 
>> (org-export--get-inbuffer-options) :select-tags)) $2))
>> [...]
>> # Arguments to macros can be macros but must not have arguments of
>> # their own.  Thus a macro must be defined to produce the desired text
>> # without any arguments. e.g.
>> #+MACRO: bold *$1*
>> #+MACRO: bold-happy {{{bold(happy)}}}

Not really. As noted in another branch of this thread, macros can be
nested, and the inner macro can have an argument. At least in practice,
if not in theory. :)

>> # Results: include-if *happy* after
>> # Since blah is selected, this results in a bold happy being exported
>> include-if {{{include-if(blah, {{{bold-happy}}})}}} after

So {{{include-if(blah, {{{bold(happy)}}})}}} works just as well.

Regards,
Christian

PS. There does seem to be a problem with using more than one argument in a
macro that is an argument to another macro, though. At least, I haven't
got it to work.

E.g., here's an example macro that generalizes your "bold" macro by
taking two arguments, a text and a string to mark it up with on both
sides.

  #+MACRO: markup $2$1$2

  {{{markup(italicized,/)}}}

results in /italicized/, i.e. the word "italicized" is exported in
italics. But

  {{{include-if(blah, {{{markup(italicized,/)}}})}}}

only results in the word "italicized", without italics. So it seems only
the first argument is recognized.

It is fortunate that neither of these examples, "bold" or "markup", is
actually needed in Org...

Reply via email to