Skip to content

Instantly share code, notes, and snippets.

@jcartledge
Created July 5, 2013 00:52
Show Gist options
  • Save jcartledge/5930995 to your computer and use it in GitHub Desktop.
Save jcartledge/5930995 to your computer and use it in GitHub Desktop.
diff --git a/repl/repl.py b/repl/repl.py
index dfdfaf0..a3a37cb 100644
--- a/repl/repl.py
+++ b/repl/repl.py
@@ -1,4 +1,5 @@
import re
+from os import path
from functools import reduce
from . import PY3K
@@ -9,10 +10,15 @@ from .ftfy import fix_text
if PY3K:
unicode = str
+repl_base = path.abspath(path.dirname(__file__))
+
def get_repl(language, repl_def):
if repl_def.get("cmd") is not None:
- return Repl(repl_def.pop("cmd"), **repl_def)
+ return Repl(
+ repl_def.pop("cmd").format(repl_base=repl_base),
+ **repl_def
+ )
raise ReplStartError("No worksheet REPL found for " + language)
diff --git a/worksheet.py b/worksheet.py
index 892be36..e6c4bd8 100644
--- a/worksheet.py
+++ b/worksheet.py
@@ -97,12 +97,8 @@ class WorksheetCommand(sublime_plugin.TextCommand):
repl_def = dict(
list(default_def.items()) + list(repl_defs.get(language, {}).items()))
filename = self.view.file_name()
- if repl_def["cwd"] == "package_base":
- repl_def["cwd"] = os.path.dirname(__file__)
- elif repl_def["cwd"] is None:
- filename = self.view.file_name()
- if filename is not None:
- repl_def["cwd"] = os.path.dirname(filename)
+ if filename is not None:
+ repl_def["cwd"] = os.path.dirname(filename)
self.repl = repl.get_repl(language, repl_def)
except repl.ReplStartError as e:
return sublime.error_message(e.message)
diff --git a/worksheet.sublime-settings b/worksheet.sublime-settings
index 85719df..da261dc 100644
--- a/worksheet.sublime-settings
+++ b/worksheet.sublime-settings
@@ -11,8 +11,7 @@
"prompt": ["node> ", "\\.\\.+ "]
},
"Perl": {
- "cmd": "re.pl --rcfile=./repl/perl.rc --profile Minimal",
- "cwd": "package_base",
+ "cmd": "re.pl --rcfile=\"{repl_base}/perl/perl.rc\" --profile Minimal",
"prompt": [">>> "],
"prefix": "# > ",
"error": ["[A-Z][a-z]+error:"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment