1 ;;; wl.el --- Wanderlust bootstrap.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 1998,1999,2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
8 ;; Keywords: mail, net news
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
35 (require 'wl-version) ; reduce recursive-load-depth
38 (unless (and (fboundp 'defgroup)
41 (defmacro defgroup (&rest args))
42 (defmacro defcustom (symbol value &optional doc &rest args)
43 (let ((doc (concat "*" (or doc ""))))
44 (` (defvar (, symbol) (, value) (, doc))))))
56 (provide 'wl) ; circular dependency
68 (require 'wl-highlight)
77 (defun wl-plugged-init (&optional make-alist)
78 (setq elmo-plugged wl-plugged)
79 (if wl-reset-plugged-alist
80 (elmo-set-plugged elmo-plugged))
82 (wl-make-plugged-alist))
84 (setq elmo-plugged (setq wl-plugged (elmo-plugged-p))
85 wl-modeline-plug-status wl-plugged)
87 (wl-toggle-plugged t 'flush)))
89 (defun wl-toggle-plugged (&optional arg queue-flush-only)
91 (elmo-quit) ; Disconnect current connection.
92 (unless queue-flush-only
97 (setq wl-plugged nil))
98 (t (setq wl-plugged (not wl-plugged))))
99 (elmo-set-plugged wl-plugged))
100 (setq elmo-plugged wl-plugged
101 wl-modeline-plug-status wl-plugged)
103 (let ((summaries (wl-collect-summary)))
105 (set-buffer (pop summaries))
106 (wl-summary-save-view)
107 (elmo-folder-commit wl-summary-buffer-elmo-folder))))
108 (setq wl-biff-check-folders-running nil)
112 (elmo-dop-queue-flush)
113 (unless queue-flush-only (wl-biff-start))
114 (if (and wl-draft-enable-queuing
116 (wl-draft-queue-flush))
117 ;; (when (and (eq major-mode 'wl-summary-mode)
118 ;; (elmo-folder-plugged-p wl-summary-buffer-elmo-folder))
119 ;; (let* ((msgdb-dir (elmo-folder-msgdb-path
120 ;; wl-summary-buffer-elmo-folder))
121 ;; (seen-list (elmo-msgdb-seen-load msgdb-dir)))
123 ;; (wl-summary-flush-pending-append-operations seen-list))
124 ;; (elmo-msgdb-seen-save msgdb-dir seen-list)))
125 (run-hooks 'wl-plugged-hook))
127 (run-hooks 'wl-unplugged-hook))
128 (force-mode-line-update t))
132 (defvar wl-plugged-port-label-alist
133 (list (cons 119 "nntp")
136 ;;(cons elmo-pop-before-smtp-port "pop3")
138 (defconst wl-plugged-switch-variables
139 '(("Queuing" . wl-draft-enable-queuing)
140 ("AutoFlushQueue" . wl-auto-flush-queue)
141 ("DisconnectedOperation" . elmo-enable-disconnected-operation)))
143 (defvar wl-plugged-buf-name "Plugged")
144 (defvar wl-plugged-mode-map nil)
145 (defvar wl-plugged-alist nil)
146 (defvar wl-plugged-switch nil)
147 (defvar wl-plugged-winconf nil)
148 (defvar wl-plugged-sending-queue-alist nil)
149 (defvar wl-plugged-dop-queue-alist nil)
150 (defvar wl-plugged-alist-modified nil)
152 (defvar wl-plugged-mode-menu-spec
154 ["Toggle plugged" wl-plugged-toggle t]
155 ["Toggle All plugged" wl-plugged-toggle-all t]
156 ["Prev Port" wl-plugged-move-to-previous t]
157 ["Next Port" wl-plugged-move-to-next t]
158 ["Prev Server" wl-plugged-move-to-previous-server t]
159 ["Next Server" wl-plugged-move-to-next-server t]
160 ["Flush queue" wl-plugged-flush-queue t]
162 ["Exit" wl-plugged-exit t]))
166 (defun wl-plugged-setup-mouse ()
167 (define-key wl-plugged-mode-map 'button2 'wl-plugged-click))
168 (defun wl-plugged-setup-mouse ()
169 (define-key wl-plugged-mode-map [mouse-2] 'wl-plugged-click))))
171 (unless wl-plugged-mode-map
172 (setq wl-plugged-mode-map (make-sparse-keymap))
173 (define-key wl-plugged-mode-map " " 'wl-plugged-toggle)
174 (define-key wl-plugged-mode-map "\C-m" 'wl-plugged-toggle)
175 (define-key wl-plugged-mode-map "\M-t" 'wl-plugged-toggle-all)
176 (define-key wl-plugged-mode-map "q" 'wl-plugged-exit)
177 (define-key wl-plugged-mode-map "\C-t" 'wl-plugged-exit)
178 (define-key wl-plugged-mode-map "F" 'wl-plugged-flush-queue)
179 (define-key wl-plugged-mode-map "P" 'wl-plugged-move-to-previous-server)
180 (define-key wl-plugged-mode-map "N" 'wl-plugged-move-to-next-server)
181 (define-key wl-plugged-mode-map "p" 'wl-plugged-move-to-previous)
182 (define-key wl-plugged-mode-map "n" 'wl-plugged-move-to-next)
183 (define-key wl-plugged-mode-map "\e\t" 'wl-plugged-move-to-previous)
184 (define-key wl-plugged-mode-map "\t" 'wl-plugged-move-to-next)
185 (wl-plugged-setup-mouse)
189 "Menu used in Plugged mode."
190 wl-plugged-mode-menu-spec))
192 (defun wl-plugged-mode ()
193 "Mode for setting Wanderlust plugged.
194 See info under Wanderlust for full documentation.
197 \\{wl-plugged-mode-map}
199 Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
201 (kill-all-local-variables)
202 (use-local-map wl-plugged-mode-map)
203 (setq major-mode 'wl-plugged-mode)
204 (setq mode-name "Plugged")
205 (easy-menu-add wl-plugged-mode-menu)
206 (wl-mode-line-buffer-identification)
207 (setq wl-plugged-switch wl-plugged)
208 (setq wl-plugged-alist-modified nil)
209 (setq buffer-read-only t)
210 (run-hooks 'wl-plugged-mode-hook))
212 (defmacro wl-plugged-string (plugged &optional time)
213 (` (if (, time) wl-plugged-auto-off
214 (if (, plugged) wl-plugged-plug-on wl-plugged-plug-off))))
216 (defmacro wl-plugged-server-indent ()
217 (` (make-string wl-plugged-server-indent ? )))
219 (defun wl-plugged-set-variables ()
220 (setq wl-plugged-sending-queue-alist
221 (wl-plugged-sending-queue-info))
222 (setq wl-plugged-dop-queue-alist
223 (wl-plugged-dop-queue-info))
224 (setq wl-plugged-alist
225 (sort (copy-sequence elmo-plugged-alist)
227 (string< (caar a) (caar b))))))
229 (defun wl-plugged-sending-queue-info ()
230 ;; sending queue status
231 (let (alist msgs sent-via server port)
232 (setq msgs (elmo-folder-list-messages
233 (wl-folder-get-elmo-folder wl-queue-folder)))
235 (setq sent-via (wl-draft-queue-info-operation (car msgs) 'get-sent-via))
237 (when (eq (nth 1 (car sent-via)) 'unplugged)
238 (setq server (car (nth 2 (car sent-via)))
239 port (cdr (nth 2 (car sent-via))))
240 (elmo-plugged-p server port) ;; add elmo-plugged-alist if nothing.
242 (wl-append-assoc-list
246 (setq sent-via (cdr sent-via)))
247 (setq msgs (cdr msgs)))
250 (defun wl-plugged-sending-queue-status (qinfo)
251 ;; sending queue status
252 (let ((len (length (cdr qinfo))))
253 (concat (wl-plugged-set-folder-icon
255 (wl-folder-get-petname wl-queue-folder))
257 (format ": %d msgs (" len)
258 (format ": %d msg (" len))
259 (mapconcat (function int-to-string) (cdr qinfo) ",")
262 (defun wl-plugged-dop-queue-info ()
265 (elmo-dop-queue (copy-sequence elmo-dop-queue))
266 dop-queue last alist server-info
268 ;(elmo-dop-queue-load)
269 (elmo-dop-queue-merge)
270 (setq dop-queue (sort elmo-dop-queue '(lambda (a b)
271 (string< (elmo-dop-queue-fname a)
272 (elmo-dop-queue-fname b)))))
273 (wl-append dop-queue (list nil)) ;; terminate(dummy)
274 (when (car dop-queue)
275 (setq last (elmo-dop-queue-fname (car dop-queue)))) ;; first
277 (when (car dop-queue)
278 (setq ope (cons (elmo-dop-queue-method-name (car dop-queue))
282 (elmo-dop-queue-arguments (car dop-queue))))
283 (car (elmo-dop-queue-arguments
284 (car dop-queue))))))))
285 (if (and (car dop-queue)
286 (string= last (elmo-dop-queue-fname (car dop-queue))))
287 (wl-append operation (list ope))
288 ;;(setq count (1+ count))
289 (when (and last (setq server-info (elmo-net-port-info
290 (wl-folder-get-elmo-folder last))))
292 (wl-append-assoc-list
294 (cons last operation)
296 (when (car dop-queue)
297 (setq last (elmo-dop-queue-fname (car dop-queue))
298 operation (list ope))))
299 (setq dop-queue (cdr dop-queue)))
302 (defun wl-plugged-dop-queue-status (qinfo &optional column)
304 (let ((operations (cdr qinfo))
305 (column (or column wl-plugged-queue-status-column)))
307 '(lambda (folder-ope)
308 (concat (wl-plugged-set-folder-icon
310 (wl-folder-get-petname (car folder-ope)))
312 (let ((opes (cdr folder-ope))
315 (if (setq pair (assoc (car (car opes)) shrinked))
316 (setcdr pair (+ (cdr pair)
317 (max (cdr (car opes)) 1)))
319 (cons (car (car opes))
320 (max (cdr (car opes)) 1))
322 (setq opes (cdr opes)))
326 (format "%s:%d" (car ope) (cdr ope))
327 (format "%s" (car ope))))
328 (nreverse shrinked) ","))
331 (concat "\n" (wl-set-string-width column "")))))
333 (defun wl-plugged-drawing (plugged-alist)
334 (let ((buffer-read-only nil)
335 (alist plugged-alist)
336 (vars wl-plugged-switch-variables)
337 last server port stream-type label plugged time
338 line len qinfo column)
341 (insert (format "%s:[%s]%s"
343 (wl-plugged-string (symbol-value (cdar vars)))
344 (if (cdr vars) " " "")))
345 (setq vars (cdr vars)))
347 (let ((elmo-plugged wl-plugged-switch))
348 (setq line (format "[%s](wl-plugged)"
349 (wl-plugged-string (elmo-plugged-p))))
350 ;; sending queue status
351 (when (setq qinfo (assoc (cons nil nil) wl-plugged-sending-queue-alist))
353 (wl-set-string-width wl-plugged-queue-status-column line)
354 (wl-plugged-sending-queue-status qinfo))))
357 (setq server (nth 0 (caar alist))
358 port (nth 1 (caar alist))
359 stream-type (nth 2 (caar alist))
360 label (nth 1 (car alist))
361 plugged (nth 2 (car alist))
362 time (nth 3 (car alist)))
363 (unless (string= last server)
365 (insert (format "%s[%s]%s\n"
366 (wl-plugged-server-indent)
368 (elmo-plugged-p server nil plugged-alist))
374 (make-string wl-plugged-port-indent ? )
375 (wl-plugged-string plugged time)
382 (cdr (assq port wl-plugged-port-label-alist))
385 (setq column (max (if line (1+ (string-width line)) 0)
386 wl-plugged-queue-status-column))
388 ;; sending queue status
389 ((setq qinfo (assoc (cons server port) wl-plugged-sending-queue-alist))
392 (wl-set-string-width column line)
393 (wl-plugged-sending-queue-status qinfo))))
395 ((setq qinfo (assoc (list server port stream-type)
396 wl-plugged-dop-queue-alist))
399 (wl-set-string-width column line)
400 (wl-plugged-dop-queue-status qinfo column)))))
402 (setq alist (cdr alist)))
403 (delete-region (1- (point-max)) (point-max)) ;; delete line at the end.
404 (goto-char (point-min))
406 (wl-highlight-plugged-current-line)
408 (set-buffer-modified-p nil)
409 (count-lines (point-min) (point-max)))
411 (defun wl-plugged-redrawing-switch (indent switch &optional time)
413 (when (re-search-forward
414 (format "^%s\\[\\([^]]+\\)\\]" (make-string indent ? )))
415 (goto-char (match-beginning 1))
416 (delete-region (match-beginning 1) (match-end 1))
417 (insert (wl-plugged-string switch time))
418 (wl-highlight-plugged-current-line)
421 (defun wl-plugged-redrawing (plugged-alist)
422 (let ((buffer-read-only nil)
423 (alist plugged-alist)
424 last server port plugged time)
425 (goto-char (point-min))
426 (wl-plugged-redrawing-switch 0 (elmo-plugged-p))
428 (setq server (caaar alist)
430 plugged (nth 2 (car alist))
431 time (nth 3 (car alist)))
432 (unless (string= last server)
434 (wl-plugged-redrawing-switch
435 wl-plugged-server-indent
436 (elmo-plugged-p server nil plugged-alist))
439 (wl-plugged-redrawing-switch
440 wl-plugged-port-indent plugged time)
441 (setq alist (cdr alist))))
443 (set-buffer-modified-p nil))
445 (defun wl-plugged-change ()
447 (if (not elmo-plugged-alist)
448 (message "No plugged info")
449 (setq wl-plugged-winconf (current-window-configuration))
450 (let* ((cur-win (selected-window))
451 (max-lines (if (eq major-mode 'wl-summary-mode)
456 (set-buffer (get-buffer-create wl-plugged-buf-name))
458 (buffer-disable-undo (current-buffer))
459 (delete-windows-on (current-buffer))
460 (wl-plugged-set-variables)
461 (setq lines (wl-plugged-drawing wl-plugged-alist)))
462 (select-window cur-win)
463 (setq window-lines (min max-lines (max lines window-min-height)))
464 (when (> (- (window-height) window-lines) window-min-height)
465 (split-window cur-win (- (window-height) window-lines)))
466 (switch-to-buffer wl-plugged-buf-name)
469 (enlarge-window (- window-lines (window-height)))
470 (when (fboundp 'pos-visible-in-window-p)
471 (goto-char (point-min))
472 (while (and (< (window-height) max-lines)
473 (not (pos-visible-in-window-p (1- (point-max)))))
474 (enlarge-window 2))))
476 (goto-char (point-min))
478 (wl-plugged-move-to-next)))) ;; goto first entry
480 (defsubst wl-plugged-get-server ()
483 (wl-plugged-move-to-previous-server)
485 (when (looking-at (format "^%s\\[[^]]+\\]\\(.*\\)"
486 (wl-plugged-server-indent)))
487 (elmo-match-buffer 1))))
489 (defun wl-plugged-toggle ()
491 (let ((cur-point (point)))
497 (let (variable switch name)
498 (goto-char cur-point)
499 (when (and (not (bobp))
500 (not (eq (char-before) ? )))
501 (if (re-search-backward " [^ ]+" nil t)
503 (re-search-backward "^[^ ]+" nil t)))
504 (when (looking-at "\\([^ :[]+\\):?\\[\\([^]]+\\)\\]")
505 (setq name (elmo-match-buffer 1))
506 (setq switch (not (string= (elmo-match-buffer 2) wl-plugged-plug-on)))
507 (when (setq variable (cdr (assoc name wl-plugged-switch-variables)))
508 (set variable switch))
509 (goto-char (match-beginning 2))
510 (let ((buffer-read-only nil))
511 (delete-region (match-beginning 2) (match-end 2))
512 (insert (wl-plugged-string switch))
513 (set-buffer-modified-p nil)))))
515 ((looking-at "^\\( *\\)\\[\\([^]]+\\)\\]\\([^ \n]*\\)")
516 (let* ((indent (length (elmo-match-buffer 1)))
517 (switch (elmo-match-buffer 2))
518 (name (elmo-match-buffer 3))
519 (plugged (not (string= switch wl-plugged-plug-on)))
520 (alist wl-plugged-alist)
521 server port stream-type name-1)
523 ((eq indent wl-plugged-port-indent) ;; toggle port plug
525 ((string-match "\\([^([]*\\)(\\([^)[]+\\))" name)
526 (setq port (string-to-int (elmo-match-string 2 name)))
527 (if (string-match "!" (setq name-1 (elmo-match-string 1 name)))
529 (intern (substring name-1 (match-end 0))))))
532 (setq server (wl-plugged-get-server))
533 (elmo-set-plugged plugged server port stream-type nil alist))
534 ((eq indent wl-plugged-server-indent) ;; toggle server plug
535 (elmo-set-plugged plugged name nil nil nil alist))
536 ((eq indent 0) ;; toggle all plug
537 (elmo-set-plugged plugged nil nil nil nil alist)))
539 (wl-plugged-redrawing wl-plugged-alist)
540 ;; show plugged status in modeline
541 (let ((elmo-plugged wl-plugged-switch))
542 (setq wl-plugged-switch (elmo-plugged-p)
543 wl-modeline-plug-status wl-plugged-switch)
544 (force-mode-line-update t))))))
545 (setq wl-plugged-alist-modified t)
546 (goto-char cur-point)))
548 (defun wl-plugged-click (e)
553 (defun wl-plugged-toggle-all ()
555 (let ((cur-point (point)))
556 (setq wl-plugged-switch (not wl-plugged-switch))
557 (elmo-set-plugged wl-plugged-switch nil nil nil nil wl-plugged-alist)
558 (wl-plugged-redrawing wl-plugged-alist)
559 (goto-char cur-point)
560 (setq wl-plugged-alist-modified t)
561 ;; show plugged status in modeline
562 (setq wl-modeline-plug-status wl-plugged-switch)
563 (force-mode-line-update t)))
565 (defun wl-plugged-exit ()
567 (setq ;;elmo-plugged-alist wl-plugged-alist
568 wl-plugged wl-plugged-switch
570 wl-plugged-sending-queue-alist nil
571 wl-plugged-dop-queue-alist nil)
572 (run-hooks 'wl-plugged-exit-hook)
573 (when wl-plugged-alist-modified
574 (wl-toggle-plugged (if wl-plugged 'on 'off) t))
575 (kill-buffer (current-buffer))
576 (if wl-plugged-winconf
577 (set-window-configuration wl-plugged-winconf)))
579 (defun wl-plugged-flush-queue ()
581 (let ((cur-point (point))
582 (dop-status (elmo-dop-queue-flush))
583 (send-status (wl-draft-queue-flush)))
584 (unless (or dop-status send-status)
585 (message "No processing queue."))
586 (wl-plugged-set-variables)
587 (wl-plugged-drawing wl-plugged-alist)
588 (goto-char cur-point)))
590 (defun wl-plugged-move-to-next ()
592 (when (re-search-forward "\\[\\([^]]+\\)\\]" nil t)
593 (let ((pos (match-beginning 1)))
594 (if (invisible-p pos)
595 (goto-char (next-visible-point pos))
598 (defun wl-plugged-move-to-previous ()
600 (if (eq (char-before) ?\]) (forward-char -1))
601 (when (re-search-backward "\\[\\([^]]+\\)\\]" nil t)
602 (let ((pos (match-beginning 1)))
603 (if (invisible-p pos)
604 (goto-char (next-visible-point pos))
607 (defun wl-plugged-move-to-next-server ()
610 (format "^%s\\[\\([^]]+\\)\\]" (wl-plugged-server-indent)))
614 (if (re-search-forward regexp nil t)
615 (setq point (match-beginning 1))))
616 (if point (goto-char point))))
618 (defun wl-plugged-move-to-previous-server ()
621 (format "^%s\\[\\([^]]+\\)\\]" (wl-plugged-server-indent))))
622 (if (re-search-backward regexp nil t)
623 (goto-char (match-beginning 1)))))
625 ;;; end of wl-plugged-mode
628 "Save summary and folder status."
630 (wl-save-status 'keep-summary)
631 (run-hooks 'wl-save-hook))
633 (defun wl-save-status (&optional keep-summary)
634 (message "Saving summary and folder status...")
637 (let ((summaries (wl-collect-summary)))
639 (with-current-buffer (car summaries)
641 (wl-summary-cleanup-temp-marks))
642 (wl-summary-save-view)
643 (elmo-folder-commit wl-summary-buffer-elmo-folder)
645 (kill-buffer (car summaries))))
646 (setq summaries (cdr summaries))))))
647 (wl-refile-alist-save)
648 (wl-folder-info-save)
649 (and (featurep 'wl-fldmgr) (wl-fldmgr-exit))
650 (elmo-crosspost-message-alist-save)
651 (message "Saving summary and folder status...done"))
655 (when (or (not wl-interactive-exit)
656 (y-or-n-p "Do you really want to quit Wanderlust? "))
658 (when wl-use-acap (funcall (symbol-function 'wl-acap-exit)))
660 (run-hooks 'wl-exit-hook)
662 (wl-folder-cleanup-variables)
663 (wl-message-buffer-cache-clean-up)
667 (list wl-folder-buffer-name
670 (when wl-delete-startup-frame-function
671 (funcall wl-delete-startup-frame-function))
672 ;; (if (and wl-folder-use-frame
673 ;; (> (length (visible-frame-list)) 1))
676 (remove-hook 'kill-emacs-hook 'wl-save-status)
678 (message "") ; empty minibuffer.
683 (require 'mime-setup)
684 (setq elmo-plugged wl-plugged)
685 (add-hook 'kill-emacs-hook 'wl-save-status)
688 (wl-refile-alist-setup)
692 (fset 'wl-summary-from-func-internal
693 (symbol-value 'wl-summary-from-function))
694 (fset 'wl-summary-subject-func-internal
695 (symbol-value 'wl-summary-subject-function))
696 (fset 'wl-summary-subject-filter-func-internal
697 (symbol-value 'wl-summary-subject-filter-function))
698 (setq elmo-no-from wl-summary-no-from-message)
699 (setq elmo-no-subject wl-summary-no-subject-message)
702 ;; This hook may contain the functions `wl-plugged-init-icons' and
703 ;; `wl-biff-init-icons' for reasons of system internal to accord
704 ;; facilities for the Emacs variants.
705 (run-hooks 'wl-init-hook)))
707 (defun wl-check-environment (no-check-folder)
708 (unless wl-from (error "Please set `wl-from' to your mail address."))
710 (when wl-insert-message-id
711 (let ((message-id (funcall wl-message-id-function))
713 (unless (string-match "^<\\([^@]*\\)@\\([^@]*\\)>$" message-id)
715 ((string-match "@" wl-message-id-domain)
716 (error "Please remove `@' from `wl-message-id-domain'."))
719 "Check around `wl-message-id-function' to get valid Message-ID string."))))
720 (setq domain (match-string 2 message-id))
721 (if (or (not (string-match "[^.]\\.[^.]" domain))
722 (string= domain "localhost.localdomain"))
724 "Please set `wl-message-id-domain' to get valid Message-ID string."))))
726 (when (not no-check-folder)
727 (let ((draft-folder (wl-folder-get-elmo-folder wl-draft-folder))
728 (queue-folder (wl-folder-get-elmo-folder wl-queue-folder))
729 (lost+found-folder (wl-folder-get-elmo-folder
730 elmo-lost+found-folder)))
731 (if (not (elmo-folder-message-file-p draft-folder))
732 (error "%s is not allowed for draft folder" wl-draft-folder))
733 (unless (elmo-folder-exists-p draft-folder)
735 (format "Draft Folder %s does not exist, create it? "
737 (elmo-folder-create draft-folder)
738 (error "Draft Folder is not created")))
739 (if (and wl-draft-enable-queuing
740 (not (elmo-folder-exists-p queue-folder)))
742 (format "Queue Folder %s does not exist, create it? "
744 (elmo-folder-create queue-folder)
745 (error "Queue Folder is not created")))
746 (when (not (eq no-check-folder 'wl-draft))
747 (unless (elmo-folder-exists-p lost+found-folder)
748 (elmo-folder-create lost+found-folder)))
750 (unless (file-exists-p wl-temporary-file-directory)
752 (format "Temp directory (to save multipart) %s does not exist, create it now? "
753 wl-temporary-file-directory))
754 (make-directory wl-temporary-file-directory)
755 (error "Temp directory is not created"))))))
757 (defconst wl-check-variables-alist
758 '((numberp . elmo-pop3-default-port)
759 (symbolp . elmo-pop3-default-authenticate-type)
760 (numberp . elmo-imap4-default-port)
761 (symbolp . elmo-imap4-default-authenticate-type)
762 (numberp . elmo-nntp-default-port)
763 (numberp . wl-pop-before-smtp-port)
764 (symbolp . wl-pop-before-smtp-authenticate-type)))
766 (defun wl-check-variables ()
767 (let ((type-variables wl-check-variables-alist)
769 (while (setq type (car type-variables))
770 (if (and (eval (cdr type))
771 (not (funcall (car type)
773 (error "%s must be %s: %S"
775 (substring (format "%s" (car type)) 0 -1)
777 (setq type-variables (cdr type-variables)))))
779 (defun wl-check-variables-2 ()
780 (if (< wl-message-buffer-cache-size 1)
781 (error "`wl-message-buffer-cache-size' must be larger than 0."))
782 (when wl-message-buffer-prefetch-depth
783 (if (not (< wl-message-buffer-prefetch-depth
784 wl-message-buffer-cache-size))
786 "`wl-message-buffer-prefetch-depth' must be smaller than "
787 "`wl-message-buffer-cache-size' - 1."))))
788 (let (case-fold-search)
789 (unless (string-match "%T" wl-summary-line-format)
790 (error "`wl-summary-line-format' must contain %%T and %%P"))
791 (unless (string-match "%P" wl-summary-line-format)
792 (error "`wl-summary-line-format' must contain %%T and %%P"))
793 (dolist (pair wl-folder-summary-line-format-alist)
794 (unless (string-match "%T" (cdr pair))
795 (error "Format `%s' must contain %%T and %%P" (cdr pair)))
796 (unless (string-match "%P" (cdr pair))
797 (error "Format `%s' must contain %%T and %%P" (cdr pair))))))
800 (defun wl (&optional arg)
801 "Start Wanderlust -- Yet Another Message Interface On Emacsen.
802 If ARG (prefix argument) is specified, folder checkings are skipped."
808 (let (demo-buf check)
810 (if wl-demo (setq demo-buf (wl-demo)))
817 (message "Checking environment...")
818 (wl-check-environment arg)
819 (message "Checking environment...done")
820 (message "Checking type of variables...")
822 (wl-check-variables-2)
823 (message "Checking type of variables...done")))
824 (let ((inhibit-quit t))
825 (wl-plugged-init (wl-folder arg)))
827 (run-hooks 'wl-auto-check-folder-pre-hook)
828 (wl-folder-auto-check)
829 (run-hooks 'wl-auto-check-folder-hook))
830 (unless arg (wl-biff-start)))
832 (if (buffer-live-p demo-buf)
833 (kill-buffer demo-buf))
834 (signal (car obj)(cdr obj)))
836 (if (buffer-live-p demo-buf)
837 (kill-buffer demo-buf)))
838 (run-hooks 'wl-hook))
840 (defvar wl-delete-startup-frame-function nil)
843 (defun wl-other-frame (&optional arg)
844 "Pop up a frame to read messages via Wanderlust."
846 (if wl-folder-use-frame
848 (let ((focusing-functions (append '(raise-frame select-frame)
849 (if (fboundp 'x-focus-frame)
852 (folder (get-buffer wl-folder-buffer-name))
853 window frame wl-folder-use-frame)
855 (setq window (get-buffer-window folder t))
856 (window-live-p window)
857 (setq frame (window-frame window)))
859 (while focusing-functions
860 (funcall (car focusing-functions) frame)
861 (setq focusing-functions (cdr focusing-functions)))
863 (setq frame (make-frame))
864 (while focusing-functions
865 (funcall (car focusing-functions) frame)
866 (setq focusing-functions (cdr focusing-functions)))
867 (setq wl-delete-startup-frame-function
869 (setq wl-delete-startup-frame-function nil)
870 (let ((frame ,frame))
871 (if (eq (selected-frame) frame)
872 (delete-frame frame)))))
875 ;; Define some autoload functions WL might use.
877 ;; This little mapcar goes through the list below and marks the
878 ;; symbols in question as autoloaded functions.
882 (let ((interactive (nth 1 (memq ':interactive package))))
887 (when (consp function)
888 (setq keymap (car (memq 'keymap function)))
889 (setq function (car function)))
890 (autoload function (car package) nil interactive keymap))))
891 (if (eq (nth 1 package) ':interactive)
894 '(("wl-fldmgr" :interactive t
895 wl-fldmgr-access-display-all wl-fldmgr-access-display-normal
896 wl-fldmgr-add wl-fldmgr-clear-cut-entity-list wl-fldmgr-copy
897 wl-fldmgr-copy-region wl-fldmgr-cut wl-fldmgr-cut-region
898 wl-fldmgr-make-access-group wl-fldmgr-make-filter
899 wl-fldmgr-make-group wl-fldmgr-make-multi
900 wl-fldmgr-reconst-entity-hashtb wl-fldmgr-rename wl-fldmgr-delete
901 wl-fldmgr-save-folders wl-fldmgr-set-petname wl-fldmgr-sort
902 wl-fldmgr-subscribe wl-fldmgr-subscribe-region
903 wl-fldmgr-unsubscribe wl-fldmgr-unsubscribe-region wl-fldmgr-yank )
904 ("wl-acap" wl-acap-init)
905 ("wl-acap" :interactive t wl-acap-store)
907 (wl-fldmgr-mode-map keymap)
908 wl-fldmgr-add-entity-hashtb)
909 ("wl-expire" :interactive t
910 wl-folder-archive-current-entity
911 wl-folder-expire-current-entity wl-summary-archive
914 wl-score-save wl-summary-rescore-msgs wl-summary-score-headers
915 wl-summary-score-update-all-lines )
916 ("wl-score" :interactive t
917 wl-score-change-score-file wl-score-edit-current-scores
918 wl-score-edit-file wl-score-flush-cache wl-summary-rescore
919 wl-score-set-mark-below wl-score-set-expunge-below
920 wl-summary-increase-score wl-summary-lower-score ))))
922 ;; for backward compatibility
923 (defalias 'wl-summary-from-func-petname 'wl-summary-default-from)
926 (product-provide (provide 'wl) (require 'wl-version))