[MLton-commit] r5697

Vesa Karvonen vesak at mlton.org
Fri Jun 29 07:21:21 PDT 2007


Reload project files automatically.

----------------------------------------------------------------------

U   mlton/trunk/ide/emacs/bg-build-mode.el
U   mlton/trunk/ide/emacs/bg-build-util.el

----------------------------------------------------------------------

Modified: mlton/trunk/ide/emacs/bg-build-mode.el
===================================================================
--- mlton/trunk/ide/emacs/bg-build-mode.el	2007-06-29 13:28:57 UTC (rev 5696)
+++ mlton/trunk/ide/emacs/bg-build-mode.el	2007-06-29 14:21:21 UTC (rev 5697)
@@ -15,8 +15,10 @@
 ;; XXX: Commands: goto-last-build-buffer
 ;; XXX: Better compilation-mode:
 ;;      - Give count of warnings and errors
+;;      - Is there a supported way to just parse the error messages and
+;;        access the results of the parse?  If not, I'll probably have to
+;;        write a new new compilation mode.
 ;;      - Highlighting in XEmacs
-;; XXX: Reload project file automatically
 ;; XXX: Combinators for making common project configurations:
 ;;      - E.g. grep for saved files from given file
 ;; XXX: Highlight (lines with) errors and warnings
@@ -123,7 +125,9 @@
                ((stringp shell)
                 (bg-build-const (split-string shell "[ \n\t]+")))
                (t
-                (compat-error "Shell command required!"))))))
+                (compat-error "Shell command required!"))))
+   (cons 'attr
+         (file-attributes file))))
 
 (defun bg-build-call-prj (project fun &rest args)
   (let* ((file (car project))
@@ -281,6 +285,16 @@
 (defvar bg-build-saved-files nil)
 
 (defun bg-build-files-saved-timeout ()
+  (mapc
+   (function
+    (lambda (project)
+      (let ((file (car project))
+            (data (cdr project)))
+        (when (bg-build-attr-newer?
+               (file-attributes file)
+               (bg-build-assoc-cdr 'attr data))
+          (bg-build-add-project file)))))
+   bg-build-projects)
   (let ((saved-files bg-build-saved-files))
     (setq bg-build-saved-files nil)
     (mapc

Modified: mlton/trunk/ide/emacs/bg-build-util.el
===================================================================
--- mlton/trunk/ide/emacs/bg-build-util.el	2007-06-29 13:28:57 UTC (rev 5696)
+++ mlton/trunk/ide/emacs/bg-build-util.el	2007-06-29 14:21:21 UTC (rev 5697)
@@ -58,6 +58,20 @@
   "Returns the current line number counting from 1."
   (+ 1 (count-lines 1 (bg-build-point-at-current-line))))
 
+(defun bg-build-time-to-double (time)
+  "Converts a time to a double."
+  (+ (* (car time) 65536.0)
+     (cadr time)
+     (if (cddr time) (* (caddr time) 1e-06) 0)))
+
+(defun bg-build-attr-newer? (attr1 attr2)
+  "Returns non-nil iff the modification time of `attr1' is later than the
+modification time of `attr2'.  Note that this also returns nil when either
+one of the modification times is nil."
+  (and attr1 attr2
+       (> (bg-build-time-to-double (nth 5 attr1))
+          (bg-build-time-to-double (nth 5 attr2)))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (provide 'bg-build-util)




More information about the MLton-commit mailing list