From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] would like to to do simple text block expansion with parameters or multiline macro replacement text Date: Sat, 21 Apr 2012 11:33:40 -0400 Message-ID: <87y5ppnlpn.fsf@gmx.com> References: <4F8077B8.2010603@gmx.net> <4F86B6A3.5070203@gmx.net> <4F929586.8050005@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLeC9-0003z2-Rp for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 13:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SLeC5-0001CX-KI for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 13:34:01 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:41005) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SLeC5-0001CR-Cr for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 13:33:57 -0400 In-Reply-To: <4F929586.8050005@gmx.net> (Olaf Hamann's message of "Sat, 21 Apr 2012 13:09:58 +0200") 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: "Olaf.Hamann" Cc: emacs-orgmode@gnu.org "Olaf.Hamann" writes: >> I think I will try to adapt m4 as org-language so that it can be used >> for executing src-blocks. > > m4 is no solution as it does not support multibyte character > > I missed the beginning of this thread, but would the following very simple support for text block evaluation be sufficient? #+begin_src emacs-lisp (defun org-babel-expand-body:text (body params) (mapc (lambda (pair) (let ((name (symbol-name (car pair))) (value (cdr pair))) (setq body (replace-regexp-in-string (concat "\$" (regexp-quote name)) (if (stringp value) value (format "%S" value)) body)))) (mapcar #'cdr (org-babel-get-header params :var))) body) (defun org-babel-execute:text (body params) (org-babel-expand-body:text body params)) #+end_src #+begin_src text :var name="Eric" Hi, my name is $name. #+end_src #+RESULTS: : Hi, my name is Eric. -- Eric Schulte http://cs.unm.edu/~eschulte/