From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id V0dDCNooS1/ZJwAA0tVLHw (envelope-from ) for ; Sun, 30 Aug 2020 04:19:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id ALjzA9ooS1/zLQAA1q6Kng (envelope-from ) for ; Sun, 30 Aug 2020 04:19:38 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 87B3394050D for ; Sun, 30 Aug 2020 04:19:37 +0000 (UTC) Received: from localhost ([::1]:33892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCEoZ-0003lY-Of for larch@yhetil.org; Sun, 30 Aug 2020 00:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCEo0-0003lP-8J for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 00:19:00 -0400 Received: from aibo.runbox.com ([91.220.196.211]:46802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCEny-0005mx-5L for emacs-orgmode@gnu.org; Sun, 30 Aug 2020 00:18:59 -0400 Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1kCEns-0001Z4-Md; Sun, 30 Aug 2020 06:18:52 +0200 Received: by submission03.runbox with esmtpsa [Authenticated alias (611856)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1kCEnj-00070m-1F; Sun, 30 Aug 2020 06:18:43 +0200 References: <87r1rqled0.fsf@havana> <87k0xifa9h.fsf@gmail.com> <87d03art6a.fsf@havana> <87h7slgbi5.fsf@gmail.com> User-agent: mu4e 1.4.3; emacs 26.3 From: Dylan Schwilk To: Jack Kamm Subject: Re: Help debugging R source code block output problem with :session In-reply-to: <87h7slgbi5.fsf@gmail.com> Date: Sat, 29 Aug 2020 23:18:40 -0500 Message-ID: <87ft84ahr3.fsf@havana> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Received-SPF: permerror client-ip=91.220.196.211; envelope-from=dylan@schwilk.org; helo=aibo.runbox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/30 00:18:53 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: P8yJcT0pe9Yf Yes, the modified comint-prompt-regexp works for my use cases and I'm back to expected output and what I had last time I taught the course. This was my instinct for a simple solution as well, but I've not tested against remote sessions and graphical outputs as Charles Berry warns. I'll take a look at your ob-session-async, thanks! -Dylan On Sat 29 Aug 2020 at 02:24, Jack Kamm wrote: > Hi Dylan, > >> The patch does fix that issue -- but it introduces a different >> bug >> for code blocks with ~:session~: the R block now only produces >> output from the last statement evaluated. > > Of course, you're right. Good catch. > > Here's another attempt. It fixes the issue by modifying the R > comint > regular expression, requiring it to match at the beginning of > the line. > > I think this should fix most cases, including the examples you > sent. Still, it's not totally robust -- for example, it will > still > mangle multiline strings, if one of the lines starts with a > substring > that looks like a prompt. > > I'd be interested to hear if the attached patch works for the > common > cases you encounter, such as with tibbles. > > As an aside, I personally use an alternative implementation of > ob-R > sessions that doesn't suffer from this issue, and also provides > some > other benefits like async evaluation [1]. I'm planning to submit > these > changes to org-mode someday, but am not ready yet. But you may > want to > check it out, it was able to solve the issue in the other thread > I > linked as well. > > [1] https://github.com/jackkamm/ob-session-async > > From 9eaf81d708f88d06f14f9b6b9cf4182dd0fbb997 Mon Sep 17 > 00:00:00 2001 > From: Jack Kamm > Date: Sat, 29 Aug 2020 00:07:58 -0700 > Subject: [PATCH] ob-R: Fix prompt mangling in session output > > * lisp/ob-R.el (org-babel-R-evaluate-session): Force comint > prompt > regexp to start at beginning of line, to prevent > org-babel-comint-with-output from splitting mid-line. > > Fixes https://orgmode.org/list/875zgjh8wn.fsf@gmail.com/ and > https://orgmode.org/list/87r1rqled0.fsf@havana/ > --- > lisp/ob-R.el | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/lisp/ob-R.el b/lisp/ob-R.el > index 5e9d35f58..10b3b6fe3 100644 > --- a/lisp/ob-R.el > +++ b/lisp/ob-R.el > @@ -450,11 +450,13 @@ (defun org-babel-R-evaluate-session > (car (split-string line "\n"))) > (substring line (match-end 1)) > line)) > - (org-babel-comint-with-output (session > org-babel-R-eoe-output) > - (insert (mapconcat 'org-babel-chomp > - (list body > org-babel-R-eoe-indicator) > - "\n")) > - (inferior-ess-send-input)))))) "\n")))) > + (with-current-buffer session > + (let ((comint-prompt-regexp (concat "^" > comint-prompt-regexp))) > + (org-babel-comint-with-output (session > org-babel-R-eoe-output) > + (insert (mapconcat 'org-babel-chomp > + (list body > org-babel-R-eoe-indicator) > + "\n")) > + (inferior-ess-send-input)))))))) "\n")))) > > (defun org-babel-R-process-value-result (result column-names-p) > "R-specific processing of return value. --