From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mikhail Titov" Subject: Re: [babel, patch] ob-octave does not catch EOE from matlabShell on MS Windows Date: Tue, 29 May 2012 12:00:44 -0500 Message-ID: <015201cd3dbc$970d2720$c5277560$@us> References: <00f901cd39f0$7da5bb00$78f13100$@us> <00ff01cd39f4$7feec3d0$7fcc4b70$@us> <010501cd3a93$ccb65f80$66231e80$@us> <010801cd3a96$d0ac2360$72046a20$@us> <87r4u4s1jj.fsf@gmx.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0153_01CD3D92.AE371F20" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZPmx-0000MU-Ml for emacs-orgmode@gnu.org; Tue, 29 May 2012 13:01:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZPmr-0005l8-SN for emacs-orgmode@gnu.org; Tue, 29 May 2012 13:00:55 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:35591 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SZPmr-0005jr-Lg for emacs-orgmode@gnu.org; Tue, 29 May 2012 13:00:49 -0400 In-Reply-To: <87r4u4s1jj.fsf@gmx.com> Content-Language: en-us 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: 'Eric Schulte' Cc: emacs-orgmode@gnu.org This is a multi-part message in MIME format. ------=_NextPart_000_0153_01CD3D92.AE371F20 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit > -----Original Message----- > From: Eric Schulte [mailto:eric.schulte@gmx.com] > Sent: Monday, May 28, 2012 10:57 AM > To: Mikhail Titov > Cc: emacs-orgmode@gnu.org > Subject: Re: [O] [babel, patch] ob-octave does not catch EOE from matlabShell > on MS Windows > > ... > >> > >> It looks like org-babel-octave-eoe-output and org-babel-octave-eoe- > indicator > >> were swapped around in org-babel-octave-evaluate-session . > >> > >> I have the following in dot emacs > >> > >> (setq org-babel-octave-eoe-output " > >> ans = > >> > >> org_babel_eoe > >> > >> ") > > > > For the sake of completeness I'm attaching the patch. Also one should > override > > > > (setq org-babel-matlab-emacs-link-wrapper-method > > "%s > > if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); > fclose(fid); else, save -ascii %s ans ; end > > delete('%s') > > ") > > > > as matlabShell does not like commands split across multiple lines. > > > > Thanks for sending along the patch and the variable re-definition. I was in the hurry and the second variable should have been (setq org-babel-octave-wrapper-method "%s if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid); else, dlmwrite('%s', ans, '\\t'); end") and not org-babel-matlab-emacs-link-wrapper-method . The only difference from what is already in there, is that it should be a single line (with ; delimiters). It might be a limitation of matlabShell. >From what I understand EmacsLink is something outdated and not supported anymore as there is matlab-emacs mode. Also the patch was missing yet another change to use single quotes instead of double quotes when making default figures invisible. I'm attaching the patch I ended up using. > If I > understand correctly then the patch should be applied for any system, > but the variable definition need only be applied on windows systems. Is > that correct? Unfortunately I don't have Matlab installed on my home GNU/Linux computer, I'll see if I'm eligible and can get one. What bugs me though is that I can't use both octave and matlab as they use same variable (org-babel-octave-eoe-output) which should be set to different values. In org-babel-comint-with-output macro (ob-comint.el) it is used to check if shell/REPL is done with evaluation and ready for input. I wonder if it is possible to generalize org-babel-octave-eoe-output for both matlab and octave as the only difference is the bunch of newlines in Matlab output. One may write a regexp that matches both, however "(regexp-quote ,eoe-indicator)" in aforementioned macro confuses me. So it got to be a plain string. M. > Can anyone confirm that matlab/octave code blocks are still functional > on a GNU/Linux machine after the above patch and redefinition have been > applied? I do not use octave/matlab myself and can't verify this. > > If they don't break anything I'm happy to apply these patches. > > Thanks, > > -- > Eric Schulte > http://cs.unm.edu/~eschulte ------=_NextPart_000_0153_01CD3D92.AE371F20 Content-Type: application/octet-stream; name="ob-octave_matlab_updated.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ob-octave_matlab_updated.patch" diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el=0A= index 9e85757..6428c8c 100644=0A= --- a/lisp/ob-octave.el=0A= +++ b/lisp/ob-octave.el=0A= @@ -90,7 +90,7 @@ end")=0A= (if (org-babel-octave-graphical-output-file params)=0A= (mapconcat 'identity=0A= (list=0A= - "set (0, \"defaultfigurevisible\", \"off\");"=0A= + "set (0, 'defaultfigurevisible', 'off');"=0A= full-body=0A= (format "print -dpng %s" (org-babel-octave-graphical-output-file = params)))=0A= "\n")=0A= @@ -231,8 +231,8 @@ value of the last statement in BODY, as elisp."=0A= (org-babel-comint-with-output=0A= (session=0A= (if matlabp=0A= - org-babel-octave-eoe-indicator=0A= - org-babel-octave-eoe-output)=0A= + org-babel-octave-eoe-output=0A= + org-babel-octave-eoe-indicator)=0A= t full-body)=0A= (insert full-body) (comint-send-input nil t)))) results)=0A= (case result-type=0A= ------=_NextPart_000_0153_01CD3D92.AE371F20--