help-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-texinfo] texi2dvi: AUC-TeX and depots


From: Akim Demaille
Subject: [help-texinfo] texi2dvi: AUC-TeX and depots
Date: Mon, 19 Sep 2005 10:22:17 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Hi!

I've been using this for almost a month, and I like it a lot.  I hope
the documentation is understandable enough so that I don't need to
comment the patch.  If not, then it's the patch that I need to update.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * util/texi2dvi ($build_dir): New.
        (--depot): New.
        ($usage): Adjust.
        ($line_error): New.
        AUC-TeX wants regular TeX error messages, so don't require
        GNU style error message when under AUC-TeX.
        ($filename_dir_abs): New.
        ($t2ddir): When the depot is specified, make sure to avoid
        collisions between files with equal names, but in different
        directories.
        ($command_line_filename): Decode possible TeX commands.
        * util/Makefile.am (pdftexi2dvi): New.

Index: NEWS
===================================================================
RCS file: /cvsroot/texinfo/texinfo/NEWS,v
retrieving revision 1.117
diff -u -u -u -r1.117 NEWS
--- NEWS 22 Aug 2005 12:06:45 -0000 1.117
+++ NEWS 19 Sep 2005 08:19:32 -0000
@@ -30,6 +30,14 @@
 * texi2dvi:
   . new mode --build=tidy which supports compilation in a separate
     directory, where intermediate files are preserved.
+  . new option --depot, to specify where the tidy build will take
+    place, either locally or globally.  This allows to avoid the clutter
+    while preserving auxiliary files.
+  . new support for AUC-TeX: texi2dvi (weakly) supports arguments a la
+    TeX such as `\nonstopmode\input{file.tex}'.
+  . pdftexi2dvi is a new wrapper to `texi2dvi --pdf', equal to texi2pdf,
+    for sake of AUC-TeX which prepends `pdf' to the compilation command
+    when requested to produce PDF.
 * texinfo.tex:
   . new Serbian translation file for texinfo.tex, txi-sr.tex.
   . section names with \ characters work properly in pdf outlines.
Index: util/Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/Makefile.am,v
retrieving revision 1.15
diff -u -u -u -r1.15 Makefile.am
--- util/Makefile.am 5 Aug 2005 09:25:44 -0000 1.15
+++ util/Makefile.am 19 Sep 2005 08:19:32 -0000
@@ -11,7 +11,10 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 bin_PROGRAMS = ginstall-info texindex
-bin_SCRIPTS = texi2dvi texi2pdf
+bin_SCRIPTS = texi2dvi texi2pdf pdftexi2dvi
+
+pdftexi2dvi: texi2dvi
+       cp -f $< $@
 
 # Use `ginstall-info' in the definition of PROGRAMS and in dependencies
 # because automake generates an install-info target in every Makefile (a
Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.60
diff -u -u -u -r1.60 texi2dvi
--- util/texi2dvi 5 Sep 2005 13:46:15 -0000 1.60
+++ util/texi2dvi 19 Sep 2005 08:19:32 -0000
@@ -45,6 +45,7 @@
 "
 
 build_mode=${TEXI2DVI_BUILD_MODE:-local}
+build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
 
 usage="Usage: $program [OPTION]... FILE...
 
@@ -54,6 +55,11 @@
 is used to determine its language ((La)TeX or Texinfo).  To process
 (e)plain TeX files, set the environment variable LATEX=tex.
 
+In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX,
+the FILE may also be composed of the following simple TeX commands.
+  \`\\input{FILE}'     the actual file to compile
+  \`\\nonstopmode\     same as --batch
+
 Makeinfo is used to perform Texinfo macro expansion before running TeX
 when needed.
 
@@ -79,23 +85,31 @@
    or --texinfo=CMD    multiple values accumulate
 
 Build modes:
-  --build=MODE  specify the treatment of auxiliary files [$build_mode]
-      --tidy    same as --build=tidy
-  -c, --clean   same as --build=clean
+  --build=MODE     specify the treatment of auxiliary files [$build_mode]
+      --tidy       same as --build=tidy
+  -c, --clean      same as --build=clean
+  -d, --depot=DIR  specify where the tidy compilation is performed.
+                   implies --tidy
+                   defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
 
 The MODE specifies where the TeX compilation takes place, and, as a
 consequence, how auxiliary files are treated.  The build mode
 can also be set using the environment variable TEXI2DVI_BUILD_MODE.
 
 Valid MODEs are:
-  \`local'  compile in the current directory, leaving all the auxiliary
-             files around.
-  \`tidy'   compile in a local *.t2d directory, where the auxiliary files
-             are left.  Output files are copied back to the original file.
-  \`clean'  same as \`tidy', but remove the auxiliary directory afterwards.
-             Every compilation therefore requires the full cycle.
+  \`local'      compile in the current directory, leaving all the auxiliary
+                 files around.  This is the traditional TeX use.
+  \`tidy'       compile in a local *.t2d directory, where the auxiliary files
+                 are left.  Output files are copied back to the original file.
+  \`clean'      same as \`tidy', but remove the auxiliary directory afterwards.
+                 Every compilation therefore requires the full cycle.
 
 Using the \`tidy' mode brings several advantages:
+  - the current directory is not cluttered with plethora of temporary files.
+  - clutter can be even reduced using --depot=dir: all the *.t2d directories
+    are stored there.
+  - clutter can be reduced to zero using --depot=/tmp/\$USER.t2d or
+    --depot=$HOME/.t2d.
   - the output file is updated after every succesful TeX run, for
     sake of concurrent visualization of the output.  In a \`local' build
     the viewer stops during the whole TeX run.
@@ -121,6 +135,7 @@
 # Initialize variables for option overriding and otherwise.
 # Don't use `unset' since old bourne shells don't have this command.
 # Instead, assign them an empty value.
