all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas S. Dye <tsd@tsdye.com>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Generate BEGIN_EXAMPLE block dynamically during export
Date: Tue, 16 Feb 2016 10:02:13 -1000	[thread overview]
Message-ID: <m237ssxw3e.fsf@tsdye.com> (raw)
In-Reply-To: <CAFyQvY1mekN5Vkbo=XQUyWK=6CTVugjxLWX-N2PHXgfSepTa7w@mail.gmail.com>

Aloha Kaushal,

Kaushal Modi writes:

> Hi all,
>
> I'd like to have an EXAMPLE block in my org file whose value is set using
> something like an org macro at the time of export.
>
> So, something like:
>
> #+MACRO TAR_FILE some_file.tar.gz
>
> #+BEGIN_EXAMPLE
>> tar xvzf {{{TAR_FILE}}}
> #+END_EXAMPLE
>
> As the above is not possible, what would be a good way to generate the
> EXAMPLE block on the fly during export with the value of {{{TAR_FILE}}}
> replaced based on the macro definition?

You might use babel instead of a macro:

,---------------------------------------------------------------------------
| #+name: tar-eg                                                            
| #+header: :var tar-file=""                                                
| #+begin_src emacs-lisp                                                    
| (format "> tar xzvf %s" tar-file)                                         
| #+end_src                                                                 
|                                                                           
| #+CALL: tar-eg(tar-file="some_file.tar.gz") :wrap example :exports results
|                                                                           
| #+results:                                                                
| #+BEGIN_example                                                           
| > tar xzvf some_file.tar.gz                                               
| #+END_example                                                             
`---------------------------------------------------------------------------

hth,
Tom

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

  reply	other threads:[~2016-02-16 20:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 19:10 Generate BEGIN_EXAMPLE block dynamically during export Kaushal Modi
2016-02-16 20:02 ` Thomas S. Dye [this message]
2016-02-16 20:51   ` Kaushal Modi
2016-02-16 21:03     ` Thomas S. Dye
2016-02-16 21:16       ` Kaushal Modi
2016-02-16 21:47         ` Kaushal Modi
2016-02-16 22:18           ` Thomas S. Dye
2016-02-16 22:20             ` Kaushal Modi
2016-02-16 22:28           ` Nick Dokos
2016-02-16 22:40             ` Kaushal Modi
2016-02-16 23:10               ` Kaushal Modi

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m237ssxw3e.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.