[MLton-commit] r5671

Vesa Karvonen vesak at mlton.org
Sun Jun 24 05:55:40 PDT 2007


Filter out potentially invalid symbol references in `esml-du-sym-to-uses`.

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

U   mlton/trunk/ide/emacs/def-use-util.el
U   mlton/trunk/ide/emacs/esml-du-mlton.el

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

Modified: mlton/trunk/ide/emacs/def-use-util.el
===================================================================
--- mlton/trunk/ide/emacs/def-use-util.el	2007-06-24 05:03:46 UTC (rev 5670)
+++ mlton/trunk/ide/emacs/def-use-util.el	2007-06-24 12:55:39 UTC (rev 5671)
@@ -12,9 +12,9 @@
 ;; In Gnu Emacs, `buffer-file-truename' is abbreviated while in XEmacs it
 ;; isn't.  This isn't in compat.el, because we want to use our cached
 ;; version of `file-truename', namely `def-use-file-truename'.
-(defun def-use-buffer-file-truename ()
+(defun def-use-buffer-file-truename (&rest buffer)
   "Returns the true filename of the current buffer."
-  (let ((name (buffer-file-name)))
+  (let ((name (apply (function buffer-file-name) buffer)))
     (when name
       (def-use-file-truename name))))
 
@@ -98,13 +98,18 @@
               (lambda (key value)
                 (push (cons key value) result)))
              hash-table)
-    (nreverse result)))
+    result))
 
 (defun def-use-hash-table-to-key-list (hash-table)
-  "Returns a list of the keys of the set (identity hash-table)."
+  "Returns a list of the keys of hash-table."
   (mapcar (function car)
           (def-use-hash-table-to-assoc-list hash-table)))
 
+(defun def-use-hash-table-to-value-list (hash-table)
+  "Returns a list of the values of the hash-table."
+  (mapcar (function cdr)
+          (def-use-hash-table-to-assoc-list hash-table)))
+
 (defun def-use-set-to-list (set)
   "Returns a list of the keys of the set (identity hash-table)."
   (def-use-hash-table-to-key-list set))

Modified: mlton/trunk/ide/emacs/esml-du-mlton.el
===================================================================
--- mlton/trunk/ide/emacs/esml-du-mlton.el	2007-06-24 05:03:46 UTC (rev 5670)
+++ mlton/trunk/ide/emacs/esml-du-mlton.el	2007-06-24 12:55:39 UTC (rev 5671)
@@ -152,7 +152,32 @@
 
 (defun esml-du-sym-to-uses (sym ctx)
   (esml-du-reload ctx)
-  (gethash sym (esml-du-ctx-sym-to-uses-table ctx)))
+  (let ((file-to-poss (def-use-make-hash-table)))
+    ;; Process by buffer/file as it avoids repeated work
+    (mapc (function
+           (lambda (ref)
+             (puthash (def-use-ref-src ref)
+                      (cons ref
+                            (gethash (def-use-ref-src ref) file-to-poss))
+                      file-to-poss)))
+          (gethash sym (esml-du-ctx-sym-to-uses-table ctx)))
+    ;; Remove references to modified buffers
+    (mapc (function
+           (lambda (buffer)
+             (when (buffer-modified-p buffer)
+               (remhash (def-use-buffer-file-truename buffer)
+                        file-to-poss))))
+          (buffer-list))
+    ;; Remove references to modified files
+    (mapc (function
+           (lambda (file)
+             (when (def-use-attr-newer?
+                     (file-attributes file)
+                     (esml-du-ctx-attr ctx))
+               (remhash file file-to-poss))))
+          (def-use-hash-table-to-key-list file-to-poss))
+    (apply (function nconc)
+           (def-use-hash-table-to-value-list file-to-poss))))
 
 (defun esml-du-stop-parsing (ctx)
   (let ((buffer (esml-du-ctx-buf ctx)))




More information about the MLton-commit mailing list