* wl.el (wl-other-frame): Removed garbages.
[elisp/wanderlust.git] / wl / wl.el
index 1dbe681..cbff2e6 100644 (file)
--- a/wl/wl.el
+++ b/wl/wl.el
@@ -666,9 +666,11 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
                        (list wl-folder-buffer-name
                              wl-plugged-buf-name)
                        "\\|")))
-    (if (and wl-folder-use-frame
-            (> (length (visible-frame-list)) 1))
-       (delete-frame))
+    (when wl-delete-startup-frame-function
+      (funcall wl-delete-startup-frame-function))
+;;    (if (and wl-folder-use-frame
+;;          (> (length (visible-frame-list)) 1))
+;;     (delete-frame))
     (setq wl-init nil)
     (remove-hook 'kill-emacs-hook 'wl-save-status)
     t)
@@ -703,7 +705,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
 (defun wl-check-environment (no-check-folder)
   (unless wl-from (error "Please set `wl-from'"))
   ;; Message-ID
-  (let ((from domain))
+  (let (from domain)
     (if wl-message-id-use-wl-from
        (if (and (setq from (wl-address-header-extract-address wl-from))
                 (string-match "^\\(.*\\)@\\(.*\\)$" from))
@@ -761,7 +763,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
            (make-directory wl-temporary-file-directory)
          (error "Temp directory is not created"))))))
 
-(defconst wl-check-type-variables
+(defconst wl-check-variables-alist
   '((numberp . elmo-pop3-default-port)
     (symbolp . elmo-pop3-default-authenticate-type)
     (numberp . elmo-imap4-default-port)
@@ -770,8 +772,9 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
     (numberp . wl-pop-before-smtp-port)
     (symbolp . wl-pop-before-smtp-authenticate-type)))
 
-(defun wl-check-type ()
-  (let ((type-variables wl-check-type-variables))
+(defun wl-check-variables ()
+  (let ((type-variables wl-check-variables-alist)
+       type)
     (while (setq type (car type-variables))
       (if (and (eval (cdr type))
               (not (funcall (car type)
@@ -782,6 +785,16 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
                 (eval (cdr type))))
       (setq type-variables (cdr type-variables)))))
 
+(defun wl-check-variables-2 ()
+  (if (< wl-message-buffer-cache-size 1)
+      (error "`wl-message-buffer-cache-size' must be larger than 0."))
+  (when wl-message-buffer-prefetch-depth
+    (if (not (< wl-message-buffer-prefetch-depth
+               wl-message-buffer-cache-size))
+       (error (concat
+               "`wl-message-buffer-prefetch-depth' must be smaller than "
+               "`wl-message-buffer-cache-size' - 1.")))))
+
 ;;;###autoload
 (defun wl (&optional arg)
   "Start Wanderlust -- Yet Another Message Interface On Emacsen.
@@ -799,13 +812,16 @@ If ARG (prefix argument) is specified, folder checkings are skipped."
     (condition-case obj
        (progn
          (if check
-             (progn
-               (message "Checking environment...")
-               (wl-check-environment arg)
-               (message "Checking environment...done")
-               (message "Checking type of variables...")
-               (wl-check-type)
-               (message "Checking type of variables...done")))
+             (condition-case nil
+                 (progn
+                   (message "Checking environment...")
+                   (wl-check-environment arg)
+                   (message "Checking environment...done"))
+               ((error quit))))
+         (message "Checking type of variables...")
+         (wl-check-variables)
+         (wl-check-variables-2)
+         (message "Checking type of variables...done")
          (wl-plugged-init (wl-folder arg))
          (unless arg
            (run-hooks 'wl-auto-check-folder-pre-hook)
@@ -822,6 +838,39 @@ If ARG (prefix argument) is specified, folder checkings are skipped."
        (kill-buffer demo-buf)))
   (run-hooks 'wl-hook))
 
+(defvar wl-delete-startup-frame-function nil)
+
+;;;###autoload
+(defun wl-other-frame (&optional arg)
+  "Pop up a frame to read messages via Wanderlust."
+  (interactive)
+  (let ((focusing-functions (append '(raise-frame select-frame)
+                                   (if (fboundp 'x-focus-frame)
+                                       '(x-focus-frame)
+                                     '(focus-frame))))
+       (folder (get-buffer wl-folder-buffer-name))
+       window frame wl-folder-use-frame)
+    (if (and folder
+            (setq window (get-buffer-window folder t))
+            (window-live-p window)
+            (setq frame (window-frame window)))
+       (progn
+         (while focusing-functions
+           (funcall (car focusing-functions) frame)
+           (setq focusing-functions (cdr focusing-functions)))
+         (wl arg))
+      (setq frame (make-frame))
+      (while focusing-functions
+       (funcall (car focusing-functions) frame)
+       (setq focusing-functions (cdr focusing-functions)))
+      (setq wl-delete-startup-frame-function
+           `(lambda ()
+              (setq wl-delete-startup-frame-function nil)
+              (let ((frame ,frame))
+                (if (eq (selected-frame) frame)
+                    (delete-frame frame)))))
+      (wl arg))))
+
 ;; Define some autoload functions WL might use.
 (eval-and-compile
   ;; This little mapcar goes through the list below and marks the