Skip to content

Commit

Permalink
use file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Sep 8, 2018
1 parent 304538b commit bc743fb
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions ride/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os

from .settings import ride_settings
from .utils import expand_variables


class RideRenderRmarkdownCommand(sublime_plugin.WindowCommand):
Expand All @@ -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)


Expand All @@ -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)


Expand All @@ -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)

0 comments on commit bc743fb

Please sign in to comment.