Add generic hook for taking action after a buffer's pathname is
authorChris Hanson <org/chris-hanson/cph>
Sat, 25 Mar 2000 20:34:54 +0000 (20:34 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 25 Mar 2000 20:34:54 +0000 (20:34 +0000)
changed.

v7/src/edwin/buffer.scm

index 8aae9a2096cf543804b4e525820599db96799829..56c04bb0d1ed17e3f8e82e365d0f1b9705060b50 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: buffer.scm,v 1.176 2000/03/23 03:19:02 cph Exp $
+;;; $Id: buffer.scm,v 1.177 2000/03/25 20:34:54 cph Exp $
 ;;;
 ;;; Copyright (c) 1986, 1989-2000 Massachusetts Institute of Technology
 ;;;
@@ -124,6 +124,7 @@ The buffer is guaranteed to be deselected at that time."
      (%set-buffer-major-mode!
       buffer
       (variable-default-value (ref-variable-object editor-default-mode)))
+     (event-distributor/invoke! event:set-buffer-pathname buffer)
      (buffer-modeline-event! buffer 'BUFFER-RESET))))
 
 (define (set-buffer-name! buffer name)
@@ -137,8 +138,12 @@ The buffer is guaranteed to be deselected at that time."
   (set-buffer-%pathname! buffer pathname)
   (if pathname
       (set-buffer-default-directory! buffer (directory-pathname pathname)))
+  (event-distributor/invoke! event:set-buffer-pathname buffer)
   (buffer-modeline-event! buffer 'BUFFER-PATHNAME))
 
+(define event:set-buffer-pathname
+  (make-event-distributor))
+
 (define (set-buffer-truename! buffer truename)
   (set-buffer-%truename! buffer truename)
   (buffer-modeline-event! buffer 'BUFFER-TRUENAME))
@@ -257,6 +262,17 @@ The buffer is guaranteed to be deselected at that time."
             (set-group-modified?! group #t)
             (buffer-modeline-event! buffer 'BUFFER-MODIFIED)))))))
 
+(define (verify-visited-file-modification-time? buffer)
+  (let ((truename (buffer-truename buffer))
+       (buffer-time (buffer-modification-time buffer)))
+    (or (not truename)
+       (not buffer-time)
+       (let ((file-time (file-modification-time truename)))
+         (and file-time (< (abs (- buffer-time file-time)) 2))))))
+
+(define-integrable (clear-visited-file-modification-time! buffer)
+  (set-buffer-modification-time! buffer #f))
+
 (define (set-buffer-auto-saved! buffer)
   (set-buffer-auto-saved?! buffer #t)
   (set-group-modified?! (buffer-group buffer) 'AUTO-SAVED))