[TxMt] Latex bundle TEXINPUTS problem / patch

Louis Theran theran at gmail.com
Sun Nov 18 18:13:32 UTC 2007


I updated to the latest bundle, and I noticed that the texMate.py  
script has problems if included files aren't in the same directory as  
the main file.  Here is my quick and dirty patch, which should be  
factored out into a separate function before it gets committed.

I can do this in a few weeks if there's interest.

^L

Index: texMate.py
===================================================================
--- texMate.py	(revision 8473)
+++ texMate.py	(working copy)
@@ -1,6 +1,8 @@
  #!/usr/bin/env python
  # encoding: utf-8

+# Fixes by Louis Theran to respect TEXINPUTS
+
  # This is a rewrite of latexErrWarn.py
  # Goals:
  #   1.  Modularize the processing of a latex run to better capture  
and parse errors
@@ -191,11 +193,14 @@
      """Find all packages included by the master file.
         or any file included from the master.  We should not have to go
         more than one level deep for preamble stuff.
+
+	   FIXUP --- Use kpsewhich to find files
      """
      try:
-        texString = open(fileName).read()
+        realfn = os.popen('kpsewhich -progname=%s %s' % ('pdflatex',  
fileName)).read().strip()
+        texString = open(realfn).read()
      except:
-        print '<p class="error">Error: Could not open %s to check for  
packages</p>' % fileName
+        print '<p class="error">Error: Could not open %s to check for  
packages</p>' % realfn
          print '<p class="error">This is most likely a problem with  
TM_LATEX_MASTER</p>'
          sys.exit(1)
      incFiles = [x[3] for x in re.findall(r'((^|\n)[^%]*?)(\\input|\ 
\include)\{([\w /\.\-]+)\}',texString)]
@@ -204,7 +209,8 @@
          if ifile.find('.tex') < 0:
              ifile += '.tex'
          try:
-            myList += [x[3] for x in re.findall(r'((^|\n)[^%]*?)\ 
\usepackage(\[[\w, \-]+\])?\{([\w,\-]+)\}',open(ifile).read()) ]
+            realif = os.popen('kpsewhich -progname=%s %s' %  
('pdflatex', fileName)).read().strip()
+            myList += [x[3] for x in re.findall(r'((^|\n)[^%]*?)\ 
\usepackage(\[[\w, \-]+\])?\{([\w,\-]+)\}',open(realif).read()) ]
          except:
              print '<p class="warning">Warning: Could not open %s to  
check for packages</p>' % ifile
      newList = []




More information about the textmate mailing list