anchor.diff:    :runtime :standard
     )
   
  -;;; Copy needed directories to distribution
  +;;; Copy needed directories to distribution, deleting CVS/ directories and other
  +;;; stuff that users shouldn't see
  +
  +;;; Base specs and handwritten lisp from Specware4/Library/
  +
   (copy-directory (in-specware-dir "Library/Base/")
   		(in-distribution-dir "Library/Base/"))
   (sys:copy-file (in-specware-dir "Library/Base.sw")
   	   (in-distribution-dir "Library/Base.sw"))
   (delete-directory-and-files (in-distribution-dir "Library/Base/CVS/"))
   (delete-file (in-distribution-dir "Library/Base/System.sw"))
  +(delete-directory-and-files (in-distribution-dir "Library/Base/Handwritten/CVS/"))
  +(delete-directory-and-files (in-distribution-dir "Library/Base/Handwritten/Lisp/CVS/"))
  +(delete-file (in-distribution-dir "Library/Base/Handwritten/Lisp/.cvsignore"))
  +
  +;;; Emacs stuff from acl directory
  +
  +(copy-directory (in-lisp-dir "xeli/")
  +		(in-distribution-dir "Library/IO/Emacs/xeli/"))
  +
  +;;; Example specs from Application/Specware/Courses/NSA_Sept_2002
   
   (copy-directory (in-specware-dir "Applications/Specware/Courses/NSA_Sept_2002/")
   		(in-distribution-dir "Examples/"))
   (delete-directory-and-files (in-distribution-dir "Examples/CVS/"))
   (delete-directory-and-files (in-distribution-dir "Examples/Matching/CVS/"))
   (delete-directory-and-files (in-distribution-dir "Examples/simple1/CVS/"))
  +(delete-file (in-distribution-dir "Examples/simple1/test.lisp"))
   (delete-directory-and-files (in-distribution-dir "Examples/simple2/CVS/"))
  +(delete-file (in-distribution-dir "Examples/simple2/test.lisp"))
  +(delete-directory-and-files (in-distribution-dir "Examples/simple2/Refs/CVS/"))
  +(delete-directory-and-files (in-distribution-dir "Examples/simple2/Specs/CVS/"))
   (delete-directory-and-files (in-distribution-dir "Examples/simple3/CVS/"))
  +(delete-file (in-distribution-dir "Examples/simple3/test.lisp"))
   
  -(copy-directory (in-lisp-dir "xeli/")
  -		(in-distribution-dir "Library/IO/Emacs/xeli/"))
  +;;; Documentation pdf's from Specware4/UserDoc/
   
   (make-directory (in-distribution-dir "Documentation/"))
   (sys:copy-file (in-specware-dir "UserDoc/language-manual/SpecwareLanguageManual.pdf")
  
positive.code: (defun in-specware-dir (file) (concatenate 'string Specware4-dir "/" file))
  
  (defun in-lisp-dir (file) (concatenate 'string (sys:getenv "ALLEGRO") "/" file))
  
  ;; This is the sub-directory to receive this particular distribution.
  ;; In particular, this is where generate-application puts all its stuff.
  
negative.code: 	   (in-distribution-dir "Documentation/SpecwareTutorial.pdf"))
  (sys:copy-file (in-specware-dir "UserDoc/user-manual/SpecwareUserManual.pdf")
  	   (in-distribution-dir "Documentation/SpecwareUserManual.pdf"))
  
  ;;; TODO this doesn't seem to work right now...
  ;;; Current (highest-numbered) patch from Specware4/Release/Patches/
  
  (make-directory (in-distribution-dir "Patches/"))
  (sys:copy-file (in-specware-dir "Release/Patches/ansi-loop.fasl")
  	       (in-distribution-dir "Patches/ansi-loop.fasl"))
  
  (defun patch-number (path)
    (or (ignore-errors
         (let* ((file-name (pathname-name path))
  	      (major-version-len (length Major-Version-String)))
  	 (if (and (string-equal (pathname-type path) excl:*fasl-default-type*)
  		  (string-equal file-name "patch-" :end1 6)
  		  (string-equal file-name Major-Version-String
  				:start1 6 :end1 (+ major-version-len 6))
  		  (eq (elt file-name (+ major-version-len 6)) #\-))
  	     (let ((num? (read-from-string (subseq file-name (+ major-version-len 7)))))
  	       (if (integerp num?) num? 0))
  	   0)))
        0))
  
  (defun copy-specware-patch-if-present ()
    (let* ((patch-dir (in-specware-dir "Release/Patches/"))
  	 (files (cl:directory patch-dir))
  	 (highest-patch-number 0)
  	 (highest-patch-file nil))
      (loop for file in files
         do (let ((patch-num (patch-number file)))
  	    (when (> patch-num highest-patch-number)
  	      (setq highest-patch-number patch-num)
  	      (setq highest-patch-file file))))
      (when (> highest-patch-number 0)
        (setq cl-user::Specware-patch-level highest-patch-number)
        (ignore-errors (sys:copy-file highest-patch-file (in-distribution-dir 
  							(concatenate 'list "Patches/" (pathname-name highest-patch-file) 
  								     "." (pathname-type highest-patch-file))))))))
  
  
  (copy-specware-patch-if-present)