emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Mikhail Titov" <mlt@gmx.us>
To: 'Eric Schulte' <eric.schulte@gmx.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel, patch] ob-octave does not catch EOE from matlabShell on MS Windows
Date: Tue, 29 May 2012 12:00:44 -0500	[thread overview]
Message-ID: <015201cd3dbc$970d2720$c5277560$@us> (raw)
In-Reply-To: <87r4u4s1jj.fsf@gmx.com>

[-- Attachment #1: Type: text/plain, Size: 2983 bytes --]

> -----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

[-- Attachment #2: ob-octave_matlab_updated.patch --]
[-- Type: application/octet-stream, Size: 882 bytes --]

diff --git a/lisp/ob-octave.el b/lisp/ob-octave.el
index 9e85757..6428c8c 100644
--- a/lisp/ob-octave.el
+++ b/lisp/ob-octave.el
@@ -90,7 +90,7 @@ end")
 		  (if (org-babel-octave-graphical-output-file params)
 		      (mapconcat 'identity
 				 (list
-				  "set (0, \"defaultfigurevisible\", \"off\");"
+				  "set (0, 'defaultfigurevisible', 'off');"
 				  full-body
 				  (format "print -dpng %s" (org-babel-octave-graphical-output-file params)))
 				 "\n")
@@ -231,8 +231,8 @@ value of the last statement in BODY, as elisp."
 		(org-babel-comint-with-output
 		    (session
 		     (if matlabp
-			 org-babel-octave-eoe-indicator
-		       org-babel-octave-eoe-output)
+			 org-babel-octave-eoe-output
+		       org-babel-octave-eoe-indicator)
 		     t full-body)
 		  (insert full-body) (comint-send-input nil t)))) results)
     (case result-type

      parent reply	other threads:[~2012-05-29 17:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 21:02 [babel] ob-octave does not catch EOE from matlabShell on MS Windows Mikhail Titov
2012-05-24 21:30 ` Mikhail Titov
2012-05-25 16:31   ` Mikhail Titov
2012-05-25 16:52     ` [babel, patch] " Mikhail Titov
2012-05-28 15:56       ` Eric Schulte
2012-05-28 18:23         ` Achim Gratz
2012-05-30 15:58           ` Mikhail Titov
2012-05-30 16:05             ` Eric Schulte
2012-05-30 16:58             ` Achim Gratz
2012-05-29 17:00         ` Mikhail Titov [this message]

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='015201cd3dbc$970d2720$c5277560$@us' \
    --to=mlt@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).