########################################################################;
## PLEASE REMEMBER THAT THIS ISN'T REALLY A PERL FILE.  IT'S ACTUALLY ##;
## READ AND "EVAL"ED ON A LINE BY LINE BASIS.  THE EVALUATOR ACCUM-   ##;
## ULATES LINES UNTIL IT FINDS ONE THAT ENDS IN A SEMICOLON.  USE     ##;
## COMMENT CHARACTERS TO PROTECT SEMICOLONS IN COMPOUND STATEMENTS AND##;
## SEMICOLONS AT THE END OF COMMENTS TO AVOID ACCUMULATING A BUNCH OF ##;
## COMMENTS INTO A STATEMENT.  MOST OF THE TIME, PERL SEEMS TO "DO THE##;
## RIGHT THING", BUT IT DOESN'T HURT TO BE CAREFUL.                   ##;
########################################################################;
## SEE THE COMMENT FOR THE 'require_hack' SUBROUTINE IN texit.pl FOR  ##;
## AN EXPLANATION OF THIS UNFORTUNATE BEHAVIOR.  IT REALLY ISN'T MY   ##;
## FAULT, HONEST!                                                     ##;
########################################################################;
#                                                                       ;
# The .texitrc file that I use on my Unix box at work                   ;
#                                                                       ;
# I like to delete a lot more files...                                  ;

@cleanup_latex = ('aux','log','blg','ilg','ind','idx','bbl','ps');

@latex_rules = (
 '$changed = 1 if &changed($TEXFILEPATH . $TEXFILENAME . ".bbl");',
 '$changed = 1 if &changed($TEXFILEPATH . $TEXFILENAME . ".toc");',
 '$changed = 1 if &changed($TEXFILEPATH . $TEXFILENAME . ".lot");',
 '$changed = 1 if &changed($TEXFILEPATH . $TEXFILENAME . ".lof");'
);

# Ask me about deleting those files on exit..                           ;
$CLEANONEXIT = 1;

# Add some local printers...some PostScript, a PostScript @ 600dpi      ;
# and a special printer to demonstrate how TeXit can be setup to ask    ;
# for options.                                                          ;
#                                                                       ;
$PRQUEUE{"oos"}     = "ps";
$PRQUEUE{"joshua"}  = "ps";
$PRQUEUE{"xerox1"}  = "ps";
$PRQUEUE{"woper"}   = "ps600";
$PRQUEUE{"qtest"}   = "psq";

$DVICMD{"psq"}      = $DVICMD{"ps"};
$DVIOPT{"psq"}      = $DVIOPT{"ps"};
$DVIQUERY{"psq"}    = "Additional DVI options? ";

$DVICMD{"ps600"}    = "dvips %o %d";
$DVIOPT{"ps600"}    = "-Pwoper";

$PRINTCMD{"oos"}    = "lpr %o %s.ps";
$PRINTOPT{"oos"}    = "-Poos";

$PRINTCMD{"joshua"} = "lpr %o %s.ps";
$PRINTOPT{"joshua"} = "-Pjoshua";

$PRINTCMD{"xerox1"} = "lpr %o %s.ps";
$PRINTOPT{"xerox1"} = "-Pxerox1 -K2";

$PRINTCMD{"woper"}  = "lpr %o %s.ps";
$PRINTOPT{"woper"}  = "-Pwoper";

$PRINTCMD{"qtest"}  = $PRINTCMD{"oos"};
$PRINTOPT{"qtest"}  = $PRINTOPT{"oos"};
$PRINTQUERY{"qtest"}= "Additional lpr options? ";
$PRINTCONFIRM{"qtest"} = "no";

# Rather than having two options, dvitty and Xdvi, let's switch between ;
# them based on the terminal type...actually, just as an example, let's ;
# make the test even more complicated:                                  ;
#                                                                       ;
#  - run xdvi if TERM=xterm                                             ;
#  - run dvgt if we're on a Sparc and not an xterm                      ;
#  - run dvi2tty if we're not on a Sparc or an xterm                    ;
#                                                                       ;
# This code assumes that your login script sets $HOSTTYPE and $TERM...  ;
#                                                                       ;
if ($ENV{"TERM"} eq "xterm") {
   $VIEWCMD = '$VIEW %o %d >/dev/null 2>1 &';  # run xdvi in the background...
} elsif ($ENV{"HOSTTYPE"} eq "sparc") {
   $VIEW = "dvigt";            # avoid end of expr
} else {
   $VIEW = "dvi2tty";          # avoid end of expr
};

