emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [babel] org-babel for matlab?


From: Christopher Long
Subject: [Orgmode] Re: [babel] org-babel for matlab?
Date: Fri, 5 Mar 2010 04:00:43 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Darlan Cavalcante Moreira <darcamo <at> gmail.com> writes:

> > > I'm afraid I can't help much on this. I just used the
org-babel-template.el file > provided by Eric and did a search and
replace as told in the file comments in > order to make tangle work
for octave and MATLAB. I didn't implement any function > (I only know
enough lisp to understand my own .emacs file).  > > - Darlan > > >
Attachment (org-babel-matlab.el): application/octet-stream, 5941 bytes
> Attachment (org-babel-octave.el): application/octet-stream, 5941
bytes > > > At Wed, 17 Feb 2010 11:45:14 -0500, > Dan Davison <davison
<at> stats.ox.ac.uk> wrote: > > > > Darlan Cavalcante Moreira <darcamo
<at> gmail.com> writes: > > > > > This is also important for me (in
fact, for octave). For now I used the template > > > file and I can
tangle the code correctly, but since I didn't implement any > > >
function for code execution tangling is all I've got.  > > > > > > -
Darlan > > > > I was also going to suggest that if someone did this,
they might want to > > try to address octave at the same time.  > > >
> Darlan -- would you like to share your initial version of octave > >
support? If we get it onto a git repository then we can all have a
look > > and maybe make a bit of progress. Either post it, or contact
me off-line > > for the admin details for
http://repo.or.cz/w/org-mode/babel.git.  > > > > I don't use either
language but here are some comments about the various > > tasks and
guesses about how hard they would be.  > > > > If someone could
comment on the extent to which differences between > > matlab and
octave (running as command-line external processes) are going > > to
make shared org-babel support problematic that would probably be > >
useful.  > > > > - external process :results output > > Running octave
as an external process under linux/OS X and collecting > > stdout
shouldn't be too hard. Presumably same for matlab? Windows > >
support: unavailable for matlab, but probably feasible for octave.  >
> > > - external process :results value > > This basically involves
(in matlab/octave) writing vectors and arrays > > to a tabular file
(and then using existing code to import the org > > table, but this
bit can be taken from the files for another language) > > >
> - :session > > At first glance it looks like there's an inferior
octave mode that > > should be suitable for use > >
with :session. Darlan -- do you have experience with this?  > > > >
http://www.gnu.org/software/octave/doc/interpreter/Running-Octave-
From-Within-Emacs.html#Running-Octave-From-Within-Emacs
> > > > - Matlab :session on Windows > > Getting org-babel to work
with the MatLab "EmacsLink" module may well be > > possible, but I
would only be able to help very superficially.  > > > > Dan > > > > >
> > > > > At Tue, 16 Feb 2010 21:16:44 +0100, > > > Bob Jansen
<bobjansen <at> gmail.com> wrote: > > >> > > >> Hi list, > > >> > > >>
Has any progress been made on this? I'm fairly new to org-mode and > >
>> org-babel but this sounds to me like a very useful feature.  > > >>
> > >> > Hi Christopher, > > >> > > > >> > I do not know of anyone
working on matlab support for org-babel.  I am > > >> > attaching a
template file which contains instructions for adding support > > >> >
for a new language.  Depending on your level of familiarity with elisp
> > >> > it could take anywhere from a couple of hours to a couple of
days.  > > >> > We're still debugging some of the original language
specific files :) > > >> > > > >> > Best of Luck! -- Eric > > >> > > >
>> > > > >> > Attachment: org-babel-template.el > > >> > Description:
application/emacs-lisp > > >> > > > >> > Christopher Long
<address@hidden> writes: > > >> > > > >> > Dear All, > > >> > >
> >> > Has anyone started on a babel mode for matlab?  Or is anyone
else > > >> > interested > > >> > in making it happen?  Or have a
suggestion for a good template to > > >> > start from (babel-python?
babel-R?)  And anyone has an estimate of how > > >> > time consuming
such a project would be?  > > >> > > > >> > I'd like it to work on
Windows and there isn't a console mode of Matlab > > >> > on windows,
but you can evaluate code with EmacsLink and likely direct > > >> >
all output to temporary files.  > > >> > (I know EmacsLink was dropped
in R2009a, but some of us are avoiding > > >> > upgrading > > >> > and
hoping that Matlab will return EmacsLink in the future.)  > > >> > > >
>> > > > >> > Thanks, > > >> > > > >> > Stoph > > >> > > > >> > > > >>
> _______________________________________________ > > >> >
Emacs-orgmode mailing list > > >> > Please use `Reply All' to send
replies to the list.  > > >> > Emacs-orgmode <at> gnu.org > > >> >
http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > >> > > >>
_______________________________________________ > > >> Emacs-orgmode
mailing list > > >> Please use `Reply All' to send replies to the
list.  > > >> Emacs-orgmode <at> gnu.org > > >>
http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > >> > > >> > >
>> -- > > >> Met vriendelijke groet, > > >> > > >> Bob Jansen > > >> >
> >> > > >> _______________________________________________ > > >>
Emacs-orgmode mailing list > > >> Please use `Reply All' to send
replies to the list.  > > >> Emacs-orgmode <at> gnu.org > > >>
http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > > > > > > > >
_______________________________________________ > > > Emacs-orgmode
mailing list > > > Please use `Reply All' to send replies to the list.
> > > Emacs-orgmode <at> gnu.org > > >
http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > >
_______________________________________________ > Emacs-orgmode
mailing list > Please use `Reply All' to send replies to the list.  >
Emacs-orgmode <at> gnu.org >
http://lists.gnu.org/mailman/listinfo/emacs-orgmode >


  In case it is useful to anyone I've hacked together something to
read back things from matlab's output using the diary mode, m-files,
and a bit of lisp combined with EmacsLink (which - sadly - is no
longer supported by the Mathworks on their most recent versions of
Matlab).  This was done on windows xp.


  This is still a few steps away from full orgmode integration, but it
is a bit nice.  Perhaps someone can build on it.

example use:

%in emacs matlab mode ss; a=1 fprintf(1,'%d\n',a) se;

% mark the above in emacs % ctrl-c ctrl-r % ctrl-c ctrl-i

%the result: %%%%%%%%%%%%% % 04-Mar-2010 20:49:45 a=1 a = 1
fprintf(1,'%d\n',a) 1 se;

%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%


the .emacs changes:

    (defun my-matlab-mode-hook () (setq fill-column 76)
       (font-lock-mode 1) (auto-fill-mode 0) ; turn off auto-fill
       (imenu-add-to-menubar "Find")) ; where auto-fill should wrap
       (setq matlab-session-filename "session.txt") (defun
       insert-session-file () (interactive) ;;
       (matlab-shell-run-region (mark) (point)) (insert-file-contents
       matlab-session-filename)) (global-set-key "\C-c\C-i"
       'insert-session-file) (add-hook 'matlab-mode-hook
       'my-matlab-mode-hook)


ss.m %sessionstart

diary off; sessionfilename='C:\Documents and Settings\clong\My
Documents\MatlabToolboxes\stoph\session.txt'; eval(['delete '''
sessionfilename ''' ']); diary([sessionfilename]);
fprintf(1,'\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n') fprintf(1,'%%
%s\n',datestr(now))


se.m %

fprintf(1,'\n%%%%%%%%%%%%%%%%%%%%%%%%%%\n') diary off;

Stoph






reply via email to

[Prev in Thread] Current Thread [Next in Thread]