Apply SSL patch.
[elisp/wanderlust.git] / elmo / elmo-util.el
index c43eaac..c493d00 100644 (file)
@@ -1,6 +1,6 @@
 ;;; elmo-util.el -- Utilities for Elmo.
 
-;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 ;; Keywords: mail, net news
@@ -157,7 +157,7 @@ File content is encoded with MIME-CHARSET."
     (if (file-writable-p filename)
        (progn
          (when mime-charset
-           ;;(elmo-set-buffer-multibyte default-enable-multibyte-characters)
+;;;        (elmo-set-buffer-multibyte default-enable-multibyte-characters)
            (encode-mime-charset-region (point-min) (point-max) mime-charset))
          (as-binary-output-file
           (write-region (point-min) (point-max) filename nil 'no-msg)))
@@ -169,7 +169,7 @@ Directory of the file is created if it doesn't exist.
 File content is encoded with MIME-CHARSET."
   (elmo-set-work-buf
    (prin1 object (current-buffer))
-   ;;(princ "\n" (current-buffer))
+;;;(princ "\n" (current-buffer))
    (elmo-save-buffer filename mime-charset)))
 
 (defsubst elmo-imap4-decode-folder-string (string)
@@ -324,9 +324,9 @@ File content is encoded with MIME-CHARSET."
        )
       (if (file-name-absolute-p fld-name)
          (setq path (expand-file-name fld-name))
+;;;    (setq path (expand-file-name fld-name
+;;;                                 elmo-localdir-folder-path))
        (setq path fld-name))
-       ;(setq path (expand-file-name fld-name
-       ;elmo-localdir-folder-path)))
       (list (if (elmo-folder-maildir-p folder)
                'maildir
              'localdir) path))))
@@ -667,7 +667,11 @@ Return value is a cons cell of (STRUCTURE . REST)"
 (defun elmo-uniq-list (lst)
   "Distractively uniqfy elements of LST."
   (let ((tmp lst))
-    (while tmp (setq tmp (setcdr tmp (and (cdr tmp) (delete (car tmp) (cdr tmp)))))))
+    (while tmp (setq tmp
+                    (setcdr tmp
+                            (and (cdr tmp)
+                                 (delete (car tmp)
+                                         (cdr tmp)))))))
   lst)
 
 (defun elmo-string-partial-p (string)
@@ -749,9 +753,9 @@ Return value is a cons cell of (STRUCTURE . REST)"
       (erase-buffer)
       (prin1 elmo-passwd-alist tmp-buffer)
       (princ "\n" tmp-buffer)
-;      (if (and (file-exists-p filename)
-;             (not (equal 384 (file-modes filename))))
-;        (error "%s is not safe.chmod 600 %s!" filename filename))
+;;;   (if (and (file-exists-p filename)
+;;;           (not (equal 384 (file-modes filename))))
+;;;      (error "%s is not safe.chmod 600 %s!" filename filename))
       (if (file-writable-p filename)
          (progn
            (write-region (point-min) (point-max)
@@ -844,7 +848,7 @@ Return value is a cons cell of (STRUCTURE . REST)"
 
 ;; from subr.el
 (defun elmo-replace-in-string (str regexp newtext &optional literal)
-  "Replaces all matches in STR for REGEXP with NEWTEXT string.
+  "Replace all matches in STR for REGEXP with NEWTEXT string.
 And returns the new string.
 Optional LITERAL non-nil means do a literal replacement.
 Otherwise treat \\ in NEWTEXT string as special:
@@ -1050,8 +1054,7 @@ Otherwise treat \\ in NEWTEXT string as special:
        (elmo-make-directory parent))
     (make-directory path)
     (if (string= path (expand-file-name elmo-msgdb-dir))
-       (set-file-modes path 448) ; 700
-      )))
+       (set-file-modes path (+ (* 64 7) (* 8 0) 0))))) ; chmod 0700
 
 (defun elmo-delete-directory (path &optional no-hierarchy)
   "Delete directory recursively."
@@ -1191,10 +1194,12 @@ Otherwise treat \\ in NEWTEXT string as special:
   (cond ((eq (elmo-folder-get-type folder1) 'imap4)
         (let ((spec1 (elmo-folder-get-spec folder1))
               (spec2 (elmo-folder-get-spec folder2)))
-          (and ;(elmo-imap4-identical-name-space-p ;; No use.
-               ; (nth 1 spec1) (nth 1 spec2))
+          (and 
+;;; No use.        
+;;;        (elmo-imap4-identical-name-space-p 
+;;;         (nth 1 spec1) (nth 1 spec2))
            (string= (elmo-imap4-spec-hostname spec1)
-                    (elmo-imap4-spec-hostname spec2))    ; hostname
+                    (elmo-imap4-spec-hostname spec2)) ; hostname
            (string= (elmo-imap4-spec-username spec1)
                     (elmo-imap4-spec-username spec2))))) ; username
        (t
@@ -1327,7 +1332,8 @@ Otherwise treat \\ in NEWTEXT string as special:
     (list 'makunbound (list 'intern string hashtable))))
 
 (defmacro elmo-unintern (string)
-  ;; Emacs 19.28 or earlier does not have unintern.
+  "`unintern' symbol named STRING,  When can use `unintern'.
+Emacs 19.28 or earlier does not have `unintern'."
   (static-if (fboundp 'unintern)
       (list 'unintern string)))
 
@@ -1438,8 +1444,7 @@ Otherwise treat \\ in NEWTEXT string as special:
 (defsubst elmo-copy-file (src dst)
   (condition-case err
       (elmo-add-name-to-file src dst t)
-    (error (copy-file src dst t)
-          (error "Copy file failed"))))
+    (error (copy-file src dst t))))
 
 (defsubst elmo-buffer-exists-p (buffer)
   (if (bufferp buffer)
@@ -1549,6 +1554,15 @@ the value of `foo'."
        (set-text-properties 0 (length obj) nil obj)
        obj)))
 
+(defun elmo-flatten (list-of-list)
+  "Flatten LIST-OF-LIST."
+  (unless (null list-of-list)
+    (append (if (and (car list-of-list)
+                    (listp (car list-of-list)))
+               (car list-of-list)
+             (list (car list-of-list)))
+           (elmo-flatten (cdr list-of-list)))))
+
 (defun elmo-y-or-n-p (prompt &optional auto default)
   "Same as `y-or-n-p'.
 But if optional argument AUTO is non-nil, DEFAULT is returned."