jcartledge / sublime-worksheet Goto Github PK
View Code? Open in Web Editor NEWAn inline REPL for JavaScript, PHP, Ruby & more in Sublime Text 2 and 3
License: MIT License
An inline REPL for JavaScript, PHP, Ruby & more in Sublime Text 2 and 3
License: MIT License
Exception OSError: OSError(9, 'Bad file descriptor') in <bound method spawn.del of <repl.pexpect.spawn object at 0x10d8ce7d0>> ignored
Traceback (most recent call last):
File "./worksheet.py", line 46, in
File "./worksheet.py", line 55, in handle_thread
File "./worksheet.py", line 69, in handle_finished_thread
File "./worksheet.py", line 22, in close_repl
File "./repl/repl.py", line 49, in close
self.repl.close()
File "./repl/pexpect.py", line 666, in close
raise ExceptionPexpect ('close() could not terminate the child using terminate()')
repl.pexpect.ExceptionPexpect: close() could not terminate the child using terminate()
No idea why, but it would be better if they didn't.
It's obnoxious.
Currently pexpect swallows these. We need to indicate to the user that execution was cancelled because a timeout occurred, and clean up properly. This needs to handle extreme cases like while(1);
.
Firstly, I admit that I'm not sure if this is more properly a bug in sublime-worksheet or a bug in python's interactive mode, but either way this unfortunately prevents me (and others, I would guess?) from using this tool which otherwise seems pretty cool...
Given code like this:
#!/usr/bin/env python
import sys
def main():
args = sys.argv[1:]
for arg in args:
if '.' in arg:
print 'great!'
print arg
if __name__ == '__main__':
main()
This runs just fine from the command line, but worksheet gives "IndentationError: unexpected indent" on line 10 (print arg). Is there anything that can be done about this? Unfortunately I get the same error if I save this file as foo.py and do:
cat foo.py | python -i
for x in range(3):
print (x)
# > 1
# > 2
Expected:
for x in range(3):
print (x)
# > 0
# > 1
# > 2
this is the error found
Package Control: Error downloading package. HTTP error 404 downloading https://nodeload.github.com/jcartledge/sublime-worksheet/zip/0.9.0.
It's a bit messy and unclear, and there's stuff in there which doesn't seem to do anything.
In Worksheet v0.7.3 on OSX 10.8.4 and ST2.0.1 thees lines of code result in an error.
Javascript:
var foo = function(bar){
return bar;
}
foo('bar');
Console:
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./worksheet.py", line 101, in run
File "./worksheet.py", line 19, in run
File "./repl/repl.py", line 8, in get_repl
File "./repl/repl.py", line 42, in __init__
File "./repl/pexpect.py", line 432, in __init__
File "./repl/pexpect.py", line 519, in _spawn
repl.pexpect.ExceptionPexpect: The command was not found or was not executable: node.
yeah ok
Weird things happen when we try to compensate for no newline at EOF, so make sure there is a newline at EOF then don't do anything special with it.
Currently we just stop processing but don't report anything. Should return something like prefix + "Interpreter went away :/"
Now we have 2 versions of Sublime Text, 3 operating systems, and 7+ languages the potential for inadvertently breaking things justifies spending some time setting up tests.
Certain REPL executables (ahem scala
) have significant startup overhead. It would be extremely convenient if we could configure (probably using worksheet-settings
for that particular language) a REPL type to remain resident even after an eval. Keepalive would need to be configured both as a flag enabling its function and as a special command to pass to the REPL instance that resets its state (e.g. :reset
for scala
). We would also need a new command to manually bounce the resident instance if something gets screwed up.
download the avmshell exe
https://code.google.com/p/redtamarin/source/browse/trunk/build/shell/
install it in your /usr/bin/
for ex:
/usr/bin/avmshell
edit the worksheet.sublime-settings
and add at the end
"ActionScript": {
"cmd": "avmshell -repl",
"prompt": ["> "],
"error": ["[0-9]+Error:"],
"ignore": [".input"]
}
This JS code stop evaluating on the return statement.
function foo() {
return 'bar';
// > Execution timed out.
}
console.log(foo());
When worksheet settings are applied in .sublime-project
they are not being applied.
To test: add the Python virtualenv settings from README.md
to a project's settings, but change the prefix
(and cmd
path to the virtualenv python) to have an additional >
like so:
"settings": {
"worksheet_languages": {
"Python": {
"cmd": "/path/to/virtualenv/bin/python -i",
"prompt": [">>> ", "\\.\\.+ "],
"prefix": "# >> ",
"error": ["Traceback ", " File \"<stdin>\","]
},
}
}
Then evaluate a Python view and the project specific prefix is not used. This applies to the other settings as well. It also makes no difference if Sublime is started from the shell in an active virtualenv.
This is with ST2 2.0.2, build 2221 on OS X and sublime-worksheet a153ad8972
Using Windows 8.
When I save the scala file, I get this error.
Unable to save test.scala
Error: MoveFileEx(... .subl8be.tmp)
c:\test.scala failed, Access is deined.
Note: I got the same error when using scalaworksheet. I filed an issue and the plugin author Tony Sloane did some investigation.
https://bitbucket.org/inkytonik/scalaworksheet/issue/5/scalaworksheet-doesnt-work-on-windows
Installed on Sublime 3 without error, but Worksheet: Eval doesn't appear in the the command palette.
for ex: the avmshell repl gives
$ avmshell -repl
avmplus interactive shell
Type '?' for help
> ?
Text entered at the prompt is compiled and evaluated unless
it is one of these commands:
? print help
.input collect lines until a line that reads '.end',
then eval the collected lines
.load file load the file (source or compiled)
.quit leave the repl
.time expr evaluate expr and report the time it took.
the ".input" to ".end" could be quite useful to support multiline scripts
Hi,
I just installed this using package manager, but using ctrl+shift+P and searching for the "woksheet: evaluate worksheet" command, I can't find it.
I tried restarting sublime but the error remains.
I'm on ubuntu 11.10 (oneiric) 64bit.
Thanks
It would be useful if the README was explicit about whether the plugin works with ST3 or not.
Probably with wexpect? not sure.
not sure how.
I was playing around with this and wanted to use Boris instead. After a couple small explosions to figure out how the settings worked, I found this to work when added to the user settings:
"worksheet_languages": {
"PHP": {
"cmd": "/path/to/boris",
"prompt": ["(\\[[\\d]+\\]) (boris> | *\\*>)"],
"error": ["PHP Parse error:", "PHP Fatal error"],
"ignore": ["<\\?php", "\\?>"]
}
}
Only real change was the prompt regex, which I still don't understand 100%. Not an issue per se, but I thought it might be useful to someone.
e.g.
if (i > 0) {
Not sure how to detect an error, except by matching the string against patterns from the language config.
should be pretty easy
There's no reason to wait 1/10 sec for the REPL thread to finish.
Steps to reproduce:
Using this code:
for x in range(2):
print (x)
print("END")
Result:
for x in range(2):
print (x)
print("END")
# > File "<stdin>", line 3
# > print("END")
# > ^
# > SyntaxError: invalid syntax
Expected result:
for x in range(2):
print (x)
# > 0
# > 1
print("END")
# > END
A bit tricky, because the newer php repl doesn't handle <?php
and ?>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.