From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: bug in expansion of variables in babel Perl Date: Sun, 24 Feb 2013 13:17:32 +0100 Message-ID: <87txp1zz1f.fsf@Rainer.invalid> References: <87ppzq138q.fsf@mn.cs.uvic.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9aWv-0006Pp-D8 for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 07:18:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9aWt-0002yz-Qq for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 07:18:09 -0500 Received: from plane.gmane.org ([80.91.229.3]:46631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9aWt-0002yO-Jp for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 07:18:07 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1U9aX7-0001N7-Ml for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 13:18:21 +0100 Received: from pd9eb24c2.dip.t-dialin.net ([217.235.36.194]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Feb 2013 13:18:21 +0100 Received: from Stromeko by pd9eb24c2.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 24 Feb 2013 13:18:21 +0100 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: emacs-orgmode@gnu.org D M German writes: > I see two ways to solve this. The first is simply to replace the output > format of the variable from "%S" to "'%s'" (use quotes '). I think that's the right thing to do. There shouldn't be anything in the table that needs to be interpolated by Perl while the variable is defined. > + (format "'%s'" var))) A slightly more perlish way would be to use (format "q(%s)" var))) > Debugging perl is very cumbersome in org-mode. It would be nice to have > a feature to export the source to a file. This is because the variable > expansion needs to be done before the code can be used (hence simply cut > and paste does not work, nor shell-command-on-region) The other languages have the same problem, maybe there should be a general option to mirror the commands into a source block in the org file or to make the buffer with the program to be eval'ed stick around. Eric, WDYT? Also, I'm not really sure why we need all the complexity of shell-command-on-region when it looks like we should be able to call-process-region ourselves. Modifying Babel to run (non-session and perhaps optionally) from files instead of buffers seems to be a more wide-reaching operation. > As we are into it, I found this declaration to be very useful. […] I think this is better done by altering org-babel-perl-command to include "-Mstrict". If you put the helper functions into a module in @INC or tell Perl where to find them, then you can add "-Mmyhelper" as well. Here's a wrapper to match: (defvar org-babel-perl-wrapper-method "{ my @r = eval( q(%s) ); open my $BO, qq(>%s)); print $BO join($\\, @r), $\\ ; }") For your problem with :results output blocks, I think it would be possible to wrap them (a bit differently) also, but the "helper module" above would also solve this problem, so let's see what Eric says since I don't know if another language has already set a precedent of wrapping these commands too. > > Finally, if interested, i can write a couple of examples for Perl that > could help people who want to use it. Also a few tests would be highly welcome. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ SD adaptations for KORG EX-800 and Poly-800MkII V0.9: http://Synth.Stromeko.net/Downloads.html#KorgSDada