From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: org babel, ess, R Date: Wed, 5 Jul 2017 21:42:13 -0700 Message-ID: References: <87mv8o2u9b.fsf@nicolasgoaziou.fr> <3295F295-A14A-43EA-8752-53D1BEBCC31A@agrarianresearch.org> <87fuef1fov.fsf@nicolasgoaziou.fr> <829AC437-872D-453D-8543-B3C147F08B54@agrarianresearch.org> <87inj660la.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSycP-0005we-Hw for emacs-orgmode@gnu.org; Thu, 06 Jul 2017 00:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSycM-0005a4-EL for emacs-orgmode@gnu.org; Thu, 06 Jul 2017 00:42:21 -0400 Received: from iport-bcv4-out.ucsd.edu ([132.239.0.122]:53290) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSycL-0005ZW-U1 for emacs-orgmode@gnu.org; Thu, 06 Jul 2017 00:42:18 -0400 In-Reply-To: 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" To: John Hendy Cc: org-mode mailing list , Vikas Rawal , Nicolas Goaziou On Wed, 5 Jul 2017, John Hendy wrote: > On Wed, Jul 5, 2017 at 4:22 PM, Nicolas Goaziou wrote: >> Hello, >> >> Vikas Rawal writes: >> >>> C-RET seems to be picking up the custom session name if it is already >>> there. But otherwise it generates the default *R* session there, >> >> Is there a bug to fix? If so, could start a new thread about it, ideally >> with an ECM demonstrating the issue? > > I guess Vikas can speak for Vikas, but he was responding to my > observation of the same: > > "... I'd like Org to pick up the fact that there's a :session > argument with a custom name and use that for C-RET in the edit buffer; > otherwise it generates the default *R* session there, but if you C-c > C-c the block later it puts it into the custom session name." This is what `org-babel-switch-to-session-with-code' does. BTW, it also handles Vikas' original issue of displaying both the edit buffer and the process buffer during editing src blocks. So you might want is to use `org-babel-switch-to-session-with-code' rather than `org-edit-src-code'. I do not think I'd want to replace `org-edit-src-code' in `org-edit-special' with that function by default, since it forces a session to start and displays the process buffer which is kind of annoying when all I want to do is browse code in an edit buffer. It fails with an error when applied to a src block with no session, so that would need to be handled if `o-b-s-t-session-w-code' is supplied as an option. HTH, Chuck > > Here's an ECM: > > #+begin_example > > * heading > > #+name: x > #+begin_src R :session r > > x <- 1:10 > > #+end_src > > #+name: y > #+begin_src R :session r > > y <- x^2 > > #+end_src > > #+end_example > > So, say I start working on a document for the day and enter the > editing buffer with C-c ' on block x. I then C-RET from the edit > buffer, which evaluates x and starts a new R session, *R*. Now I'm > done and go on to block y, but don't need to edit. Maybe I just want > to update a plot or other result in the document, so I C-c C-c: > > Error: object 'x' not found > > This really, really common for my work. I define a setup block > somewhere in which I load libraries, read in thousands of lines of > sensor code, and process things (moving averages, summary stats, etc.) > and create my sort of "master object." From there I have sections of a > report that subset the data, plot various things, but typically have > them all set to :eval no by default. If I pick up work on a file, edit > my setup code block, but only interactively because I forget I need to > C-c C-c something first to kick off the custom session, the work was > sort of for naught as everything is in the wrong session. > > In this example, I realize the error and go back to block x and C-c > C-c after failing on block y. At that point, when I go to a block > interactively to do C-RET again, I get this in the minibuffer. > > Process to load into: {r | *R* | *new* } > > Then I switch to *R* to quit() and end the spurious session. > > Really, it was a comment about how Org behaves, not necessarily a bug. > That said, speaking for myself, I would never want a default session > in interactive mode when I've defined one in the code heading. I'd > love if Org could pick up on that setting, such that the first C-RET > of the day dropped into the session named by the block I'm editing. At > present, interactive mode appears to ignore this. > > > Hope that helps clarify, > John > > > > > >> Regards, >> >> -- >> Nicolas Goaziou > > Charles C. Berry Dept of Family Medicine & Public Health cberry at ucsd edu UC San Diego / La Jolla, CA 92093-0901 http://biostat.ucsd.edu/ccberry.htm