(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED "21-Dec-88 16:28:43" {QV}<NOTECARDS>1.3MNEXT>PMIPATCH114.;3 10780  

      changes to%:  (FNS NC.InspectAndRepairNoteFile NCP.LookupCardByName)
                    (VARS PMIPATCH114COMS)

      previous date%: "21-Dec-88 12:24:01" {QV}<NOTECARDS>1.3MNEXT>PMIPATCH114.;1)


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

(PRETTYCOMPRINT PMIPATCH114COMS)

(RPAQQ PMIPATCH114COMS
       (

(* ;;; "New file")

        (DECLARE%: DONTCOPY (PROPS (PMIPATCH114 MAKEFILE-ENVIRONMENT)
                                   (PMIPATCH114 FILETYPE)))
        
        (* ;; "pmi 12/21/88: Fixes problems with %"arg not notefile%" complaints from various notefile operations, either from the NoteCards filebrowser or the session icon's notefile operations menu.  Also cures break caused by compacting a notefile when a copy of it is already open.")

        
        (* ;; "Changed in NCDATABASE")

        (FNS NC.NoticeNoteFileName NC.InspectAndRepairNoteFile)
        
        (* ;; "Changed in NCPROGINT")

        (FNS NCP.LookupCardByName)))



(* ;;; "New file")

(DECLARE%: DONTCOPY 

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

(PUTPROPS PMIPATCH114 FILETYPE :BCOMPL)
)



(* ;; 
"pmi 12/21/88: Fixes problems with %"arg not notefile%" complaints from various notefile operations, either from the NoteCards filebrowser or the session icon's notefile operations menu.  Also cures break caused by compacting a notefile when a copy of it is already open."
)




(* ;; "Changed in NCDATABASE")

