From: Dylan Schwilk <firstname.lastname@example.org> To: Jack Kamm <email@example.com> Cc: firstname.lastname@example.org Subject: Re: Help debugging R source code block output problem with :session Date: Sat, 29 Aug 2020 23:18:40 -0500 [thread overview] Message-ID: <87ft84ahr3.fsf@havana> (raw) In-Reply-To: <email@example.com> 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 <firstname.lastname@example.org> 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 . 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. > >  https://github.com/jackkamm/ob-session-async > > From 9eaf81d708f88d06f14f9b6b9cf4182dd0fbb997 Mon Sep 17 > 00:00:00 2001 > From: Jack Kamm <email@example.com> > 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://firstname.lastname@example.org/ 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. --
next prev parent reply other threads:[~2020-08-30 4:19 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-28 20:11 Dylan Schwilk 2020-08-29 2:36 ` Jack Kamm 2020-08-29 4:07 ` Dylan Schwilk 2020-08-29 7:24 ` Jack Kamm 2020-08-29 20:35 ` Berry, Charles via General discussions about Org-mode. 2020-08-30 4:37 ` Dylan Schwilk 2020-08-30 15:08 ` Jack Kamm 2020-09-07 8:18 ` Jack Kamm 2020-09-07 8:45 ` Jack Kamm 2020-09-07 17:37 ` Berry, Charles via General discussions about Org-mode. 2020-09-07 20:07 ` Jack Kamm 2020-09-07 22:12 ` Berry, Charles via General discussions about Org-mode. 2020-09-08 1:06 ` Jack Kamm 2020-09-08 2:08 ` Berry, Charles via General discussions about Org-mode. 2020-09-08 14:51 ` Jack Kamm 2020-09-08 16:45 ` Berry, Charles via General discussions about Org-mode. 2020-09-08 17:41 ` Jack Kamm 2020-09-18 16:39 ` Dylan Schwilk 2020-10-28 13:13 ` Jack Kamm 2020-10-28 13:46 ` Jeremie Juste 2020-08-30 4:18 ` Dylan Schwilk [this message] 2021-05-03 8:53 ` Jeremie Juste 2022-01-11 23:36 John Hendy 2022-01-12 7:49 ` Jeremie Juste 2022-01-12 15:04 ` John Hendy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=87ft84ahr3.fsf@havana \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: Help debugging R source code block output problem with :session' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).