(FILECREATED "14-Mar-85 22:28:47" {ERIS}<LISPNEW>PATCHES>FILEPKGPATCH.;3 4741   

      changes to:  (VARS FILEPKGPATCHCOMS)
		   (FNS LOOKIN)

      previous date: "14-Mar-85 22:14:46" {ERIS}<LISPNEW>PATCHES>FILEPKGPATCH.;1)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FILEPKGPATCHCOMS)

(RPAQQ FILEPKGPATCHCOMS [(FNS EDITFROMFILE LOOKIN)
			 (BLOCKS (EDITFROMFILE EDITFROMFILE LOOKIN (GLOBALVARS EDITLOADFNSFLG)
					       (NOLINKFNS LOADFROM])
(DEFINEQ

(EDITFROMFILE
  [LAMBDA (FNS FILES EDITPATTERN EDITCOMS ONLYTYPES)         (* rmk: "14-Mar-85 21:51")
    (RESETVARS [(EDITLOADFNSFLG (COND
				  ((EQ EDITLOADFNSFLG T)
				    (QUOTE (T . NO)))
				  (T EDITLOADFNSFLG]
	       (PROG NIL
		     [OR EDITCOMS (SETQ EDITCOMS (LIST (LIST (QUOTE EXAM)
							     EDITPATTERN]
		     (AND
		       (SETQ FILES (for FILE inside (OR FILES FILELST)
				      when (OR (AND EDITLOADFNSFLG (FMEMB (ROOTFILENAME FILE)
									  FILELST))
					       (COND
						 ((EQ (QUOTE Y)
						      (ASKUSER DWIMWAIT (QUOTE Y)
							       (LIST "load from" FILE)
							       NIL T))
						   (LOADFROM FILE FNS (QUOTE ALLPROP))
						   T)))
				      collect FILE))
		       (for TYPE in [COND
				      ((LISTP ONLYTYPES))
				      (ONLYTYPES (QUOTE (FNS)))
				      (T 

          (* Move FNS to the front. This means that all the fns will be dwimified and editted before anything else 
	  (like a rename of fields) is done.)


					 (CONS (QUOTE FNS)
					       (REMOVE (QUOTE FNS)
						       FILEPKGTYPES]
			  when (AND (LITATOM TYPE)
				    (NEQ (fetch EDITDEF of TYPE)
					 (QUOTE NILL)))
			  do
			   (PROG (SEEN)
			         (for FILE inside FILES
				    do
				     (for NAME in [COND
						    ((AND (EQ TYPE (QUOTE FNS))
							  (NEQ FNS T))
                                                             (* for this type, we are given the list of items)
						      (PROG1 FNS (SETQ FNS NIL)))
						    (T       (* only want the values of "TYPE" which are not part of
							     some other type)
						       (FILECOMSLST FILE TYPE (QUOTE EDIT]
					unless (MEMBER NAME SEEN)
					do
					 (ERSETQ
					   (PROG [(DEF (OR (GETDEF NAME TYPE (QUOTE CURRENT)
								   (QUOTE (NOCOPY NOERROR)))
							   (GETDEF NAME TYPE (QUOTE SAVED)
								   (QUOTE (NOCOPY NOERROR]

          (* If definition has been loaded, it may have been editted. Work on that explicitly instead of bringing in a file 
	  definition to smash the users previous changes. Perhaps we should query the user about this, but until the 
	  interaction is worked out, it is better to avoid trashing his in core edits, given that he can always get the file 
	  definition from permanent storage with LOADFNS. -
	  We might also be more discriminating about this: if the user specified a root file name, then he means the 
	  definition from the definition group, not the physical file. But ... rmk)


					         (COND
						   ((OR (AND (EQ TYPE (QUOTE FNS))
							     (NEQ FNS T))
							(AND (LISTP DEF)
							     (LOOKIN DEF EDITPATTERN)))
						     (COND
						       ((NULL SEEN)
							 (LISPXPRIN1 "editing the " T)
							 (LISPXPRIN1 (OR (fetch DESCRIPTION
									    of TYPE)
									 TYPE)
								     T)
							 (LISPXSPACES 1 T)))
						     (SETQ SEEN (CONS NAME SEEN))
						     (LISPXPRIN2 NAME T T)
						     (LISPXPRIN1 ":
" T)
						     (COND
						       ((NOT
							   (ERSETQ
							     (EDITDEF
							       NAME TYPE
							       (OR (AND DEF (CONS (QUOTE =)
										  DEF))
								   FILE)
							       EDITCOMS)))
							 (LISPXPRIN1 "failed" T)))
						     (LISPXTERPRI T])

(LOOKIN
  [LAMBDA (X PAT)                                            (* lmm "11-MAR-78 14:20")
    (COND
      ([AND (EQ (CAR PAT)
		(QUOTE *ANY*))
	    (EVERY (CDR PAT)
		   (FUNCTION (LAMBDA (X)
		       (AND (LITATOM X)
			    (NOT (STRPOS (QUOTE )
					 X]
	(FINDATS X (CDR PAT)))
      (T (EDITFINDP X PAT T])
)
[DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY
(BLOCK: EDITFROMFILE EDITFROMFILE LOOKIN (GLOBALVARS EDITLOADFNSFLG)
	(NOLINKFNS LOADFROM))
]
(PUTPROPS FILEPKGPATCH COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (499 4516 (EDITFROMFILE 509 . 4125) (LOOKIN 4127 . 4514)))))
STOP