X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=wl%2Fwl.el;h=e076fa3c223ad84e8e9e39993558311f2ee94c4c;hb=6dc2bb1ee1d35e7f6cf19df145c35561cc5265bd;hp=d1e20d9bff5d11b37531b67056b8e913f54aae8b;hpb=a00717819fec22a7113b06e3f5daddabe202d615;p=elisp%2Fwanderlust.git diff --git a/wl/wl.el b/wl/wl.el index d1e20d9..e076fa3 100644 --- a/wl/wl.el +++ b/wl/wl.el @@ -1,4 +1,4 @@ -;;; wl.el -- Wanderlust bootstrap. +;;; wl.el --- Wanderlust bootstrap. ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi ;; Copyright (C) 1998,1999,2000 Masahiro MURATA @@ -36,7 +36,7 @@ ;; from x-face.el (unless (and (fboundp 'defgroup) - (fboundp 'defcustom)) + (fboundp 'defcustom)) (require 'backquote) (defmacro defgroup (&rest args)) (defmacro defcustom (symbol value &optional doc &rest args) @@ -50,16 +50,16 @@ (require 'wl-xmas)) (wl-on-emacs21 (require 'wl-e21)) - (wl-on-nemacs - (require 'wl-nemacs)) (t (require 'wl-mule))) (provide 'wl) ; circular dependency (require 'wl-folder) (require 'wl-summary) +(require 'wl-action) (require 'wl-thread) (require 'wl-address) +(require 'wl-news) (wl-draft-mode-setup) (require 'wl-draft) @@ -72,11 +72,8 @@ (require 'cl) (require 'smtp) (require 'wl-score) - (unless wl-on-nemacs - (require 'wl-fldmgr)) - (if wl-use-semi - (require 'wl-mime) - (require 'tm-wl))) + (require 'wl-fldmgr) + (require 'wl-mime)) (defun wl-plugged-init (&optional make-alist) (setq elmo-plugged wl-plugged) @@ -99,7 +96,7 @@ (setq wl-plugged t)) ((eq arg 'off) (setq wl-plugged nil)) - (t (setq wl-plugged (null wl-plugged)))) + (t (setq wl-plugged (not wl-plugged)))) (elmo-set-plugged wl-plugged)) (setq elmo-plugged wl-plugged wl-modeline-plug-status wl-plugged) @@ -107,8 +104,8 @@ (let ((summaries (wl-collect-summary))) (while summaries (set-buffer (pop summaries)) - (elmo-folder-commit wl-summary-buffer-elmo-folder) - (wl-summary-set-message-modified)))) + (wl-summary-save-view) + (elmo-folder-commit wl-summary-buffer-elmo-folder)))) (setq wl-biff-check-folders-running nil) (if wl-plugged (progn @@ -169,10 +166,8 @@ (if wl-on-xemacs (defun wl-plugged-setup-mouse () (define-key wl-plugged-mode-map 'button2 'wl-plugged-click)) - (if wl-on-nemacs - (defun wl-plugged-setup-mouse ()) - (defun wl-plugged-setup-mouse () - (define-key wl-plugged-mode-map [mouse-2] 'wl-plugged-click))))) + (defun wl-plugged-setup-mouse () + (define-key wl-plugged-mode-map [mouse-2] 'wl-plugged-click)))) (unless wl-plugged-mode-map (setq wl-plugged-mode-map (make-sparse-keymap)) @@ -281,10 +276,10 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (setq last (elmo-dop-queue-fname (car dop-queue)))) ;; first (while dop-queue (when (car dop-queue) - (setq ope (cons (elmo-dop-queue-method (car dop-queue)) - (length + (setq ope (cons (elmo-dop-queue-method-name (car dop-queue)) + (length (if (listp - (car + (car (elmo-dop-queue-arguments (car dop-queue)))) (car (elmo-dop-queue-arguments (car dop-queue)))))))) @@ -315,12 +310,23 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (car folder-ope) (wl-folder-get-petname (car folder-ope))) "(" - (mapconcat - '(lambda (ope) - (if (> (cdr ope) 0) - (format "%s:%d" (car ope) (cdr ope)) - (format "%s" (car ope)))) - (cdr folder-ope) ",") + (let ((opes (cdr folder-ope)) + pair shrinked) + (while opes + (if (setq pair (assoc (car (car opes)) shrinked)) + (setcdr pair (+ (cdr pair) + (max (cdr (car opes)) 1))) + (setq shrinked (cons + (cons (car (car opes)) + (max (cdr (car opes)) 1)) + shrinked))) + (setq opes (cdr opes))) + (mapconcat + '(lambda (ope) + (if (> (cdr ope) 0) + (format "%s:%d" (car ope) (cdr ope)) + (format "%s" (car ope)))) + (nreverse shrinked) ",")) ")")) operations (concat "\n" (wl-set-string-width column ""))))) @@ -487,7 +493,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (save-excursion (beginning-of-line) (cond - ;; swtich variable + ;; switch variable ((bobp) (let (variable switch name) (goto-char cur-point) @@ -506,7 +512,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (delete-region (match-beginning 2) (match-end 2)) (insert (wl-plugged-string switch)) (set-buffer-modified-p nil))))) - ;; swtich plug + ;; switch plug ((looking-at "^\\( *\\)\\[\\([^]]+\\)\\]\\([^ \n]*\\)") (let* ((indent (length (elmo-match-buffer 1))) (switch (elmo-match-buffer 2)) @@ -634,7 +640,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (with-current-buffer (car summaries) (unless keep-summary (wl-summary-cleanup-temp-marks)) - (wl-summary-save-view keep-summary) + (wl-summary-save-view) (elmo-folder-commit wl-summary-buffer-elmo-folder) (unless keep-summary (kill-buffer (car summaries)))) @@ -648,8 +654,9 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (defun wl-exit () (interactive) (when (or (not wl-interactive-exit) - (y-or-n-p "Quit Wanderlust? ")) + (y-or-n-p "Do you really want to quit Wanderlust? ")) (elmo-quit) + (when wl-use-acap (funcall (symbol-function 'wl-acap-exit))) (wl-biff-stop) (run-hooks 'wl-exit-hook) (wl-save-status) @@ -661,32 +668,26 @@ 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) - (unless wl-on-nemacs - (remove-hook 'kill-emacs-hook 'wl-save-status)) + (remove-hook 'kill-emacs-hook 'wl-save-status) t) (message "") ; empty minibuffer. ) (defun wl-init () (when (not wl-init) - (unless (featurep 'mime-setup) - (require 'mime-setup)) + (require 'mime-setup) (setq elmo-plugged wl-plugged) - (unless wl-on-nemacs - (add-hook 'kill-emacs-hook 'wl-save-status)) + (add-hook 'kill-emacs-hook 'wl-save-status) (wl-address-init) (wl-draft-setup) (wl-refile-alist-setup) - (if wl-use-semi - (progn - (require 'wl-mime) - (setq elmo-use-semi t)) - (require 'tm-wl) - (setq elmo-use-semi nil)) + (require 'wl-mime) ;; defined above. (wl-mime-setup) (fset 'wl-summary-from-func-internal @@ -695,8 +696,10 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (symbol-value 'wl-summary-subject-function)) (fset 'wl-summary-subject-filter-func-internal (symbol-value 'wl-summary-subject-filter-function)) + (wl-summary-define-mark-action) (setq elmo-no-from wl-summary-no-from-message) (setq elmo-no-subject wl-summary-no-subject-message) + (wl-news-check) (setq wl-init t) ;; This hook may contain the functions `wl-plugged-init-icons' and ;; `wl-biff-init-icons' for reasons of system internal to accord @@ -704,30 +707,27 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (run-hooks 'wl-init-hook))) (defun wl-check-environment (no-check-folder) - (unless wl-from - (error "Please set `wl-from'")) + (unless wl-from (error "Please set `wl-from' to your mail address")) ;; Message-ID - (unless (string-match "[^.]\\.[^.]" (or wl-message-id-domain - (if wl-local-domain - (concat (system-name) - "." wl-local-domain) - (system-name)))) - (error "Please set `wl-local-domain' to get valid FQDN")) - (if (string-match "@" (or wl-message-id-domain - (if wl-local-domain - (concat (system-name) - "." wl-local-domain) - (system-name)))) - (error "Please remove `@' from `wl-message-id-domain'")) - (if (string= wl-local-domain "localdomain") - (error "Please set `wl-local-domain'")) - (if (string= wl-message-id-domain "localhost.localdomain") - (error "Please set `wl-message-id-domain'")) + (when wl-insert-message-id + (let ((message-id (funcall wl-message-id-function)) + domain) + (unless (string-match "^<\\([^@]*\\)@\\([^@]*\\)>$" message-id) + (cond + ((string-match "@" wl-message-id-domain) + (error "Please remove `@' from `wl-message-id-domain'")) + (t + (error + "Check around `wl-message-id-function' to get valid Message-ID string")))) + (setq domain (match-string 2 message-id)) + (if (or (not (string-match "[^.]\\.[^.]" domain)) + (string= domain "localhost.localdomain")) + (elmo-warning + "Please set `wl-message-id-domain' to get valid Message-ID string.")))) ;; folders (when (not no-check-folder) (let ((draft-folder (wl-folder-get-elmo-folder wl-draft-folder)) (queue-folder (wl-folder-get-elmo-folder wl-queue-folder)) - (trash-folder (wl-folder-get-elmo-folder wl-trash-folder)) (lost+found-folder (wl-folder-get-elmo-folder elmo-lost+found-folder))) (if (not (elmo-folder-message-file-p draft-folder)) @@ -746,51 +746,91 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'." (elmo-folder-create queue-folder) (error "Queue Folder is not created"))) (when (not (eq no-check-folder 'wl-draft)) - (unless (elmo-folder-exists-p trash-folder) - (if (y-or-n-p - (format "Trash Folder %s does not exist, create it? " - wl-trash-folder)) - (elmo-folder-create trash-folder) - (error "Trash Folder is not created"))) (unless (elmo-folder-exists-p lost+found-folder) (elmo-folder-create lost+found-folder))) ;; tmp dir - (unless (file-exists-p wl-tmp-dir) + (unless (file-exists-p wl-temporary-file-directory) (if (y-or-n-p (format "Temp directory (to save multipart) %s does not exist, create it now? " - wl-tmp-dir)) - (make-directory wl-tmp-dir) + wl-temporary-file-directory)) + (make-directory wl-temporary-file-directory) (error "Temp directory is not created")))))) +(defconst wl-check-variables-alist + '((numberp . elmo-pop3-default-port) + (symbolp . elmo-pop3-default-authenticate-type) + (numberp . elmo-imap4-default-port) + (symbolp . elmo-imap4-default-authenticate-type) + (numberp . elmo-nntp-default-port) + (numberp . wl-pop-before-smtp-port) + (symbolp . wl-pop-before-smtp-authenticate-type))) + +(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) + (eval (cdr type))))) + (error "%s must be %s: %S" + (cdr type) + (substring (format "%s" (car type)) 0 -1) + (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.")))) + (let (case-fold-search) + (unless (string-match "%T" wl-summary-line-format) + (error "`wl-summary-line-format' must contain %%T and %%P")) + (unless (string-match "%P" wl-summary-line-format) + (error "`wl-summary-line-format' must contain %%T and %%P")) + (dolist (pair wl-folder-summary-line-format-alist) + (unless (string-match "%T" (cdr pair)) + (error "Format `%s' must contain %%T and %%P" (cdr pair))) + (unless (string-match "%P" (cdr pair)) + (error "Format `%s' must contain %%T and %%P" (cdr pair)))))) + ;;;###autoload (defun wl (&optional arg) "Start Wanderlust -- Yet Another Message Interface On Emacsen. If ARG (prefix argument) is specified, folder checkings are skipped." (interactive "P") (unless wl-init - (wl-load-profile)) - (elmo-init) - (let (demo-buf) + (wl-load-profile) + (wl-folder-init) + (elmo-init)) + (let (demo-buf check) (unless wl-init - (if wl-demo (setq demo-buf (wl-demo)))) + (if wl-demo (setq demo-buf (wl-demo))) + (setq check t)) (wl-init) - (unless wl-init - (condition-case nil - (progn - (message "Checking environment...") - (wl-check-environment arg) - (message "Checking environment...done")) - (error) - (quit))) (condition-case obj (progn - (wl-plugged-init (wl-folder arg)) + (if check + (progn + (message "Checking environment...") + (wl-check-environment arg) + (message "Checking environment...done") + (message "Checking type of variables...") + (wl-check-variables) + (wl-check-variables-2) + (message "Checking type of variables...done"))) + (let ((inhibit-quit t)) + (wl-plugged-init (wl-folder arg))) (unless arg (run-hooks 'wl-auto-check-folder-pre-hook) (wl-folder-auto-check) (run-hooks 'wl-auto-check-folder-hook)) (unless arg (wl-biff-start))) - (error + (error (if (buffer-live-p demo-buf) (kill-buffer demo-buf)) (signal (car obj)(cdr obj))) @@ -799,6 +839,41 @@ 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) + (if wl-folder-use-frame + (wl arg) + (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 @@ -828,6 +903,8 @@ If ARG (prefix argument) is specified, folder checkings are skipped." wl-fldmgr-save-folders wl-fldmgr-set-petname wl-fldmgr-sort wl-fldmgr-subscribe wl-fldmgr-subscribe-region wl-fldmgr-unsubscribe wl-fldmgr-unsubscribe-region wl-fldmgr-yank ) + ("wl-acap" wl-acap-init) + ("wl-acap" :interactive t wl-acap-store) ("wl-fldmgr" (wl-fldmgr-mode-map keymap) wl-fldmgr-add-entity-hashtb)