# Let's make sure we can find the previewer and turn off the option if  ;
# we can't.  Print a warning message in that case too...                ;
#                                                                       ;
if (&find_on_path ($ENV{"PATH"}, $VIEW) eq "") {
   print "*** Can't find previewer ($VIEW) on path.  "; #
   print "Viewing disabled. ***\n"; #
   delete $CMDTEST{$ViewReply}; #
   delete $CMDPROMPT{$ViewReply}; #
};

# Uncomment this code if you _always_ want a choice for dvi2tty instead ;
# of using the switch above.  For example, if you want dvi2tty as a choice ;
# even if you are running on an Xterm.                                  ;
#                                                                       ;
#$DVITTY      = "/exp/rcf/share/tex/bin/dvi2tty";
#$DVITTYCMD   = "$DVITTY %o %d";
#$DvittyReply = "dvi2[tty]";
#$CMDPROMPT{$DvittyReply} = '&run("$DVITTYCMD", "$opts"); $REASK;';
#$CMDTEST{$DvittyReply}   = '"$DVITTY" && -x "$DVITTY" && -r &auxfile("dvi")';

# Setting up dvips as a command...;
#$DVIPS      = "/usr/local/bin/dvips";
#$DVIPSCMD   = "$DVIPS -o %s.ps %d";
#$DvipsReply = "dvi[ps]";
#$CMDPROMPT{$DvipsReply} = '&run("$DVIPSCMD", "$opts"); $REASK;';
#$CMDTEST{$DvipsReply}   = '"$DVIPS" && -x "$DVIPS" && -r &auxfile("dvi")';

# Adding a query printer option...;
#
$LpqReply = "[q]uery printer";
$CMDPROMPT{$LpqReply} = '&run("lpq -P%o", $opts); $REASK;';
$CMDTEST{$LpqReply}   = '';

# Delete Ghostview...                                                   ;
#                                                                       ;
delete $CMDPROMPT{$GhostviewReply};
delete $CMDTEST{$GhostviewReply};

# Default action when hitting Enter after TeXing is Viewing...          ;
#                                                                       ;
$DEFAULTCMD{$TeXReply} = $ViewReply;

# Add a new command which runs TeX and then automatically runs View...  ;
#                                                                       ;
$TeXandViewReply = "[T]eX & View";
$CMDPROMPT{$TeXandViewReply} = $CMDPROMPT{$TeXReply};
$CMDTEST{$TeXandViewReply} = $CMDTEST{$TeXReply};
$AUTOCMD{$TeXandViewReply} = $ViewReply;
$AUTOOPT{$TeXandViewReply} = "";

# let ! run any command, but don't bother to show the prompt...The fact ;
# that there are two !'s in this example is coincidence, they are       ;
# unrelated.                                                            ;
#                                                                       ;
$RunCommand = "![!] run command";
$CMDPROMPT{$RunCommand} = '&run("$opts",""); $REASK;';
$CMDTEST{$RunCommand}   = '';

# Add an edit command.  This is kind of funky because we want to edit   ;
# the master TeX file if no option is given, but edit the file specified;
# if a file is given...                                                 ;
# We get the editor from the "EDITOR" environment variable or use emacs.;
# This option is hidden because I never use it (the joys of an Xterm,   ;
# I guess ;-).  It's included just because it's an interesting example. ;
#                                                                       ;
$EditCommand = "![e]dit a file";
$EDITOR = $ENV{"EDITOR"};
$EDITOR = "emacs" if $EDITOR eq "";
$CMDPROMPT{$EditCommand} =
 'if ("\$opts" eq "") {
    &run("\$EDITOR %o &",
         \$TEXFILEPATH . \$TEXFILENAME . "." . \$TEXFILEEXT); #
  } else {
    &run("\$EDITOR %o &", "\$opts"); } ';
$CMDTEST{$EditCommand} = "";