From bc743fb39b9a3dcd25dfa92c4664b97d12c28960 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Fri, 7 Sep 2018 23:36:26 -0400 Subject: [PATCH] use file_name --- ride/render.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ride/render.py b/ride/render.py index 685fe54..3f6175a 100644 --- a/ride/render.py +++ b/ride/render.py @@ -3,7 +3,6 @@ import os from .settings import ride_settings -from .utils import expand_variables class RideRenderRmarkdownCommand(sublime_plugin.WindowCommand): @@ -12,14 +11,12 @@ def is_enabled(self): return view.settings().get("syntax").endswith("R Markdown.sublime-syntax") def run(self): - cmd = "rmarkdown::render(\"$file\", encoding = \"UTF-8\")" - extracted_variables = self.window.extract_variables() - cmd = expand_variables(cmd, extracted_variables) + cmd = "rmarkdown::render(\"$file_name\", encoding = \"UTF-8\")" + cmd = sublime.expand_variables(cmd, self.window.extract_variables()) kwargs = {} kwargs["cmd"] = [ride_settings.r_binary(), "--slave", "-e", cmd] kwargs["working_dir"] = os.path.dirname(self.window.active_view().file_name()) kwargs["env"] = {"PATH": ride_settings.custom_env("PATH")} - kwargs = sublime.expand_variables(kwargs, self.window.extract_variables()) self.window.run_command("exec", kwargs) @@ -29,15 +26,13 @@ def is_enabled(self): return view.settings().get("syntax").endswith("R Sweave.sublime-syntax") def run(self, edit): - cmd = ("""Sweave(\"$file\")\n""" + cmd = ("""Sweave(\"$file_name\")\n""" """tools::texi2dvi(\"$file_base_name.tex\", pdf = TRUE)""") - extracted_variables = self.window.extract_variables() - cmd = expand_variables(cmd, extracted_variables) + cmd = sublime.expand_variables(cmd, self.window.extract_variables()) kwargs = {} kwargs["cmd"] = [ride_settings.r_binary(), "--slave", "-e", cmd] kwargs["working_dir"] = os.path.dirname(self.window.active_view().file_name()) kwargs["env"] = {"PATH": ride_settings.custom_env("PATH")} - kwargs = sublime.expand_variables(kwargs, self.window.extract_variables()) self.window.run_command("exec", kwargs) @@ -47,13 +42,11 @@ def is_enabled(self): return view.settings().get("syntax").endswith("R Sweave.sublime-syntax") def run(self, edit): - cmd = ("""knitr::knit(\"$file\", output=\"$file_base_name.tex\")\n""" + cmd = ("""knitr::knit(\"$file_name\", output=\"$file_base_name.tex\")\n""" """tools::texi2dvi(\"$file_base_name.tex\", pdf = TRUE)")""") - extracted_variables = self.window.extract_variables() - cmd = expand_variables(cmd, extracted_variables) + cmd = sublime.expand_variables(cmd, self.window.extract_variables()) kwargs = {} kwargs["cmd"] = [ride_settings.r_binary(), "--slave", "-e", cmd] kwargs["working_dir"] = os.path.dirname(self.window.active_view().file_name()) kwargs["env"] = {"PATH": ride_settings.custom_env("PATH")} - kwargs = sublime.expand_variables(kwargs, self.window.extract_variables()) self.window.run_command("exec", kwargs)