* elmo-imap4.el (elmo-imap4-list-folders): When hierarchy is
authorokada <okada>
Sun, 5 Nov 2000 17:54:53 +0000 (17:54 +0000)
committerokada <okada>
Sun, 5 Nov 2000 17:54:53 +0000 (17:54 +0000)
non-nil, make hierarchy.

elmo/ChangeLog
elmo/elmo-imap4.el

index f181777..e41fdb2 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-06  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-imap4.el (elmo-imap4-list-folders): When hierarchy is
+       non-nil, make hierarchy.
+
 2000-11-05  OKAZAKI Tetsurou  <okazaki@be.to>
 
        * elmo-pipe.el (elmo-pipe-drain): When calling `elmo-list-folder',
index 1d90519..f3d1327 100644 (file)
@@ -567,11 +567,40 @@ BUFFER must be a single-byte buffer."
          (setq append-serv (concat append-serv
                                    (elmo-network-stream-type-spec-string
                                     type)))))
-    (mapcar (lambda (fld)
-             (concat "%" (elmo-imap4-decode-folder-string fld)
-                     (and append-serv
-                          (eval append-serv))))
-           result)))
+    (if hierarchy
+       (let (folder folders ret)
+         (while (setq folders (car result))
+           (if (prog1 
+                   (string-match
+                    (concat "^\\(" root "[^" delim "]" "+\\)" delim)
+                         folders)
+                 (setq folder (match-string 1 folders)))
+               (progn
+                 (setq ret 
+                       (append ret (list (list
+                                          (concat "%" (elmo-imap4-decode-folder-string folder)
+                                                  (and append-serv
+                                                       (eval append-serv)))))))
+                 (setq result
+                       (delq nil
+                             (mapcar '(lambda (fld)
+                                        (unless
+                                            (string-match
+                                             (concat "^" (regexp-quote folder))
+                                             fld)
+                                          fld))
+                                     result))))
+             (setq ret (append ret (list 
+                                    (concat "%" (elmo-imap4-decode-folder-string folders)
+                                            (and append-serv
+                                                 (eval append-serv))))))
+             (setq result (cdr result))))
+         ret)
+      (mapcar (lambda (fld)
+               (concat "%" (elmo-imap4-decode-folder-string fld)
+                       (and append-serv
+                            (eval append-serv))))
+             result))))
 
 (defun elmo-imap4-folder-exists-p (spec)
   (let ((session (elmo-imap4-get-session spec)))