[uim-commit] r1165 - trunk/scm

tkng at freedesktop.org tkng at freedesktop.org
Tue Aug 9 10:04:53 EST 2005


Author: tkng
Date: 2005-08-08 17:04:50 -0700 (Mon, 08 Aug 2005)
New Revision: 1165

Modified:
   trunk/scm/custom-rt.scm
Log:
* scm/custom-rt.scm: This commit aims avoid needless reloading of config files.
  If a config file is not updated, then it would not be loaded while config reloading.
 -(custom-reload-group-syms): Now this list is an alist. Spec of each element
  is: (symbol-for-config-file . mtime-of-config-file)
  We should rename this variable with more proper name.
 -(prepend-new-reload-group-syms): New procedure.
 -(update-gsym-mtime): New procedure.
 -(custom-load-group-conf, custom-reload-configs): All function which used 
  custom-reload-group-syms somewhile are modified.
  s/custom-reload-group-syms/(map car custom-reload-group-syms)/;


Modified: trunk/scm/custom-rt.scm
===================================================================
--- trunk/scm/custom-rt.scm	2005-08-08 23:52:37 UTC (rev 1164)
+++ trunk/scm/custom-rt.scm	2005-08-09 00:04:50 UTC (rev 1165)
@@ -55,18 +55,33 @@
 (define custom-rt-primary-groups ())
 (define custom-set-hooks ())
 
+(define prepend-new-reload-group-syms
+  (lambda (gsym path)
+    (set! custom-reload-group-syms
+	  (cons (cons gsym 0) custom-reload-group-syms))))
+
+(define update-gsym-mtime
+  (lambda (gsym path)
+    (set-cdr! (assq gsym custom-reload-group-syms)
+	      (get-file-mtime path))
+	      #t))
+
 ;; full implementation
 (define custom-load-group-conf
   (lambda (gsym)
-    (if (not (memq gsym custom-reload-group-syms))
-	(set! custom-reload-group-syms
-	      (cons gsym custom-reload-group-syms)))
     (let* ((group-name (symbol->string gsym))
 	   (path (string-append (getenv "HOME")
 				"/.uim.d/customs/custom-"
 				group-name
 				".scm")))
-      (try-load path))))
+      (if (not (memq gsym (map (lambda (x) (car x)) custom-reload-group-syms)))
+	  (prepend-new-reload-group-syms gsym path))
+      (if (= (get-file-mtime path)
+	     (cdr (assq gsym custom-reload-group-syms)))
+	    #t ; File isn't modified, no need to reload. 
+	  (if (try-load path)
+	      (update-gsym-mtime gsym path)
+	      #f)))))
 
 ;; full implementation
 (define require-custom
@@ -202,7 +217,7 @@
 
 (define custom-reload-configs
   (lambda ()
-    (if (null? custom-reload-group-syms)
-	#f ; No file should be loaded.
-	(begin
-	  (for-each custom-load-group-conf (reverse custom-reload-group-syms))))))
+    (let ((group-syms (map (lambda (x) (car x)) custom-reload-group-syms)))
+      (if (null? group-syms)
+	  #f ; No file should be loaded.
+	  (for-each custom-load-group-conf (reverse group-syms))))))



More information about the uim-commit mailing list