From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas S. Dye Subject: Re: Generate BEGIN_EXAMPLE block dynamically during export Date: Tue, 16 Feb 2016 10:02:13 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVlpZ-0005kf-6Z for emacs-orgmode@gnu.org; Tue, 16 Feb 2016 15:02:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVlpU-0002Hl-4O for emacs-orgmode@gnu.org; Tue, 16 Feb 2016 15:02:41 -0500 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:33819) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1aVlpT-0002Cc-TO for emacs-orgmode@gnu.org; Tue, 16 Feb 2016 15:02:36 -0500 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kaushal Modi Cc: emacs-org list 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