;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*- ;;; Patch file for System version 124.31 ;;; Reason: ;;; Find a file in ZMacs which is/was associated with a buffer. It has been ;;; deleted behind your back. ZMacs probes to see if the file still exists. ;;; ;;; determines this properly and gives the user a message. Before ;;; you could get an error. ;;; Written 7-Jun-88 11:54:45 by keith (Keith M. Corbett) at site Gigamos Cambridge ;;; while running on Breaking Glass from band 3 ;;; with Experimental System 124.24, Experimental Local-File 74.1, Experimental File-Server 23.1, Experimental Unix-Interface 12.0, Experimental ZMail 72.0, Experimental Tape 23.6, Experimental Lambda-Diag 16.1, microcode 1756, SDU Boot Tape 3.14, SDU ROM 103. ; From modified file DJ: L.ZWEI; ZMACS.LISP#572 at 7-Jun-88 11:54:46 #8R ZWEI#: (COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI"))) (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; ZMACS  " (DEFUN FIND-FILE (PATHNAME &OPTIONAL (SELECT-P T) QUIETLY (LOAD-P T) DONT-SECTIONIZE &AUX BUFFER STREAM) "Return a buffer visiting file PATHNAME, reading file in if necessary. If SELECT-P is T (the default), select the buffer also. QUIETLY non-NIL means do not print messages about reading the file. If LOAD-P is NIL, we do not read the file, just create a buffer supposedly visiting that file (as if the file did not exist). If there is already a buffer visiting the file, we check to see if a more recent version of the file exists in the file system and offer to revert if so. To avoid this, try FIND-FILE-BUFFER before you try FIND-FILE. If DONT-SECTIONIZE is non-NIL, we mark all the buffers not to be sectionized. If PATHNAME has wildcards, we visit all the files specified." (IF (STRINGP PATHNAME) (SETQ PATHNAME (FS:MERGE-PATHNAME-DEFAULTS PATHNAME))) (IF (SEND PATHNAME :WILD-P) (SEND PATHNAME :WILDCARD-MAP #'FIND-FILE-1 NIL NIL (SEND PATHNAME :VERSION) SELECT-P QUIETLY LOAD-P DONT-SECTIONIZE) (SETQ BUFFER (OR (FIND-FILE-BUFFER PATHNAME) (MAKE-INSTANCE 'ZMACS-BUFFER :NAME NIL))) (IF DONT-SECTIONIZE (SETF (GET BUFFER ':DONT-SECTIONIZE) T) (REMPROP BUFFER ':DONT-SECTIONIZE)) (IF (NULL (BUFFER-FILE-ID BUFFER)) (IF LOAD-P (REVERT-BUFFER BUFFER PATHNAME (IF DONT-SECTIONIZE 'NOSECTIONIZE T) (AND SELECT-P *FIND-FILE-EARLY-SELECT*) QUIETLY) (SET-BUFFER-PATHNAME PATHNAME BUFFER)) (IF (NULL (SETQ STREAM (OPEN PATHNAME :DIRECTION :PROBE))) (AND (NOT (SYMBOLP (BUFFER-FILE-ID BUFFER))) (FORMAT *QUERY-IO* "~&Note: File ~A has been deleted." PATHNAME)) (MULTIPLE-VALUE-BIND (NEW-DESC OLD-DESC) (STREAM-CHECK-FILE-ID STREAM (BUFFER-FILE-ID BUFFER)) (COND ((AND (SYMBOLP (BUFFER-FILE-ID BUFFER)) (BP-= (INTERVAL-FIRST-BP BUFFER) (INTERVAL-LAST-BP BUFFER))) (WHEN (YES-OR-NO-P "The file ~A exists now. Read it in? " PATHNAME) (REVERT-BUFFER BUFFER PATHNAME (IF DONT-SECTIONIZE 'NOSECTIONIZE T) (AND SELECT-P *FIND-FILE-EARLY-SELECT*)))) ((SYMBOLP (BUFFER-FILE-ID BUFFER))) ((NOT NEW-DESC)) ((BUFFER-NEEDS-SAVING-P BUFFER) (BEEP) (FORMAT T "Since you last read or wrote ~A (~A), while you've been editing, someone has written a new copy out (~A). You will lose some work if you are not careful. I will leave you your old copy instead of reading the new one. I suggest that you file this out under a different name and then SRCCOM the two files. Do M-X Revert if you really want the new one.~%" PATHNAME OLD-DESC NEW-DESC)) (T (FORMAT T "Since you last read or wrote ~A (~A), someone else wrote a new version on disk (~A). Luckily, you haven't edited the buffer since then. Your old copy is still in the buffer. " PATHNAME OLD-DESC NEW-DESC) (WHEN (FQUERY `(:STREAM ,*STANDARD-OUTPUT* . ,FORMAT::YES-OR-NO-P-OPTIONS) "Do you want the new version instead? ") (REVERT-BUFFER BUFFER PATHNAME (IF DONT-SECTIONIZE 'NOSECTIONIZE T) (AND SELECT-P *FIND-FILE-EARLY-SELECT*)))))))) (SEND BUFFER :ACTIVATE T) (IF SELECT-P (MAKE-BUFFER-CURRENT BUFFER)) BUFFER)) ))