emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] bug in expansion of variables in babel Perl


From: Achim Gratz
Subject: Re: [O] bug in expansion of variables in babel Perl
Date: Sun, 24 Feb 2013 14:08:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (gnu/linux)

D M German writes:
[…]

Please leave the formats alone, if you change the number of parameters
there folks that use their own definitions won't know what hit them.
What you want is to prepend something to the body that Babel gives you,
so let-bind that result and use it.  You could even advise the function
and have it submit to your will without changing Org.

--8<---------------cut here---------------start------------->8---
(defun org-babel-perl-evaluate (session ibody &optional result-type)
  "Pass BODY to the Perl process in SESSION.
If RESULT-TYPE equals 'output then return a list of the outputs
of the statements in BODY, if RESULT-TYPE equals 'value then
return the value of the last statement in BODY, as elisp."
  (when session (error "Sessions are not supported for Perl"))
  (let ((body (concat org-babel-perl-preface ibody)))
    (case result-type
      (output (org-babel-eval org-babel-perl-command body))
      (value (let ((tmp-file (org-babel-temp-file "perl-")))
               (org-babel-eval
                org-babel-perl-command
                (format org-babel-perl-wrapper-method body
                        (org-babel-process-file-name tmp-file 'noquote)))
               (org-babel-eval-read-file tmp-file))))))
--8<---------------cut here---------------end--------------->8---


BTW, now that I think some more about it: debugging Perl is much easier
than you seem to let on:

(setq org-babel-perl-command "perl -Mstrict -ne print").

This will echo the program sent to Perl in full glory into the output
block.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]