#!/usr/bin/perl

#    This file is part of cqual.
#    Copyright (C) 2000-2001 The Regents of the University of California.
# 
# cqual is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# cqual is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with cqual; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

$outfile="$ENV{HOME}/.emacs";

if (system("grep cqual $outfile > /dev/null 2>&1") == 0)
{
    print "\nNOTE:  you seem to have already updated $HOME/.emacs for cqual,";
    print "\nso it will not be done again.\n\n";
    exit(0);
}

open (OUT, ">>$outfile") || die "error opening $outfile";

chomp($cwd=`pwd`);
$pamdir="$cwd/PAM-3";
$bindir="$cwd/bin";
$configdir="$cwd/config";

print OUT <<EOF

;;; Set up PAM mode to run cqual

(autoload 'pam-analyze-file "pam-3" "Qualifier inference" t)
(autoload 'pam-analyze-file-common "pam-3" "Qualifier inference" t)

(setq pam-default-analysis '("$bindir/cqual"
			     "-fpam-mode"
			     "-hotspots"
			     "10"
;                             "-fcasts-preserve"
;			      "-prelude"
;			      "$configdir/prelude.i"
			     "-config"
			     "$configdir/lattice"))
(fset 'cqual 'pam-analyze-file)

(require 'pam-faces)

;;; Custom PAM colors

;;; You can change the default colors here
(custom-set-faces
 '(pam-color-1 ((t (:foreground "Wheat" :underline t))) t)
 '(pam-color-2 ((t (:foreground "Turquoise" :underline t))) t)
 '(pam-color-3 ((t (:foreground "GreenYellow" :underline t))) t)
 '(pam-color-4 ((t (:foreground "LightBlue" :underline t))) t)
 '(pam-color-5 ((t (:foreground "MediumBlue" :background "purple" :underline t))) t)
 '(pam-color-6 ((t (:foreground "Red" :underline t))) t)
 '(pam-color-7 ((t (:foreground "Green" :underline t))) t)
 '(pam-color-8 ((t (:foreground "Brown" :underline t))) t)
 '(pam-color-mouse ((t (:foreground "White" :background "Grey" :underline t))) t))

;;; Add new colors here

; Tainting qualifier colors
(pam-add-face pam-color-tainted ((t (:foreground "Red" :underline t))))
(pam-add-face pam-color-untainted ((t (:foreground "Green" :underline t))))

; Y2K qualifier colors
(pam-add-face pam-color-yyyy ((t (:foreground "GreenYellow" :underline t))))
(pam-add-face pam-color-yy   ((t (:foreground "LightBlue" :underline t))))
(pam-add-face pam-color-nonyear ((t (:foreground "MediumBlue" :underline t))))
(pam-add-face pam-color-ww50 ((t (:foreground "Red" :underline t))))
(pam-add-face pam-color-rcsdate ((t (:foreground "Green" :underline t))))

EOF

    ;
close(OUT);
