From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: [BABEL] BUG Re: Omitting try/catch blocks from tangled R code? Date: Tue, 11 Mar 2014 20:13:34 -0500 Message-ID: References: <52F498AE.6090802@krugs.de> <87siruamo3.fsf@gmail.com> <52F5326C.7010505@krugs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNXjl-000664-R3 for emacs-orgmode@gnu.org; Tue, 11 Mar 2014 21:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNXjk-0006Ny-5x for emacs-orgmode@gnu.org; Tue, 11 Mar 2014 21:13:37 -0400 Received: from mail-oa0-x22e.google.com ([2607:f8b0:4003:c02::22e]:63136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNXjj-0006MC-VV for emacs-orgmode@gnu.org; Tue, 11 Mar 2014 21:13:36 -0400 Received: by mail-oa0-f46.google.com with SMTP id i7so9391683oag.5 for ; Tue, 11 Mar 2014 18:13:35 -0700 (PDT) In-Reply-To: <52F5326C.7010505@krugs.de> 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: Rainer@krugs.de Cc: emacs-orgmode , Eric Schulte On Fri, Feb 7, 2014 at 1:22 PM, Rainer M Krug wrote: > > > > On 02/07/14, 17:47 , Eric Schulte wrote: > > Rainer M Krug writes: > > > >> On 02/07/14, 07:18 , John Hendy wrote: > >>> Greetings, > >>> > >>> > >>> I don't usually tangle, but am creating a code file to go along with a > >>> presentation I'm giving this weekend so that attendees can try things > >>> out afterward by cloning my github repo where all the data and > >>> necessary files are stored. > >>> > >>> In my presentation (Beamer), I create plots via the R pdf() device, > >>> and noticed that all of the tangled code where plots are generated > >>> contains the following: > >>> > >>> pdf(file="file.pdf"); tryCatch({ > >>> > >>> code block contents here > >>> > >>> },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', > >>> axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); > >>> paste('ERROR', e$message, sep=' : ')}); dev.off() > >>> > >>> Is there a way to omit this? > >> > >> This is a bug which must have been introduced some time ago - in the > >> stock version of emacs (Org-mode version 7.9.3f > >> (release_7.9.3f-17-g7524ef @ > >> /usr/local/Cellar/emacs/24.3/share/emacs/24.3/lisp/org/)) it does not > >> tangle the enclosing commands to create graphics, but in 8.2 it does (I > >> don't have an older version at hand to go further back). > >> > > > > I believe this was introduced by your commit eaa3a761d. Reversion of > > which with the following should provide a temporary workaround. > > I checked it with version 8.2, which was, as far as I remember, before > my change of the R code to include the error handling, and the pdf(...) > ... dev.off() was in the tangled file as well - so the behaviour must > have been introduced earlier. The only change I did was to change the R > code, so no change in the behavior if it is tangled or not. > > I will look at it again on Monday to go back through the released > versions to narrow down where this had changed. > > Just following up on this to see if the current behavior is desired or if, indeed, something should/could change. Thanks! John > > > > git revert eaa3a761d > > I don't think that this actually changes much - only that the enclosing > code will become pdf(...) THE CODE dev.off() > > Cheers, > > Rainer > > > > > Perhaps the try/catch code should be moved from org-babel-expand-body:R > > to org-babel-execute:R. Alternately, the code should stay as is and you > > should use the no-expand header argument during tangling. > > > > I'm not sure which makes the most sense, but I'd lean towards the > > former. > > > > Best, > > > >> > >>> > >>> I'm guessing this is here to create a blank plot with the error as the > >>> output when something goes awry? > >> > >> Yes. > >> > >>> > >>> I checked around variable completions of org-babel-tangle-* and > >>> searched google for terms like "org babel tangle try catch" but am not > >>> finding anything that looks like what I need. > >> > >> There is nothing, as it should not be tangled. The enclosing commands > >> concern the export, but not tangling, > >> > >> I agree that the :result graphics header argument caused commands should > >> not be in the tangled file. > >> > >> Another question is about the :epilogue and :prologue which I think > >> should be present (haven't checked if they are...). > >> > >> Cheers, > >> > >> Rainer > >> > >> > >>> > >>> > >>> Thanks, > >>> John > >>> > > > > -- > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation > Biology, UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Stellenbosch University > South Africa > > Tel : +33 - (0)9 53 10 27 44 > Cell: +33 - (0)6 85 62 59 98 > Fax : +33 - (0)9 58 10 27 44 > > Fax (D): +49 - (0)3 21 21 25 22 44 > > email: Rainer@krugs.de > > Skype: RMkrug >