xuhdev / SingleCompile

A Vim plugin making it more convenient to compile or run a single source file.
https://singlecompile.topbug.net
GNU General Public License v3.0
123 stars 20 forks source link

add matlab/octave compiler template #40

Closed mckelvin closed 11 years ago

xuhdev commented 11 years ago

Thanks for your PR.

I tried with my matlab. The GUI program launched and actually the script is not executed. I'm on OS X.

mckelvin commented 11 years ago

@xuhdev I'm sorry that I didn't have Matlab installed in my PC and I just wrote the "as-is" code without testing the Matlab Compiler yet. Please wait for my latter commits.

btw, this may helps but i didn't test it yet.

mckelvin commented 11 years ago

@xuhdev I tested it on Linux 3.9.7-1-ARCH x86_64 / Matlab R2013a and it works fine.Please re-check it again.

xuhdev commented 11 years ago

Could you paste your output here please? Say we have a *.m file with:

1+1
mckelvin commented 11 years ago

the output of the Matlab Compiler:

                              < M A T L A B (R) >
                    Copyright 1984-2013 The MathWorks, Inc.
                      R2013a (8.1.0.604) 64-bit (glnxa64)
                               February 15, 2013

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

ans =

     2

Press ENTER or type command to continue

the output of the Octave Compiler:

GNU Octave, version 3.6.4
Copyright (C) 2013 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "x86_64-unknown-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

ans =  2

Press ENTER or type command to continue

actually the Octave Compiler is much faster than the Matlab Compiler but with a larger priority(60).

xuhdev commented 11 years ago

Thanks, does the test performed under terminal environment without GUI support?

mckelvin commented 11 years ago

@xuhdev this test is performed in terminator (a GUI terminal program under X11) with the output above, and no GUI window will pop up. I also tested it under a tty just now, and it works too.

xuhdev commented 11 years ago

OK then, please do me a favor. Run the following two commands in your terminal,

$ matlab
$ matlab some.m

what happens? Does the Matlab GUI launch? For me, the GUI program launches. Thanks

mckelvin commented 11 years ago

@xuhdev yes, both of these two commands will launch the Matlab GUI without running the some.m

xuhdev commented 11 years ago

Sorry that I was on a vacation. I upgrade my matlab to version 2013a but it still doesn't work. Would you mind test it on other platforms such as OS X or Windows? Thanks!

mckelvin commented 11 years ago

@xuhdev Sorry, I don't have any other platforms installed on my PC. Can you detail the problem on your platform? What happens if you:

create foo.m in the current working directory with:

x = 1

and then execute matlab -nodisplay -nosplash -r foo,exit on a terminal?

xuhdev commented 11 years ago
                            < M A T L A B (R) >
                  Copyright 1984-2013 The MathWorks, Inc.
                     R2013a (8.1.0.604) 64-bit (maci64)
                             February 15, 2013

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

x =

     1

What do you think of suppressing the welcome message?

mckelvin commented 11 years ago

@xuhdev I also get the same output, and SingleCompile also give the same output in my platform! I can't figure out how the problem comes in your plarform, could you do some tweak to fix that on your platform?

The welcome message is OK, in my view, just KISS.

xuhdev commented 11 years ago

Here's the patch:

diff --git a/autoload/SingleCompile/templates/matlab.vim b/autoload/SingleCompile/templates/matlab.vim
index 9830435..2ca750c 100644
--- a/autoload/SingleCompile/templates/matlab.vim
+++ b/autoload/SingleCompile/templates/matlab.vim
@@ -19,10 +19,10 @@

 function! SingleCompile#templates#matlab#Initialize()
     call SingleCompile#SetCompilerTemplate('matlab', 'matlab', 'MathWorks MATLAB',
-                \'matlab', '', '')
+                \'matlab', '-nodisplay -nosplash -r "$(FILE_TITLE)$; exit"', '')
     call SingleCompile#SetPriority('matlab', 'matlab', 50)
     call SingleCompile#SetCompilerTemplate('matlab', 'octave', 'GNU Octave',
-                \'octave', '', '')
+                \'octave', '-nodisplay -nosplash -r "$(FILE_TITLE)$; exit"', '')
     call SingleCompile#SetPriority('matlab', 'octave', 60)
 endfunction

Could you test whether octave works properly in this case, please? Thanks

mckelvin commented 11 years ago

@xuhdev I've fixed this in https://github.com/mckelvin/SingleCompile/commit/c2a14ed237a899abec08f11b4a938d2fa03f7e97 , I guess you may forget to pull the latest code in my repo.

xuhdev commented 11 years ago

Oh I see! What about octave? Do they share the same command line interface?

mckelvin commented 11 years ago

@xuhdev no extra params are needed for the octave compiler. as:

$ octave /tmp/foo.m 
GNU Octave, version 3.6.4
Copyright (C) 2013 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "x86_64-unknown-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

x =  1
xuhdev commented 11 years ago

OK thanks!