Use modb-standard-entity-filename instead of hardcoded name
authorvitaly <v.mayatskih@gmail.com>
Thu, 26 Mar 2009 13:19:39 +0000 (26 14:19 +0100)
committervitaly <v.mayatskih@gmail.com>
Thu, 26 Mar 2009 13:19:39 +0000 (26 14:19 +0100)
That's it: use standard thing.

elmo/modb-standard.el

index 43c3562..f268c3a 100644 (file)
 
 (defun modb-standard-cleanup-stale-entities (modb path)
   (message "Removing stale entities...")
-  (let ((entities (elmo-uniq-list
-                  (mapcar
-                   #'(lambda (x) (/ x modb-standard-divide-number))
-                   (modb-standard-number-list-internal modb))))
-       (files (mapcar #'(lambda(x)
-                          (when (string-match "^entity-\\([0-9]+\\)" x)
-                            (string-to-int (match-string 1 x))))
-                      (directory-files path nil "^entity-"))))
+  (let* ((entity-regex
+         (concat "^" modb-standard-entity-filename "-\\([0-9]+\\)"))
+        (entities (elmo-uniq-list
+                   (mapcar
+                    #'(lambda (x) (/ x modb-standard-divide-number))
+                    (modb-standard-number-list-internal modb))))
+        (files (mapcar #'(lambda(x)
+                           (when (string-match entity-regex x)
+                             (string-to-int (match-string 1 x))))
+                       (directory-files path nil entity-regex))))
     (dolist (entity (car (elmo-list-diff-nonsortable files entities)))
-      (ignore-errors (delete-file (expand-file-name
-                                  (modb-standard-entity-filename entity) path))))))
+      (ignore-errors (delete-file
+                     (expand-file-name
+                      (modb-standard-entity-filename entity) path))))))
 
 (defun modb-standard-save-entity (modb path)
   (let ((modified (modb-generic-message-modified-internal modb)))