Trim trailing whitespaces.
[elisp/wanderlust.git] / elmo / elmo-localdir.el
index 0c8597d..fb16b14 100644 (file)
@@ -4,7 +4,6 @@
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 ;; Keywords: mail, net news
-;; Time-stamp: <2000-05-18 17:12:55 teranisi>
 
 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
 
@@ -69,8 +68,8 @@
       (when (file-exists-p file)
        ;; Read until header separator is found.
        (while (and (eq elmo-localdir-header-chop-length
-                       (nth 1 
-                            (as-binary-input-file 
+                       (nth 1
+                            (as-binary-input-file
                              (insert-file-contents
                               file nil beg
                               (incf beg elmo-localdir-header-chop-length)))))
@@ -98,7 +97,7 @@
              (elmo-localdir-insert-header file)
            (error (throw 'done nil)))
          (goto-char (point-min))
-         (setq header-end 
+         (setq header-end
                (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t)
                    (point)
                  (point-max)))
   (elmo-localdir-msgdb-create-overview-entity-from-file
    number (expand-file-name (int-to-string number) dir)))
 
-(defun elmo-localdir-msgdb-create-as-numlist (spec numlist new-mark 
-                                                  already-mark seen-mark 
+(defun elmo-localdir-msgdb-create-as-numlist (spec numlist new-mark
+                                                  already-mark seen-mark
                                                   important-mark seen-list)
   (when numlist
     (let ((dir (elmo-localdir-get-folder-directory spec))
       (message "Creating msgdb...")
       (while numlist
        (setq entity
-             (elmo-localdir-msgdb-create-entity 
+             (elmo-localdir-msgdb-create-entity
               dir (car numlist)))
        (if (null entity)
            ()
          (setq num (elmo-msgdb-overview-entity-get-number entity))
-         (setq overview 
+         (setq overview
                (elmo-msgdb-append-element
                 overview entity))
          (setq number-alist
          (setq seen (member message-id seen-list))
          (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
                              (if (elmo-cache-exists-p message-id) ; XXX
-                                 (if seen 
+                                 (if seen
                                      nil
                                    already-mark)
-                               (if seen 
+                               (if seen
                                    nil ;;seen-mark
                                  new-mark))))
              (setq mark-alist
-                   (elmo-msgdb-mark-append 
-                    mark-alist 
+                   (elmo-msgdb-mark-append
+                    mark-alist
                     num
                     gmark))))
        (setq i (1+ i))
            (setq dirent (cdr dirent))
            (setq abspath (expand-file-name relpath curdir))
            (and
-            (not (string-match 
+            (not (string-match
                   elmo-localdir-list-folders-filter-regexp
                   relpath))
             (eq (nth 0 (setq attr (file-attributes abspath))) t)
     (setq file (expand-file-name number dir))
     (if (and (string-match "[0-9]+" number) ; for safety.
             (file-exists-p file)
-            (file-writable-p file) 
+            (file-writable-p file)
             (not (file-directory-p file)))
        (progn (delete-file file)
               t))))
 (defun elmo-localdir-check-validity (spec validity-file)
   (let* ((dir (elmo-localdir-get-folder-directory spec))
         (cur-val (nth 5 (file-attributes dir)))
-        (file-val (read 
+        (file-val (read
                    (or (elmo-get-file-string validity-file)
                        "nil"))))
     (cond
       (prin1 (nth 5 (file-attributes dir)) tmp-buffer)
       (princ "\n" tmp-buffer)
       (if (file-writable-p validity-file)
-         (write-region (point-min) (point-max) 
+         (write-region (point-min) (point-max)
                        validity-file nil 'no-msg)
        (message (format "%s is not writable." number-file)))
       (kill-buffer tmp-buffer))))
        t))))
 
 (defsubst elmo-localdir-field-condition-match (spec number condition)
-  (elmo-file-field-condition-match 
+  (elmo-file-field-condition-match
    (expand-file-name (int-to-string number)
                     (elmo-localdir-get-folder-directory spec))
    condition))
        (onum-alist (elmo-msgdb-get-number-alist msgdb))
        (omark-alist (elmo-msgdb-get-mark-alist msgdb))
        (oov (elmo-msgdb-get-overview msgdb))
-       i flist onum mark new-mark-alist total)
-    (setq i 0)
+       (new-number 1)                  ; first ordinal position in localdir
+       flist onum mark new-mark-alist total)
     (setq flist
          (if elmo-pack-number-check-strict
-             (elmo-call-func spec "list-folder") ;; allow localnews
+             (elmo-call-func spec "list-folder") ; allow localnews
            (mapcar 'car onum-alist)))
     (setq total (length flist))
     (while flist
       (elmo-display-progress
        'elmo-localdir-pack-number "Packing..."
-       (/ (* i 100) total))
+       (/ (* new-number 100) total))
       (setq onum (car flist))
-      (when (not (eq onum i)) ;; why \=() is wrong..
+      (when (not (eq onum new-number))         ; why \=() is wrong..
         (elmo-bind-directory
         dir
         ;; xxx  nfs,hardlink
-        (rename-file (int-to-string onum) (int-to-string i) t))
+        (rename-file (int-to-string onum) (int-to-string new-number) t))
         ;; update overview
         (elmo-msgdb-overview-entity-set-number
         (elmo-msgdb-overview-get-entity-by-number
-         oov onum) i)
+         oov onum) new-number)
        ;; update number-alist
-       (setcar (assq onum onum-alist) i))
+       (setcar (assq onum onum-alist) new-number))
       ;; update mark-alist
       (when (setq mark (cadr (assq onum omark-alist)))
        (setq new-mark-alist
              (elmo-msgdb-mark-append
               new-mark-alist
-              i mark)))
-      (setq i (1+ i))
+              new-number mark)))
+      (setq new-number (1+ new-number))
       (setq flist (cdr flist)))
     (message "Packing...done.")
     (list (elmo-msgdb-get-overview msgdb)
   t)
 
 (defun elmo-localdir-get-msg-filename (spec number &optional loc-alist)
-  (expand-file-name 
+  (expand-file-name
    (int-to-string number)
    (elmo-localdir-get-folder-directory spec)))
 
                (throw 'found t))
            (setq lock (cdr lock)))))))
 
-(defalias 'elmo-localdir-sync-number-alist 
+(defalias 'elmo-localdir-sync-number-alist
   'elmo-generic-sync-number-alist)
-(defalias 'elmo-localdir-list-folder-unread 
+(defalias 'elmo-localdir-list-folder-unread
   'elmo-generic-list-folder-unread)
 (defalias 'elmo-localdir-list-folder-important
   'elmo-generic-list-folder-important)