aboutsummaryrefslogtreecommitdiff
path: root/texall
diff options
context:
space:
mode:
Diffstat (limited to 'texall')
-rwxr-xr-xtexall82
1 files changed, 56 insertions, 26 deletions
diff --git a/texall b/texall
index f5c4719..dcefe73 100755
--- a/texall
+++ b/texall
@@ -89,15 +89,7 @@ else:
# iterate over all .tex files that are not ignored by -i or -p
def alltexfiles(args):
for a in args:
- if os.path.isfile(a):
- if re_texfile.match(a):
- (dirname, filename) = os.path.split(a)
- if dirname == "":
- dirname = "."
- yield (dirname, filename)
- else:
- error(a, "is no tex file; skipped")
- elif os.path.isdir(a):
+ if os.path.isdir(a):
for dir, subdirs, files in os.walk(a):
if not options.recurse:
subdirs[:] = []
@@ -113,6 +105,21 @@ def alltexfiles(args):
else:
if options.verbosity > 2:
print "%s: skipped because no main latex file"%os.path.normpath(os.path.join(dir,name))
+ elif os.path.isfile(a):
+ if re_texfile.match(a):
+ (dirname, filename) = os.path.split(a)
+ if dirname == "":
+ dirname = "."
+ yield (dirname, filename)
+ else:
+ error(a, "is no .tex file; skipped")
+ elif os.path.isfile(a+".tex"):
+ (dirname, filename) = os.path.split(a+".tex")
+ if dirname == "":
+ dirname = "."
+ yield(dirname, filename)
+ else:
+ error(a, "file not found")
def texgrep(matcher, dirname, filename, recurse=False):
try:
@@ -256,6 +263,8 @@ def detecttextype(dirname, texname):
re_rmligs = re.compile('\\\usepackage((\\[.*?\\])?\\{n?german\\}|\\[[^]]*?german[^]]*?\\]\\{babel\\})')
def detectrmligs(dirname, texname):
+ if rmligs_name == "":
+ return False
for m in texgrep(re_rmligs, dirname, texname, recurse=True):
return True
return False
@@ -331,9 +340,9 @@ def processtexfiles(args):
run(["makeindex", jobname], dirname, reason=" (because .idx file might have changed)")
runtex(tex, texname, realname, dirname, reason=" (because .ind file might have changed)")
- if tex == "latex":
- run(["dvips", jobname+".dvi"], dirname)
- run(["ps2pdf", jobname+".ps"], dirname)
+ if tex == "latex":
+ run(["dvips", jobname+".dvi"], dirname)
+ run(["ps2pdf", jobname+".ps"], dirname)
rmtempfile(tmplist, dirname)
@@ -395,18 +404,26 @@ def rmtempfile(filename, dirname):
else:
error(fullname, "could not be removed (does not exist)", warning=True)
-def run(arglist, dirname, reason="", stdin=None, stdout=None):
- if options.interactionmode != "batchmode":
- # use stdout (default)
- output=None
- else:
- output=null
+def run(arglist, dirname, reason="", stdin=None, stdout=None, stderr=None, doio=None):
+ if options.interactionmode == "batchmode":
if not stdout:
- stdout=output
+ stdout=null
+ if not stderr:
+ stderr=null
if options.verbosity:
- print " running %s%s..."%(" ".join(arglist), reason)
+ redir = ""
+ if hasattr(stdin, "name"):
+ redir = "%s < %s"%(redir, stdin.name)
+ if hasattr(stdout, "name") and stdout is not null:
+ redir = "%s > %s"%(redir, stdout.name)
+ if hasattr(stderr, "name") and stderr is not null:
+ redir = "%s 2> %s"%(redir, stderr.name)
+ print " running %s%s%s..."%(" ".join(arglist), redir, reason)
if options.act:
- ret = subprocess.call(arglist, stdin=stdin, stdout=stdout, stderr=output, cwd=dirname)
+ proc = subprocess.Popen(arglist, stdin=stdin, stdout=stdout, stderr=stderr, cwd=dirname)
+ if doio:
+ doio(proc)
+ ret = proc.wait()
if ret:
error(dirname, "failed command: %s"%(" ".join(arglist)))
@@ -431,7 +448,6 @@ def preparermligs(texname, dirname, tmplist):
return texname
else:
tmplist.append(rmligsname)
- proc = subprocess.Popen([rmligs_name, "-f"], stdin=texfile, stdout=subprocess.PIPE, cwd=dirname)
def rewriteinputrmligs(m):
name=m.group(2)
@@ -442,16 +458,30 @@ def preparermligs(texname, dirname, tmplist):
else:
error(os.path.join(dirnam, texname), "%s: File could not be located. Not using rmligs."%name, warning=True)
return "\\%s{%s}"%(m.group(1), name[:-4])
- for line in proc.stdout:
- rmligsfile.write(re_inputinclude.sub(rewriteinputrmligs, line))
+ def doio(p):
+ for line in p.stdout:
+ rmligsfile.write(re_inputinclude.sub(rewriteinputrmligs, line))
+ run([rmligs_name, "-f"], dirname, stdin=texfile, stdout=subprocess.PIPE, doio=doio)
+
texfile.close()
if rmligsfile is not null:
rmligsfile.close()
return rmligsname
-
+
+re_rmligsfile = re.compile("\\.([^/ ]+)\\.rmligs\\.tex")
+def rmligscleanoutput(p): # filter tex output to make emacs jump to the right source positions
+ for l in p.stdout:
+ sys.stdout.write(re_rmligsfile.sub("\\1.tex", l))
+ sys.stdout.flush()
def runtex(tex, texname, realname, dirname, reason=""):
if texname != realname:
- run([tex, "-interaction", options.interactionmode, "-jobname", texname[:-4], realname], dirname, reason=reason)
+ if options.interactionmode == "batchmode":
+ stdout = None
+ doio = None
+ else:
+ stdout = subprocess.PIPE
+ doio = rmligscleanoutput
+ run([tex, "-interaction", options.interactionmode, "-jobname", texname[:-4], realname], dirname, stdout=stdout, doio=doio, reason=reason)
else:
run([tex, "-interaction", options.interactionmode, texname], dirname, reason=reason)