[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [babel] would like to to do simple text block expansion with par
From: |
Eric Schulte |
Subject: |
Re: [O] [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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) |
"Olaf.Hamann" <address@hidden> 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/