(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED " 4-Oct-88 18:36:39" {QV}<IDE>1.4>DSJPATCH078.;1 7115   

      changes to%:  (VARS DSJPATCH078COMS))


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

(PRETTYCOMPRINT DSJPATCH078COMS)

(RPAQQ DSJPATCH078COMS [
                        (* ;; 
  "dsj.  Change to Change to make display of cross-file links faster.  (1st change in dsjpatch072). ")

                        
                        (* ;; "Changed in NCCROSSFILELINKS")

                        (FNS NC.GetCrossFileLinkDestCard)
                        (DECLARE%: DONTCOPY (PROPS (DSJPATCH078 MAKEFILE-ENVIRONMENT)
                                                   (DSJPATCH078 FILETYPE])



(* ;; 
"dsj.  Change to Change to make display of cross-file links faster.  (1st change in dsjpatch072). ")




(* ;; "Changed in NCCROSSFILELINKS")

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  [LAMBDA (CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
                                                             (* ; "Edited  4-Oct-88 18:35 by DSJ")

         (* * Find the notefile corresponding to this crossfilelink and try to open it if 
         not already open. Then look for the card in there having the given UID.
         Return NIL if failed for any reason.)

         (* * rht 11/10/86%: Make sure CrossFileLinkCard is cached before fetching 
         substance.)

         (* * rht 11/19/86%: Now rips off version number from destination notefile hint.)

         (* * rht 12/11/86%: Now checks that destination card is not deleted.)

         (* * rht 12/16/86%: Now takes InterestedWindow argument.)

         (* * rht 3/25/87%: Now calls NC.CoerceToInterestedWindow.)

         (* * rht 3/27/87%: Now calls NC.OpenCrossFileLinkDestNoteFile.)

         (* * rht 5/27/87%: New arg Don'tOpenDestNoteFileFlg.
         If non-nil, then destination notefile has to be already open.)

         (* * rht 6/4/87%: Now passes CrossFileLinkCard to 
         NC.OpenCrossFileLinkDestNoteFile.)

         (* * rht 6/8/87%: Now computes WasOpenPromptWindowFlg)

         (* * pmi 8/7/87%: Now gets a filename if it has to loop and ask for another 
         notefile to try.)

         (* * pmi 9/8/87%: Now sets Don'tOpenDestNoteFileFlg to the results of 
         NC.OpenCrossFileLinkDestNoteFile)

         (* * dsj |9/14/88.| For speed, Now no longer updates the 
         CrossFileLinkDestFileHint field of the CrossFileLinkCard substance with the 
         DestNoteFile, thereby avoiding a call to FULLNAME.)

         (* * dsj |10/4/88.| Changed change of |9/14/88.|
         Now still does replaces but does not call FULLNAME.)

    (LET ((Title (NC.FetchTitle CrossFileLinkCard))
          (SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
          Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName Card 
          WasOpenPromptWindowFlg)
         (OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow SourceNoteFile)))
         (SETQ WasOpenPromptWindowFlg (NC.PromptWindowOpenP InterestedWindow))
         (if (NOT (NC.ActiveCardP CrossFileLinkCard))
             then (NC.GetNoteCard CrossFileLinkCard))
         (SETQ Substance (NC.FetchSubstance CrossFileLinkCard))
         (SETQ DestCardUID (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID) of Substance))
         (SETQ DestNoteFileUID (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
                                  of Substance))
         (SETQ DestFileHint (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance))
         (SETQ DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
         (SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
                                     (fetch (NoteFile FullFileName) of DestNoteFile))
                                DestFileHint))
         (for while [if Don'tOpenDestNoteFileFlg
                        then (NCP.OpenNoteFileP DestNoteFile)
                      else [SETQ Don'tOpenDestNoteFileFlg (NULL (SETQ DestNoteFile
                                                                 (NC.OpenCrossFileLinkDestNoteFile
                                                                  DestNoteFile DestFileName 
                                                                  InterestedWindow CrossFileLinkCard]
                           (SETQ DestFileName (OR DestFileName (AND (type? NoteFile DestNoteFile)
                                                                    (fetch (NoteFile FullFileName)
                                                                       of DestNoteFile] bind 
                                                                                          NewFileName
            do (if (NC.ValidCardP (SETQ Card (NC.CardFromUID DestCardUID DestNoteFile)))
                   then 
                        (* ;; "Now does not call FULLNAME on the CrossFileLinkDestFileHint, but instead strips the version off the FullFileName.  dsj. ")

                        (if (NOT (EQUAL (PACKFILENAME 'VERSION NIL 'BODY (SETQ NewFileName
                                                                          (fetch (NoteFile 
                                                                                        FullFileName)
                                                                             of DestNoteFile)))
                                        (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint)
                                           of Substance)))
                            then (replace (CrossFileLinkSubstance CrossFileLinkDestFileHint)
                                    of Substance with (PACKFILENAME 'VERSION NIL 'BODY NewFileName))
                                 (NC.MarkCardDirty CrossFileLinkCard))
                        (RETURN Card)
                 else (if Don'tOpenDestNoteFileFlg
                          then (RETURN NIL)
                        else (NC.PrintMsg InterestedWindow T "Couldn't find destination card in " 
                                    DestFileName "." (CHARACTER 13))
                             (if (NOT (NC.AskYesOrNo "Want to try opening a different notefile? " 
                                             " -- " "Yes" NIL InterestedWindow WasOpenPromptWindowFlg
                                             ))
                                 then (RETURN NIL)
                               else (SETQ DestNoteFile (SETQ DestFileName NIL])
)
(DECLARE%: DONTCOPY 

(PUTPROPS DSJPATCH078 MAKEFILE-ENVIRONMENT (:PACKAGE "INTERLISP" :READTABLE "INTERLISP"))

(PUTPROPS DSJPATCH078 FILETYPE :TCOMPL)
)
(PUTPROPS DSJPATCH078 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (935 6861 (NC.GetCrossFileLinkDestCard 945 . 6859)))))
STOP