Permalink
Browse files

Initial transition to invoking make_pdf via build system, with config

  • Loading branch information...
msiniscalchi committed May 25, 2011
1 parent 954640f commit 70f186e9ec55b4c873a911bf5979f2fe24c15888
Showing with 95 additions and 33 deletions.
  1. +1 −1 Default (OSX).sublime-keymap
  2. +56 −19 LaTeX.sublime-build
  3. +27 −0 LaTeX.sublime-build.OLD
  4. +11 −13 makePDF.py
@@ -2,7 +2,7 @@
LaTeX Package keymap for OSX
*/
[
- { "keys": ["ctrl+alt+t"], "command": "make_pdf" },
+ // { "keys": ["ctrl+alt+t"], "command": "make_pdf" }, // now bound to Command-B via the standard build system
{ "keys": ["ctrl+alt+s"], "command": "tex_sections" },
/* why not use TextMate's keybindings?
we only clobber next-tab and previous-tab, whihc are also bound
View
@@ -1,27 +1,64 @@
-/* Let's not preview for now. This should be OK on Win/MikTeX, too (?) */
-/* Make sure latexmk is on the $PATH, AND add it to .MacOSX/environment.plist */
+// Compilation settings
+// ====================
+//
+// The actual magic happens in the make_pdf command
+// I stick to the format of standard ST2 sublime-build files
+// with minor variations.
+// As of 5/24/11, latexmk (and texify on Windows) need to be on your $PATH
+// and, on OSX, you need to add /usr/texbin or similar to your .MacOSX/environment.plist
+// I will replace this with an explicit "binpaths" parameter
+//
+// NOTE: the viewer is NOT configured from here!
+// As of 5/24/11, it cannot be changed, but I will introduce a setting later
{
- "cmd": ["latexmk",
- "-e", "\\$pdflatex = 'pdflatex %O -file-line-error --max-print-line=200 -synctex=1 %S'",
- "-e", "\\$pdf_previewer = qq{if [ -n \"`ps axww | grep Skim | grep -v grep`\" ] ; then osascript -e 'tell app \"Skim\" to revert front document' ; else open -a Skim %O %S ; fi}",
- //"-e", "\\$pdf_previewer = qq{/Applications/Skim.app/Contents/SharedSupport/displayline -g -r 0 %S}",
- "-pv", "-pdf", "$file"],
- "working_dir": "$file_path", /* crucial or latexmk will spew stuff in /!!! */
- "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
+
+ // General settings; DO NOT MODIFY!!!
+ "target": "make_pdf",
"selector": "text.tex.latex",
- // Windows-specific command
- // ASSUMES sumatrapdf is default viewer
- // Only problem is that it comes to the foreground
+ // Mac-specific settings
+ // ---------------------
+
+ "osx":
+ {
+ // Mac texification settings
+ // -------------------------
+ // Personalize this, IF you know what you are doing!
+ // e.g. change 'pdflatex...' to 'xelatex...'
+ // Refer to the documentation for latexmk
+ //
+ // Note: do NOT include $file or similar!!!
+ // Only configure the compilation parameters you need, MINUS the
+ // actual file to be compiled
+ //
+ // By default, latexmk is told to use pdflatex, with synctex on for
+ // backward/forward search, forcing compilation (e.g. even if no bib file is found)
+ // and producing pdf rather than dvi output
+ "cmd": ["latexmk",
+ "-e", "\\$pdflatex = 'pdflatex %O -synctex=1 %S'",
+ "-f", "-pdf"],
+
+ // DO NOT MESS WITH THE FOLLOWING!!!
+ "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)"
+ },
+
+ // Windows-specific settings
+ // -------------------------
"windows":
{
- "cmd": ["texify", "-b", "-p",
- "--tex-option=\"--synctex=1\"",
- "--tex-option=\"--max-print-line=200\"",
- "--tex-option=\"-file-line-error\"",
- "--run-viewer",
- "--viewer-option=\"-reuse-instance\"",
- "$file"]
+ // Texification command
+ // -----------------------------
+ // See above comments on Mac parameters
+ // Refer to the documentation for texify (miktex)
+ //
+ // Again, do NOT include $file or similar!!!
+ "cmd": ["texify",
+ "-b", "-p",
+ "--tex-option=\"--synctex=1\""
+ ],
+
+ // DO NOT MESS WITH THE FOLLOWING!!!
+ "file-regex": "^((?:.:)?[^:\n\r]*):([0-9]+):?([0-9]+)?:? (.*)$"
}
}
View
@@ -0,0 +1,27 @@
+/* Let's not preview for now. This should be OK on Win/MikTeX, too (?) */
+/* Make sure latexmk is on the $PATH, AND add it to .MacOSX/environment.plist */
+
+{
+ "cmd": ["latexmk",
+ "-e", "\\$pdflatex = 'pdflatex %O -file-line-error --max-print-line=200 -synctex=1 %S'",
+ "-e", "\\$pdf_previewer = qq{if [ -n \"`ps axww | grep Skim | grep -v grep`\" ] ; then osascript -e 'tell app \"Skim\" to revert front document' ; else open -a Skim %O %S ; fi}",
+ //"-e", "\\$pdf_previewer = qq{/Applications/Skim.app/Contents/SharedSupport/displayline -g -r 0 %S}",
+ "-pv", "-pdf", "$file"],
+ "working_dir": "$file_path", /* crucial or latexmk will spew stuff in /!!! */
+ "file_regex": "^(...*?):([0-9]+): ([0-9]*)([^\\.]+)",
+ "selector": "text.tex.latex",
+
+ // Windows-specific command
+ // ASSUMES sumatrapdf is default viewer
+ // Only problem is that it comes to the foreground
+ "windows":
+ {
+ "cmd": ["texify", "-b", "-p",
+ "--tex-option=\"--synctex=1\"",
+ "--tex-option=\"--max-print-line=200\"",
+ "--tex-option=\"-file-line-error\"",
+ "--run-viewer",
+ "--viewer-option=\"-reuse-instance\"",
+ "$file"]
+ }
+}
View
@@ -268,8 +268,14 @@ def run ( self ):
# If so, find out! Otherwise log file is never refreshed
# Work-around: check file creation times
+# We get the texification command (cmd), file regex and binpaths (TODO) from
+# the sublime-build file. This allows us to use the ST2 magic: we can keep both
+# windows and osx settings there, and we get handed the right one depending on
+# the platform! Cool!
+
class make_pdfCommand(sublime_plugin.WindowCommand):
- def run(self):
+
+ def run(self, cmd="", file_regex="", binpaths=""):
view = self.window.active_view()
self.file_name = view.file_name()
self.tex_base, self.tex_ext = os.path.splitext(self.file_name)
@@ -290,6 +296,10 @@ def run(self):
self.window.run_command("show_panel", {"panel": "output.exec"})
+ # Get parameters from sublime-build file:
+ self.make_cmd = cmd
+ self.output_view.settings().set("result_file_regex", file_regex)
+
if view.is_dirty():
print "saving..."
view.run_command('save') # call this on view, not self.window
@@ -300,21 +310,9 @@ def run(self):
s = platform.system()
if s == "Darwin":
- # use latexmk
- # -f forces compilation even if e.g. bib files are not found
- self.make_cmd = ["latexmk",
- "-e", "$pdflatex = 'pdflatex %O -synctex=1 %S'",
- "-f", "-pdf",]
self.encoding = "UTF-8"
- self.output_view.settings().set("result_file_regex", "^([^:\n\r]*):([0-9]+):?([0-9]+)?:? (.*)$")
elif s == "Windows":
- self.make_cmd = ["texify", "-b", "-p",
- "--tex-option=\"--synctex=1\"",
- #"--tex-option=\"--max-print-line=200\"",
- #"--tex-option=\"-file-line-error\""
- ]
self.encoding = getOEMCP()
- self.output_view.settings().set("result_file_regex", "^((?:.:)?[^:\n\r]*):([0-9]+):?([0-9]+)?:? (.*)$")
else:
sublime.error_message("Platform as yet unsupported. Sorry!")
return

0 comments on commit 70f186e

Please sign in to comment.