(FILECREATED "13-Oct-86 12:34:03" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH116.;3 7285   

      changes to:  (FNS NC.CachedMakeFilingLink NC.MakeFilingLink NC.MarkerMatchesCardP)
		   (VARS RHTPATCH116COMS)

      previous date: "11-Oct-86 15:50:21" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH116.;1)


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

(PRETTYCOMPRINT RHTPATCH116COMS)

(RPAQQ RHTPATCH116COMS ((* * This patch file revamps the filebox mechanism for inserting new links. 
			     Supersedes all the insert-before-marker and insert-in-ordering cruft.)
			  (* * New stuff for NCLINKS)
			  (GLOBALVARS NC.FileBoxLinkSpacer)
			  (INITVARS (NC.FileBoxLinkSpacer (CHARACTER 13)))
			  (FNS NC.CachedMakeFilingLink)
			  (* * Changes for NCLINKS)
			  (FNS NC.MakeFilingLink)
			  (* * Delete the following functions from NCLINKS: NC.InsertLinkInOrdering 
			     NC.CachedInsertLinkInOrdering NC.InsertLinkBeforeMarker)
			  (* * New function for NCUTILITIES)
			  (FNS NC.MarkerMatchesCardP)))
(* * This patch file revamps the filebox mechanism for inserting new links. Supersedes all the
 insert-before-marker and insert-in-ordering cruft.)

(* * New stuff for NCLINKS)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.FileBoxLinkSpacer)
)

(RPAQ? NC.FileBoxLinkSpacer (CHARACTER 13))
(DEFINEQ

(NC.CachedMakeFilingLink
  (LAMBDA (SourceCard DestinationCard LinkType DisplayMode IgnoreMarkersFlg)
                                                             (* rht: "13-Oct-86 12:31")

          (* * Assumes SourceCard is cached. Inserts a link to DestinationCard into SourceCard. Unless IgnoreMarkersFlg is 
	  non-nil or there's no marker for type of DestinationCard, then will insert somewhere between appropriate marker and
	  either the next marker or the end of SourceCard substance using SourceCard's OrderingFn to determine where to 
	  insert. If there's no OrderingFn, but there is an appropriate marker, then stick at end of group.
	  If no marker and no OrderingFn, then stick wherever cursor is.)


    (LET ((OrderingFn (NC.GetProp SourceCard (QUOTE OrderingFn)))
	  (TextStream (NC.FetchSubstance SourceCard))
	  StartLoc EndLoc TextObject FoundMarkerFlg Link)
         (SETQ TextObject (TEXTOBJ TextStream))
         (OR IgnoreMarkersFlg (SETQ FoundMarkerFlg (for MarkerPairs
							  on (TEDIT.LIST.OF.OBJECTS
								 TextObject
								 (FUNCTION NC.PlaceMarkerP))
							  eachtime (BLOCK)
							  do (if (NC.MarkerMatchesCardP
								       (CAAR MarkerPairs)
								       DestinationCard)
								   then
								    (SETQ StartLoc (CADAR 
										      MarkerPairs))
								    (SETQ EndLoc
								      (OR (CADADR MarkerPairs)
									    (ADD1 (GETEOFPTR
										      TextStream))))
								    (RETURN T))
							  finally (SETQ StartLoc 1)
								    (SETQ EndLoc
								      (ADD1 (GETEOFPTR TextStream)
									      )))))
         (COND
	   (OrderingFn (for ObjectPair in (TEDIT.LIST.OF.OBJECTS TextObject
								       (FUNCTION 
									 NC.LinkIconImageObjP))
			  eachtime (BLOCK) until (GREATERP (CADR ObjectPair)
								   EndLoc)
			  when (AND (LEQ StartLoc (CADR ObjectPair))
					(APPLY* OrderingFn DestinationCard
						  (fetch (Link DestinationCard)
						     of (NC.FetchLinkFromLinkIcon (CAR 
										       ObjectPair)))))
			  do (TEDIT.SETSEL TextStream (CADR ObjectPair)
					       0
					       (QUOTE LEFT))
			       (RETURN)
			  finally (TEDIT.SETSEL TextStream EndLoc 0 (QUOTE RIGHT))))
	   (FoundMarkerFlg (TEDIT.SETSEL TextStream EndLoc 0 (QUOTE RIGHT))))
         (PROG1 (NC.InsertLinkInText TextStream LinkType DestinationCard SourceCard DisplayMode)
		  (TEDIT.INSERT TextStream NC.FileBoxLinkSpacer)))))
)
(* * Changes for NCLINKS)