+line_error=true # Pass --file-line-error to TeX.
 batch=false     # true for batch mode
 debug=false
 escape="\\"
@@ -346,6 +361,9 @@
     false:) _dest=;;
     *:*)    _dest=$_out_noext.$_file_ext;;
   esac
+  if test ! -f "$1"; then
+    fatal 1 "no such file or directory: $1"
+  fi
   if test -n "$_dest"; then
     verbose "Copying $1 to $_dest"
     cp -p "$1" "$_dest"
@@ -386,7 +404,7 @@
     ensure_dir "$tex_help_dir"
     tex_help=`cd "$tex_help_dir" >&6 && $tex --help </dev/null 2>&1`
   fi
-  case $tex_help in
+  $line_error && case $tex_help in
     *file-line-error*) cmd="$cmd --file-line-error";;
   esac
 
@@ -707,6 +725,7 @@
     # Silently and without documentation accept -b and --b[atch] as synonyms.
     -b | --b*) batch=true;;
     -c | --c*) build_mode=clean;;
+    -d | --dep*)  shift; build_dir=$1; build_mode=tidy;;
     -D | --d*) debug=true;;
     -e | -E | --e*) expand=t;;
     -h | --h*) echo "$usage"; exit 0;;
@@ -749,8 +768,8 @@
 # Pop the token
 shift
 
-# clean: remove the t2d directory afterward.
-# tidy:  compile in this t2d directory.
+# $tidy:  compile in a t2d directory.
+# $clean: remove the t2d directory afterward.
 case $build_mode in
   local) clean=true;  tidy=false;;
   tidy)  clean=false; tidy=true;;
@@ -851,6 +870,21 @@
   echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >&6 \
   || command_line_filename="./$command_line_filename"
 
+  # See if we are run from within AUC-Tex, in which case we are
+  # passed `\input{FOO.tex}' or even `\nonstopmode\input{FOO.tex}'.
+  case $command_line_filename in
+    *\\nonstopmode*)
+      batch=true;;
+  esac
+  case $command_line_filename in
+    *\\input{*}*)
+      # Let AUC-TeX error parser deal with line numbers.
+      line_error=false
+      command_line_filename=`\
+        expr X"$command_line_filename" : X'.*input{\([^}]*\)}'`
+      ;;
+  esac
+
   # See if the file exists.  If it doesn't we're in trouble since, even
   # though the user may be able to reenter a valid filename at the tex
   # prompt (assuming they're attending the terminal), this script won't
@@ -862,10 +896,9 @@
 
   # Get the name of the current directory.
   filename_dir=`func_dirname "$command_line_filename"`
+  filename_dir_abs=`cd "$filename_dir" >&6 && pwd`
   # In a clean build, we `cd', so get an absolute file name.
-  case $tidy in
-    true)  filename_dir=`cd "$filename_dir" >&6 && pwd` ;;
-  esac
+  $tidy && filename_dir=$filename_dir_abs
 
   # Strip directory part but leave extension.
   filename_ext=`basename "$command_line_filename"`
@@ -879,12 +912,18 @@
 
   # An auxiliary directory used for all the auxiliary tasks involved
   # in compiling this document.
-  t2ddir=$filename_noext.t2d
+  case $build_dir in
+      '' | . ) t2ddir=$filename_noext.t2d ;;
+      *) # Avoid collisions between multiple occurrences of the same
+        # file.
+        t2ddir=$build_dir/`echo "$filename_dir_abs/" | sed 's,/,!,g'`
+        t2ddir=$t2ddir$filename_noext.t2d;;
+  esac
   # Remove it at exit if clean mode.
   $clean &&
     trap "cd / && rm -rf $t2ddir" 0 1 2 15
 
-  ensure_dir "$t2ddir"
+  ensure_dir "$build_dir" "$t2ddir"
 
   # We will change directory, better work with an absolute path...
   t2ddir=`cd "$t2ddir" && pwd`





reply via email to

[Prev in Thread] Current Thread [Next in Thread]