From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0IbsJcoZkF6nLgAA0tVLHw (envelope-from ) for ; Fri, 10 Apr 2020 07:01:30 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cEb1A8wZkF6ReAAAbx9fmQ (envelope-from ) for ; Fri, 10 Apr 2020 07:01:32 +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 aspmx2.migadu.com (Postfix) with ESMTPS id 48C8C68227B for ; Fri, 10 Apr 2020 07:01:29 +0000 (UTC) Received: from localhost ([::1]:59296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMnfL-0007Ej-Gq for larch@yhetil.org; Fri, 10 Apr 2020 03:01:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMmWW-00068I-94 for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 01:48:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMmWV-00083s-A1 for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 01:48:16 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:36846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMmWV-00083R-2v for emacs-orgmode@gnu.org; Fri, 10 Apr 2020 01:48:15 -0400 Received: by mail-pf1-x430.google.com with SMTP id n10so647339pff.3 for ; Thu, 09 Apr 2020 22:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=HNkfGgxZUQee/Bc7RHmLpD3gMJScJHhJ0Y6GrPfb2xo=; b=SboSR68QfpVbBXnIwX5Us2SZB/5oiDON+C2VERIK2VskN0alrTLfCI4iKIpji1r4Vc oshlEhu+aWcDzW5mC5mhlLwjCyONr7+2yxEBpfNWydIxBka5yLI4pr8WMntLWE6SKFJ6 JeVkaDpbGAiQvgGdxYlW9CBy25g278t155sSVwws/8vhgJLUjAeJcL5JeBt+zTFRHF40 oIZm1J7tZCbG/W9V6UJmFsMAbAvmk7whqPLXtoyqNw2BCcoTvo6BJFN4snf4bs8GZWJ+ AV0zBhe5XZyYx7F6jL9dr4V7Az4921pukryV0YR4K5txiYrdoS4VN2S0HkmdwnLO6lc6 bvHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=HNkfGgxZUQee/Bc7RHmLpD3gMJScJHhJ0Y6GrPfb2xo=; b=uHRvWHDfiW3gPWUk8ydFx4zeUb/4I6kbsvjSaArG3vGQgI0EwPD3gIR6FDtSBGab5F EOYsfW2HVmanusykKDSpMdS+wRo2wR2wxgAUvoZNmG8DNZ84Uq2olu+SO+cwTUu6SpPt ZS9OFzfNSd0oov8YQCIynZsZwFVo9OIIUsq/Hg2KcvYkaxcSuTXLrnuo1B+V6wXugz/H r3IcGhrazIQeWCW29AmTdf+35VSnwx70vdzhNu5ArCia4o3Pm00inlPE9yqm8AJjP9nu Zjco6ifFQEC4zUqFlGqq3qlnkb+eyDkhy9AkKK30o1R9pNSB0ouy7e6hUokEk/qipocD GwTQ== X-Gm-Message-State: AGi0Puba1K3e6fo0cgAwW5hx9Q3g6R04CxOmSFeMjfrNgDGoZaSkrQKm 0T5XOnSmwRGygvLbxqnPaRO60/hiFZo= X-Google-Smtp-Source: APiQypLwRBKgZdW9JWbvZLj+P8O3G0a52fImbv05dHeLgrpflcnxB4g3cEBgIHOAMLliISHfpz39bA== X-Received: by 2002:a63:460a:: with SMTP id t10mr3083138pga.105.1586497693321; Thu, 09 Apr 2020 22:48:13 -0700 (PDT) Received: from localhost (ip98-171-160-254.sb.sd.cox.net. [98.171.160.254]) by smtp.gmail.com with ESMTPSA id f4sm744923pjk.33.2020.04.09.22.48.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 22:48:12 -0700 (PDT) From: Karthik Chikmagalur To: emacs-orgmode@gnu.org Subject: Org-babel Matlab (session) output is malformed Date: Thu, 09 Apr 2020 22:48:11 -0700 Message-ID: <86eesvopr8.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::430 X-Mailman-Approved-At: Fri, 10 Apr 2020 03:00:56 -0400 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586502090; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=HNkfGgxZUQee/Bc7RHmLpD3gMJScJHhJ0Y6GrPfb2xo=; b=Co6/bXBi856rc2WAnjsMY5M3Jc3iQkRLdd3eBVUpIXAh/5opaNVIKaKCKe7pfNzjtrvsOA GDQerVLdxUPS5WnrDVaF8QmV65PZdIHvWNxDpHLPzzeNF+Mi7GvLBIdvT9S6or8i8DAFYi HKs1zTocsfb2cctksLGBPygcdia7IF4= ARC-Seal: i=1; s=default; d=yhetil.org; t=1586502090; a=rsa-sha256; cv=none; b=WGe47EdTLvav+jXYLOSpZmNIO+aAVvzabYIyTJwe8rxShEjKWr9JzgzNl1N7KxllXxG5pK ju60A2ly+R+KuJJ+i4qQsSjlnhbiY9wsRNBQ1Frdj6WZUX49z4gnyW/W/Pip2TRk5y4Y78 8eOAFYld9Tv81CYEX0M8IKzwVLAQs40= ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SboSR68Q; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx2.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-Scanner: scn0 X-Spam-Score: -1.71 Authentication-Results: aspmx2.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SboSR68Q; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx2.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-Scan-Result: default: False [-1.71 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.58018427817302]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; ARC_SIGNED(0.00)[i=1]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.30), country: US(-0.01), ip: 209.51.188.17(-0.58)]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.50)[eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_NEQ_ENVFROM(0.00)[karthikchikmagalur@gmail.com,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: RWJgY9UHJ6Tv I'm trying to evaluate some Matlab code using org-babel in a session: #+BEGIN_SRC matlab :session :results output a = 4; b = a + 3 c = a - 3 #+END_SRC And following the org-babel documentation, (something like) this is the output I expect: #+RESULTS: #+begin_example b = 7 c = 1 #+end_example But this is the output I get: #+RESULTS: #+begin_example a = 4; b = a + 3 b = 7 c = a - 3 c = 1 'org_babel_eoe' ans = 'org_babel_eoe' #+end_example (Including the =#+begin_example= etc) After going through the source of the function =org-babel= calls, here is what's supposed to happen: 1. =org-babel-octave-evaluate-session= copies the code into the Matlab REPL (calling =matlab-shell= if necessary) and the shell runs it. 2. It then copies the result back as a string up to the end-of-evaluation token, and then removes the original code from the output string. it looks like =org-babel-octave-evaluate-session= is not reading the end-of-evaluation token (='org_babel_eoe'=) correctly, and not removing the input code from the resulting string either. This looks like it should be an easy fix, but I couldn't figure it out. Any ideas how to fix this? Notes: 1. The relevant function(s) are in =/usr/share/emacs/27.0.90/lisp/org/ob-octave.el= or equivalent location. I am using Emacs 27.0.90. 2. The same org-babel module pulls double duty for Octave and Matlab with a flag to distinguish between uses, hence the name. When I run the same test as an Octave source block it runs correctly: #+BEGIN_SRC octave :session :results output a = 4; b = a + 3 c = a - 3 #+END_SRC #+RESULTS: : : b = 7 : c = 1 3. This issue regards evaluation of source blocks with the =:results output= option, where org-babel includes in the results block everything that the REPL prints to stdout. (This is different from the default =:results value= option where only the return value of the block is considered as a result.) - Karthik