(DEFINEQ

(NC.MakeFilingLink
  (LAMBDA (SourceCard DestinationCard LinkType)              (* rht: "13-Oct-86 12:09")

          (* Make a link from FileBox to DestinationCard If card is a regular card, insert link at end of contents card.
	  If card is a supercontents of contents card then insert just before the subcontents marker 
	  (i.e., at end of super contents list). If card is a subcontents card then insert just before note cards marker 
	  (i.e., at end of subcontents list))



          (* * rht 10/25/85: Now checks if card's window is shrunken. If so, shrink it back at the end.)



          (* * kirk: 14Nov85: deleted use of of DatabaseStream)



          (* * fgh 11/15/85 Adapted from and intended to replace NC.MakeAContentsHook)



          (* * kirk 11Apr86 took out hard coded link display mode)



          (* * rht 10/13/86: Totally overhauled. Now calls NC.CachedMakeFilingLink which does both inserting before markers 
	  and inserting in ordering.)


    (if (NC.ActiveCardP SourceCard)
	then (NC.IfMultipleCardPartsNotBusy SourceCard (SUBSTANCE TOLINKS FROMLINKS GLOBALTOLINKS)
					      (LET ((ShrunkenFlg (NC.GetShrunkenWin SourceCard)))
					           (PROG1 (NC.CachedMakeFilingLink SourceCard 
										  DestinationCard 
										       LinkType)
							    (AND ShrunkenFlg (SHRINKW
								     (NC.FetchWindow SourceCard)))))
					      )
      else (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
			   (NC.IfMultipleCardPartsNotBusy
			     SourceCard
			     (SUBSTANCE TOLINKS FROMLINKS GLOBALTOLINKS)
			     (if (NC.CardP (NC.GetNoteCard SourceCard))
				 then 

          (* * This next set of obtain write locks is only to make sure that we come out even when NC.DeactivateCard releases
	  the write locks. Note that the SourceCard will be deactivated upon exit of the RESETLST, as set up by the 
	  RESETSAVE.)


					(RESETSAVE (for CardPart
							in (QUOTE (SUBSTANCE TOLINKS 
										 GLOBALTOLINKS 
										 PROPLIST))
							do (APPLY* (fetch (Card 
									  ObtainWritePermissionFn)
									  of SourceCard)
								       SourceCard CardPart))
						     (BQUOTE (NC.DeactivateCard , SourceCard)))
					(PROG1 (NC.CachedMakeFilingLink SourceCard 
									    DestinationCard LinkType)
						 (NC.PutMainCardData SourceCard)
						 (NC.PutLinks SourceCard))))))))
)
(* * Delete the following functions from NCLINKS: NC.InsertLinkInOrdering 
NC.CachedInsertLinkInOrdering NC.InsertLinkBeforeMarker)

(* * New function for NCUTILITIES)

(DEFINEQ

(NC.MarkerMatchesCardP
  (LAMBDA (MarkerImageObject Card)                           (* rht: "13-Oct-86 12:08")

          (* * Return non-nil if Marker is appropriate for Card.)


    (AND (NC.PlaceMarkerP MarkerImageObject)
	   (STREQUAL (IMAGEOBJPROP MarkerImageObject (QUOTE OBJECTDATUM))
		       (if (NC.FileBoxP Card T)
			   then "File Boxes"
			 else "Note Cards")))))
)
(PUTPROPS RHTPATCH116 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1326 4012 (NC.CachedMakeFilingLink 1336 . 4010)) (4045 6587 (NC.MakeFilingLink 4055 . 
6585)) (6767 7203 (NC.MarkerMatchesCardP 6777 . 7201)))))
STOP