(DEFINEQ

(NC.NoticeNoteFileName
  [LAMBDA (NoteFileOrFileName)                           (* ; "Edited 20-Dec-88 16:16 by pmi")

    (* ;; "pmi 5/14/87: Created to keep track of noticed NoteFiles")

    (* ;; "pmi 5/21/87: Now creates a menu item bitmap for this notefile.")

    (* ;; "pmi 8/13/87: Overhauled stuff for menu of noticed notefiles.")

    (* ;; "pmi 12/18/87: Changed the global var NC.NoticedNoteFileNames to NCP.NoticedNoteFileNames to make it available in the programmer's interface.")

    (* ;; "rar.  10/20/88 Added check to see if Notefile is marked as %"UnNoticable%" and shouldn't appear in the menu.")

    (* ;; 
  "pmi 12/20/88: Added check for non-NIL notefile before checking for UnNoticable property.")

    (DECLARE (GLOBALVARS NCP.NoticedNoteFileNames NC.NoticedNoteFilesMenu))
    (LET (FullFileName NoteFile)
         (if (type? NoteFile NoteFileOrFileName)
             then (SETQ FullFileName (fetch (NoteFile FullFileName) of NoteFileOrFileName
                                                ))
                   (SETQ NoteFile NoteFileOrFileName)
           else (SETQ FullFileName (FULLNAME NoteFileOrFileName))
                 (SETQ NoteFile (NC.NoteFileFromFileName FullFileName)))

(* ;;; "If the filename is a valid file, add it to the list of noticed files.  If the filename is not a valid file, remove it from the list of noticed files.  If the resulting list is empty, set it to NIL (DREMOVE can't set a list to NIL)")

         (if FullFileName
             then 

                   (* ;; 
                 "If the notefile has not been marked as %"UnNoticable%", then add it to the menu")

                   (if [NOT (AND NoteFile (NCP.NoteFileProp NoteFile 'UnNoticable]
                       then (if NCP.NoticedNoteFileNames
                                    then (MERGEINSERT FullFileName NCP.NoticedNoteFileNames T)
                                  else (SETQ NCP.NoticedNoteFileNames (MERGEINSERT FullFileName 
                                                                             NCP.NoticedNoteFileNames
                                                                                 T)))
                             (SELECTQ (GETPROP FullFileName 'LastKnownStatus)
                                 (OPEN (if (NULL (NC.NoteFileOpenP NoteFile))
                                           then (PUTPROP FullFileName 'LastKnownStatus
                                                           'CLOSED)
                                                 (SETQ NC.NoticedNoteFilesMenu NIL)))
                                 (CLOSED (if (NC.NoteFileOpenP NoteFile)
                                             then (PUTPROP FullFileName 'LastKnownStatus
                                                             'OPEN)
                                                   (SETQ NC.NoticedNoteFilesMenu NIL)))
                                 (PROGN (if (NC.NoteFileOpenP NoteFile)
                                            then (PUTPROP FullFileName 'LastKnownStatus
                                                            'OPEN)
                                          else (PUTPROP FullFileName 'LastKnownStatus
                                                          'CLOSED))
                                        (SETQ NC.NoticedNoteFilesMenu NIL))) 

(* ;;; "Constuct menu items for this notefile.")

                             (NC.CreateNoteFileMenuItems FullFileName))
           else (if (DREMOVE NoteFileOrFileName NCP.NoticedNoteFileNames)
                      else (SETQ NCP.NoticedNoteFileNames NIL])

(NC.InspectAndRepairNoteFile
  [LAMBDA (NoteFileOrFileName ReadSubstancesFlg InterestedWindow)
                                                             (* ; "Edited 21-Dec-88 16:25 by pmi")

    (* ;; "Check to be sure file is closed before calling real inspect and repair.")

    (* ;; "rht 7/16/86: Added InterestedWindow arg.  Removed call to NC.OpenDatabaseFile.")

    (* ;; "rht 7/17/86: Now works with file name args as well as notefile args.  Took out reopen'ing of notefile, because you don't know how it was originally opened.")

    (* ;; "fgh 9/1/86 Now just a wrapper for the device specific inspect & repair fn.  Old functionality is in NCLocalDevice.InspectAndRepairNoteFile.")

    (* ;; "pmi 12/19/86 Added test for open notefile so we can abort if it is open.  Made consistent with other NoteFile operations in the way it checks for valid NoteFile, gets msg window, etc.")

    (* ;; "pmi 5/29/87: Added call to NC.NoticeNoteFile to make sure this NoteFile is noticed.  Cleaned up case where notefilename is valid, but a notefile object does not exist.")

    (* ;; "pmi 12/21/88: Now passes either the notefile or its filename to the device-specific repair notefile fn.")

    (DECLARE (GLOBALVARS NC.MsgDelay))
    (PROG ((MsgWindow InterestedWindow)
           NoteFile FileName FullFileName)

     (* ;; "Get the name of the file to be inspected.")

          (if (type? NoteFile NoteFileOrFileName)
              then (SETQ NoteFile NoteFileOrFileName)
                    (SETQ FileName (fetch (NoteFile FullFileName) of NoteFile))
            elseif (SETQ FileName (OR NoteFileOrFileName (NC.DatabaseFileName 
                                                     "Name of NoteFile to be inspected and repaired:"
                                                                    " -- " T NIL NIL MsgWindow)))
            else (RETURN NIL))

     (* ;; "Check for existence of file to be inspect and repaired.")

          (if (SETQ FullFileName (FULLNAME FileName))
              then [if (OR NoteFile (SETQ NoteFile (NC.NoteFileFromFileName FullFileName)))
                           then (SETQ MsgWindow (OR MsgWindow (NC.CoerceToInterestedWindow 
                                                                         NoteFile]
            else (NC.RemoveAccessToNoteFile FileName)
                  (SETQ MsgWindow (NC.CoerceToInterestedWindow MsgWindow))
                  (NC.PrintMsg MsgWindow T FileName " does not exist." (CHARACTER 13)
                         "Inspect & Repair cancelled."
                         (CHARACTER 13))
                  (DISMISS NC.MsgDelay)
                  (NC.ClearMsg MsgWindow T)
                  (RETURN NIL))

     (* ;; "Check to see if the notefile is open, abort if it is.")

          (if (NC.NoteFileOpenP FullFileName)
              then (NC.PrintMsg MsgWindow T "Can't inspect and repair an open notefile."
                              (CHARACTER 13)
                              "Inspect & Repair cancelled."
                              (CHARACTER 13))
                    (DISMISS NC.MsgDelay)
                    (NC.ClearMsg MsgWindow T)
                    (RETURN NIL))

     (* ;; "Add the From notefile to the Hash Array and the list of noticed notefiles, in case it isn't already there.")

          (NC.NoticeNoteFile FullFileName)

     (* ;; "Apply the device specific repair notefile fn for the file's host.")

          (RETURN (APPLY* (fetch (NoteFileDevice RepairNoteFileFn)
                             of (NC.DeviceVectorForHost (FILENAMEFIELD FullFileName 'HOST)
                                           'PRIVATE))
                         (OR NoteFile FullFileName)
                         ReadSubstancesFlg MsgWindow])
)



(* ;; "Changed in NCPROGINT")

(DEFINEQ

(NCP.LookupCardByName
  [LAMBDA (Name NoteFileOrRegistryCard)                  (* ; "Edited 21-Dec-88 15:33 by pmi")

    (* ;; "Lookup Name in notefile's system registry card.")

    (* ;; "rht 11/16/86: Changed call to NCP.ReportError")

    (* ;; "rht 5/23/87: Second arg can now be RegistryCard or NoteFile.  If the latter, then grab notefile's RegistryCard.")

    (* ;; "pmi 12/21/88: Now returns NIL if the NoteFile does not have a registry card (as when called from NC.OpenNotefile  (via NC.CloseNotefile and NC.AbortSession) with partially opened notefile).")

    (LET (RegistryCard)
         [COND
            ((NCP.OpenNoteFileP NoteFileOrRegistryCard)
             (SETQ RegistryCard (fetch (NoteFile RegistryCard) of NoteFileOrRegistryCard)))
            ((AND (NC.ValidCardP NoteFileOrRegistryCard)
                  (EQ (NCP.CardType NoteFileOrRegistryCard)
                      'Registry))
             (SETQ RegistryCard NoteFileOrRegistryCard))
            (T (NCP.ReportError 'NCP.LookupCardByName (CONCAT "Improper arg: " NoteFileOrRegistryCard
                                                             ]

         (* ;; "Don't try to call NC.LookupCardByName if RegistryCard is NIL.")

         (if RegistryCard
             then (NC.LookupCardByName RegistryCard Name])
)
(PUTPROPS PMIPATCH114 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1687 9302 (NC.NoticeNoteFileName 1697 . 5436) (NC.InspectAndRepairNoteFile 5438 . 9300)
) (9341 10697 (NCP.LookupCardByName 9351 . 10695)))))
STOP