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
69 (require 'wl-highlight)
79 (defun wl-plugged-init (&optional make-alist)
80 (setq elmo-plugged wl-plugged)
81 (if wl-reset-plugged-alist
82 (elmo-set-plugged elmo-plugged))
84 (wl-make-plugged-alist))
86 (setq elmo-plugged (setq wl-plugged (elmo-plugged-p))
87 wl-modeline-plug-status wl-plugged)
89 (wl-toggle-plugged t 'flush)))
91 (defun wl-toggle-plugged (&optional arg queue-flush-only)
93 (elmo-quit) ; Disconnect current connection.
94 (unless queue-flush-only
99 (setq wl-plugged nil))
100 (t (setq wl-plugged (not wl-plugged))))
101 (elmo-set-plugged wl-plugged))
102 (setq elmo-plugged wl-plugged
103 wl-modeline-plug-status wl-plugged)
105 (let ((summaries (wl-collect-summary)))
107 (set-buffer (pop summaries))
108 (wl-summary-save-view)
109 (elmo-folder-commit wl-summary-buffer-elmo-folder))))
110 (setq wl-biff-check-folders-running nil)
114 (elmo-dop-queue-flush)
115 (unless queue-flush-only
116 (when wl-biff-check-folder-list
117 (wl-biff-check-folders)
119 (if (and wl-draft-enable-queuing
121 (wl-draft-queue-flush))
122 ;; (when (and (eq major-mode 'wl-summary-mode)
123 ;; (elmo-folder-plugged-p wl-summary-buffer-elmo-folder))
124 ;; (let* ((msgdb-dir (elmo-folder-msgdb-path
125 ;; wl-summary-buffer-elmo-folder))
126 ;; (seen-list (elmo-msgdb-seen-load msgdb-dir)))
128 ;; (wl-summary-flush-pending-append-operations seen-list))
129 ;; (elmo-msgdb-seen-save msgdb-dir seen-list)))
130 (run-hooks 'wl-plugged-hook))
132 (run-hooks 'wl-unplugged-hook))
133 (force-mode-line-update t))
137 (defvar wl-plugged-port-label-alist
138 (list (cons 119 "nntp")
142 ;;(cons elmo-pop-before-smtp-port "pop3")
144 (defconst wl-plugged-switch-variables
145 '(("Queuing" . wl-draft-enable-queuing)
146 ("AutoFlushQueue" . wl-auto-flush-queue)
147 ("DisconnectedOperation" . elmo-enable-disconnected-operation)))
149 (defvar wl-plugged-buf-name "Plugged")
150 (defvar wl-plugged-mode-map nil)
151 (defvar wl-plugged-alist nil)
152 (defvar wl-plugged-switch nil)
153 (defvar wl-plugged-winconf nil)
154 (defvar wl-plugged-sending-queue-alist nil)
155 (defvar wl-plugged-dop-queue-alist nil)
156 (defvar wl-plugged-alist-modified nil)
158 (defvar wl-plugged-mode-menu-spec
160 ["Toggle plugged" wl-plugged-toggle t]
161 ["Toggle All plugged" wl-plugged-toggle-all t]
162 ["Prev Port" wl-plugged-move-to-previous t]
163 ["Next Port" wl-plugged-move-to-next t]
164 ["Prev Server" wl-plugged-move-to-previous-server t]
165 ["Next Server" wl-plugged-move-to-next-server t]
166 ["Flush queue" wl-plugged-flush-queue t]
168 ["Exit" wl-plugged-exit t]))
172 (defun wl-plugged-setup-mouse ()
173 (define-key wl-plugged-mode-map 'button2 'wl-plugged-click))
174 (defun wl-plugged-setup-mouse ()
175 (define-key wl-plugged-mode-map [mouse-2] 'wl-plugged-click))))
177 (unless wl-plugged-mode-map
178 (setq wl-plugged-mode-map (make-sparse-keymap))
179 (define-key wl-plugged-mode-map " " 'wl-plugged-toggle)
180 (define-key wl-plugged-mode-map "\C-m" 'wl-plugged-toggle)
181 (define-key wl-plugged-mode-map "\M-t" 'wl-plugged-toggle-all)
182 (define-key wl-plugged-mode-map "q" 'wl-plugged-exit)
183 (define-key wl-plugged-mode-map "\C-t" 'wl-plugged-exit)
184 (define-key wl-plugged-mode-map "F" 'wl-plugged-flush-queue)
185 (define-key wl-plugged-mode-map "P" 'wl-plugged-move-to-previous-server)
186 (define-key wl-plugged-mode-map "N" 'wl-plugged-move-to-next-server)
187 (define-key wl-plugged-mode-map "p" 'wl-plugged-move-to-previous)
188 (define-key wl-plugged-mode-map "n" 'wl-plugged-move-to-next)
189 (define-key wl-plugged-mode-map "\e\t" 'wl-plugged-move-to-previous)
190 (define-key wl-plugged-mode-map "\t" 'wl-plugged-move-to-next)
191 (wl-plugged-setup-mouse)
195 "Menu used in Plugged mode."
196 wl-plugged-mode-menu-spec))
198 (defun wl-plugged-mode ()
199 "Mode for setting Wanderlust plugged.
200 See info under Wanderlust for full documentation.
203 \\{wl-plugged-mode-map}
205 Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
207 (kill-all-local-variables)
208 (use-local-map wl-plugged-mode-map)
209 (setq major-mode 'wl-plugged-mode)
210 (setq mode-name "Plugged")
211 (easy-menu-add wl-plugged-mode-menu)
212 (wl-mode-line-buffer-identification)
213 (setq wl-plugged-switch wl-plugged)
214 (setq wl-plugged-alist-modified nil)
215 (setq buffer-read-only t)
216 (run-hooks 'wl-plugged-mode-hook))
218 (defmacro wl-plugged-string (plugged &optional time)
219 (` (if (, time) wl-plugged-auto-off
220 (if (, plugged) wl-plugged-plug-on wl-plugged-plug-off))))
222 (defmacro wl-plugged-server-indent ()
223 (` (make-string wl-plugged-server-indent ? )))
225 (defun wl-plugged-set-variables ()
226 (setq wl-plugged-sending-queue-alist
227 (wl-plugged-sending-queue-info))
228 (setq wl-plugged-dop-queue-alist
229 (wl-plugged-dop-queue-info))
230 (setq wl-plugged-alist
231 (sort (copy-sequence elmo-plugged-alist)
233 (string< (caar a) (caar b))))))
235 (defun wl-plugged-sending-queue-info ()
236 ;; sending queue status
237 (let (alist msgs sent-via server port)
238 (setq msgs (elmo-folder-list-messages
239 (wl-folder-get-elmo-folder wl-queue-folder)))
241 (setq sent-via (wl-draft-queue-info-operation (car msgs) 'get-sent-via))
243 (when (eq (nth 1 (car sent-via)) 'unplugged)
244 (setq server (car (nth 2 (car sent-via)))
245 port (cdr (nth 2 (car sent-via))))
246 (elmo-plugged-p server port) ;; add elmo-plugged-alist if nothing.
248 (wl-append-assoc-list
252 (setq sent-via (cdr sent-via)))
253 (setq msgs (cdr msgs)))
256 (defun wl-plugged-sending-queue-status (qinfo)
257 ;; sending queue status
258 (let ((len (length (cdr qinfo))))
259 (concat (wl-plugged-set-folder-icon
261 (wl-folder-get-petname wl-queue-folder))
263 (format ": %d msgs (" len)
264 (format ": %d msg (" len))
265 (mapconcat (function int-to-string) (cdr qinfo) ",")
268 (defun wl-plugged-dop-queue-info ()
271 (elmo-dop-queue (copy-sequence elmo-dop-queue))
272 dop-queue last alist server-info
274 ;(elmo-dop-queue-load)
275 (elmo-dop-queue-merge)
276 (setq dop-queue (sort elmo-dop-queue '(lambda (a b)
277 (string< (elmo-dop-queue-fname a)
278 (elmo-dop-queue-fname b)))))
279 (wl-append dop-queue (list nil)) ;; terminate(dummy)
280 (when (car dop-queue)
281 (setq last (elmo-dop-queue-fname (car dop-queue)))) ;; first
283 (when (car dop-queue)
284 (setq ope (cons (elmo-dop-queue-method-name (car dop-queue))
288 (elmo-dop-queue-arguments (car dop-queue))))
289 (car (elmo-dop-queue-arguments
290 (car dop-queue))))))))
291 (if (and (car dop-queue)
292 (string= last (elmo-dop-queue-fname (car dop-queue))))
293 (wl-append operation (list ope))
294 ;;(setq count (1+ count))
295 (when (and last (setq server-info (elmo-net-port-info
296 (wl-folder-get-elmo-folder last))))
298 (wl-append-assoc-list
300 (cons last operation)
302 (when (car dop-queue)
303 (setq last (elmo-dop-queue-fname (car dop-queue))
304 operation (list ope))))
305 (setq dop-queue (cdr dop-queue)))
308 (defun wl-plugged-dop-queue-status (qinfo &optional column)
310 (let ((operations (cdr qinfo))
311 (column (or column wl-plugged-queue-status-column)))
313 '(lambda (folder-ope)
314 (concat (wl-plugged-set-folder-icon
316 (wl-folder-get-petname (car folder-ope)))
318 (let ((opes (cdr folder-ope))
321 (if (setq pair (assoc (car (car opes)) shrinked))
322 (setcdr pair (+ (cdr pair)
323 (max (cdr (car opes)) 1)))
325 (cons (car (car opes))
326 (max (cdr (car opes)) 1))
328 (setq opes (cdr opes)))
332 (format "%s:%d" (car ope) (cdr ope))
333 (format "%s" (car ope))))
334 (nreverse shrinked) ","))
337 (concat "\n" (wl-set-string-width column "")))))
339 (defun wl-plugged-drawing (plugged-alist)
340 (let ((buffer-read-only nil)
341 (alist plugged-alist)
342 (vars wl-plugged-switch-variables)
343 last server port stream-type label plugged time
344 line len qinfo column)
347 (insert (format "%s:[%s]%s"
349 (wl-plugged-string (symbol-value (cdar vars)))
350 (if (cdr vars) " " "")))
351 (setq vars (cdr vars)))
353 (let ((elmo-plugged wl-plugged-switch))
354 (setq line (format "[%s](wl-plugged)"
355 (wl-plugged-string (elmo-plugged-p))))
356 ;; sending queue status
357 (when (setq qinfo (assoc (cons nil nil) wl-plugged-sending-queue-alist))
359 (wl-set-string-width wl-plugged-queue-status-column line)
360 (wl-plugged-sending-queue-status qinfo))))
363 (setq server (nth 0 (caar alist))
364 port (nth 1 (caar alist))
365 stream-type (nth 2 (caar alist))
366 label (nth 1 (car alist))
367 plugged (nth 2 (car alist))
368 time (nth 3 (car alist)))
369 (unless (string= last server)
371 (insert (format "%s[%s]%s\n"
372 (wl-plugged-server-indent)
374 (elmo-plugged-p server nil plugged-alist))
380 (make-string wl-plugged-port-indent ? )
381 (wl-plugged-string plugged time)
388 (cdr (assq port wl-plugged-port-label-alist))
391 (setq column (max (if line (1+ (string-width line)) 0)
392 wl-plugged-queue-status-column))
394 ;; sending queue status
395 ((setq qinfo (assoc (cons server port) wl-plugged-sending-queue-alist))
398 (wl-set-string-width column line)
399 (wl-plugged-sending-queue-status qinfo))))
401 ((setq qinfo (assoc (list server port stream-type)
402 wl-plugged-dop-queue-alist))
405 (wl-set-string-width column line)
406 (wl-plugged-dop-queue-status qinfo column)))))
408 (setq alist (cdr alist)))
409 (delete-region (1- (point-max)) (point-max)) ;; delete line at the end.
410 (goto-char (point-min))
412 (wl-highlight-plugged-current-line)
414 (set-buffer-modified-p nil)
415 (count-lines (point-min) (point-max)))
417 (defun wl-plugged-redrawing-switch (indent switch &optional time)
419 (when (re-search-forward
420 (format "^%s\\[\\([^]]+\\)\\]" (make-string indent ? )))
421 (goto-char (match-beginning 1))
422 (delete-region (match-beginning 1) (match-end 1))
423 (insert (wl-plugged-string switch time))
424 (wl-highlight-plugged-current-line)
427 (defun wl-plugged-redrawing (plugged-alist)
428 (let ((buffer-read-only nil)
429 (alist plugged-alist)
430 last server port plugged time)
431 (goto-char (point-min))
432 (wl-plugged-redrawing-switch 0 (elmo-plugged-p))
434 (setq server (caaar alist)
436 plugged (nth 2 (car alist))
437 time (nth 3 (car alist)))
438 (unless (string= last server)
440 (wl-plugged-redrawing-switch
441 wl-plugged-server-indent
442 (elmo-plugged-p server nil plugged-alist))
445 (wl-plugged-redrawing-switch
446 wl-plugged-port-indent plugged time)
447 (setq alist (cdr alist))))
449 (set-buffer-modified-p nil))
451 (defun wl-plugged-change ()
453 (if (not elmo-plugged-alist)
454 (message "No plugged info")
455 (setq wl-plugged-winconf (current-window-configuration))
456 (let* ((cur-win (selected-window))
457 (max-lines (if (eq major-mode 'wl-summary-mode)
462 (set-buffer (get-buffer-create wl-plugged-buf-name))
464 (buffer-disable-undo (current-buffer))
465 (delete-windows-on (current-buffer))
466 (wl-plugged-set-variables)
467 (setq lines (wl-plugged-drawing wl-plugged-alist)))
468 (select-window cur-win)
469 (setq window-lines (min max-lines (max lines window-min-height)))
470 (when (> (- (window-height) window-lines) window-min-height)
471 (split-window cur-win (- (window-height) window-lines)))
472 (switch-to-buffer wl-plugged-buf-name)
475 (enlarge-window (- window-lines (window-height)))
476 (when (fboundp 'pos-visible-in-window-p)
477 (goto-char (point-min))
478 (while (and (< (window-height) max-lines)
479 (not (pos-visible-in-window-p (1- (point-max)))))
480 (enlarge-window 2))))
482 (goto-char (point-min))
484 (wl-plugged-move-to-next)))) ;; goto first entry
486 (defsubst wl-plugged-get-server ()
489 (wl-plugged-move-to-previous-server)
491 (when (looking-at (format "^%s\\[[^]]+\\]\\(.*\\)"
492 (wl-plugged-server-indent)))
493 (elmo-match-buffer 1))))
495 (defun wl-plugged-toggle ()
497 (let ((cur-point (point)))
503 (let (variable switch name)
504 (goto-char cur-point)
505 (when (and (not (bobp))
506 (not (eq (char-before) ? )))
507 (if (re-search-backward " [^ ]+" nil t)
509 (re-search-backward "^[^ ]+" nil t)))
510 (when (looking-at "\\([^ :[]+\\):?\\[\\([^]]+\\)\\]")
511 (setq name (elmo-match-buffer 1))
512 (setq switch (not (string= (elmo-match-buffer 2) wl-plugged-plug-on)))
513 (when (setq variable (cdr (assoc name wl-plugged-switch-variables)))
514 (set variable switch))
515 (goto-char (match-beginning 2))
516 (let ((buffer-read-only nil))
517 (delete-region (match-beginning 2) (match-end 2))
518 (insert (wl-plugged-string switch))
519 (set-buffer-modified-p nil)))))
521 ((looking-at "^\\( *\\)\\[\\([^]]+\\)\\]\\([^ \n]*\\)")
522 (let* ((indent (length (elmo-match-buffer 1)))
523 (switch (elmo-match-buffer 2))
524 (name (elmo-match-buffer 3))
525 (plugged (not (string= switch wl-plugged-plug-on)))
526 (alist wl-plugged-alist)
527 server port stream-type name-1)
529 ((eq indent wl-plugged-port-indent) ;; toggle port plug
531 ((string-match "\\([^([]*\\)(\\([^)[]+\\))" name)
532 (setq port (string-to-int (elmo-match-string 2 name)))
533 (if (string-match "!" (setq name-1 (elmo-match-string 1 name)))
535 (intern (substring name-1 (match-end 0))))))
538 (setq server (wl-plugged-get-server))
539 (elmo-set-plugged plugged server port stream-type nil alist))
540 ((eq indent wl-plugged-server-indent) ;; toggle server plug
541 (elmo-set-plugged plugged name nil nil nil alist))
542 ((eq indent 0) ;; toggle all plug
543 (elmo-set-plugged plugged nil nil nil nil alist)))
545 (wl-plugged-redrawing wl-plugged-alist)
546 ;; show plugged status in modeline
547 (let ((elmo-plugged wl-plugged-switch))
548 (setq wl-plugged-switch (elmo-plugged-p)
549 wl-modeline-plug-status wl-plugged-switch)
550 (force-mode-line-update t))))))
551 (setq wl-plugged-alist-modified t)
552 (goto-char cur-point)))
554 (defun wl-plugged-click (e)
559 (defun wl-plugged-toggle-all ()
561 (let ((cur-point (point)))
562 (setq wl-plugged-switch (not wl-plugged-switch))
563 (elmo-set-plugged wl-plugged-switch nil nil nil nil wl-plugged-alist)
564 (wl-plugged-redrawing wl-plugged-alist)
565 (goto-char cur-point)
566 (setq wl-plugged-alist-modified t)
567 ;; show plugged status in modeline
568 (setq wl-modeline-plug-status wl-plugged-switch)
569 (force-mode-line-update t)))
571 (defun wl-plugged-exit ()
573 (setq ;;elmo-plugged-alist wl-plugged-alist
574 wl-plugged wl-plugged-switch
576 wl-plugged-sending-queue-alist nil
577 wl-plugged-dop-queue-alist nil)
578 (run-hooks 'wl-plugged-exit-hook)
579 (when wl-plugged-alist-modified
580 (wl-toggle-plugged (if wl-plugged 'on 'off) t))
581 (kill-buffer (current-buffer))
582 (if wl-plugged-winconf
583 (set-window-configuration wl-plugged-winconf)))
585 (defun wl-plugged-flush-queue ()
587 (let ((cur-point (point))
588 (dop-status (elmo-dop-queue-flush))
589 (send-status (wl-draft-queue-flush)))
590 (unless (or dop-status send-status)
591 (message "No processing queue."))
592 (wl-plugged-set-variables)
593 (wl-plugged-drawing wl-plugged-alist)
594 (goto-char cur-point)))
596 (defun wl-plugged-move-to-next ()
598 (when (re-search-forward "\\[\\([^]]+\\)\\]" nil t)
599 (let ((pos (match-beginning 1)))
600 (if (invisible-p pos)
601 (goto-char (next-visible-point pos))
604 (defun wl-plugged-move-to-previous ()
606 (if (eq (char-before) ?\]) (forward-char -1))
607 (when (re-search-backward "\\[\\([^]]+\\)\\]" nil t)
608 (let ((pos (match-beginning 1)))
609 (if (invisible-p pos)
610 (goto-char (next-visible-point pos))
613 (defun wl-plugged-move-to-next-server ()
616 (format "^%s\\[\\([^]]+\\)\\]" (wl-plugged-server-indent)))
620 (if (re-search-forward regexp nil t)
621 (setq point (match-beginning 1))))
622 (if point (goto-char point))))
624 (defun wl-plugged-move-to-previous-server ()
627 (format "^%s\\[\\([^]]+\\)\\]" (wl-plugged-server-indent))))
628 (if (re-search-backward regexp nil t)
629 (goto-char (match-beginning 1)))))
631 ;;; end of wl-plugged-mode
634 "Save summary and folder status."
636 (wl-save-status 'keep-summary)
637 (run-hooks 'wl-save-hook))
639 (defun wl-execute-temp-marks ()
640 "Execute temporary marks in summary buffers."
642 (let ((summaries (wl-collect-summary)))
644 (with-current-buffer (car summaries)
645 (wl-summary-exec-with-confirmation)
646 (wl-summary-save-status))
647 (setq summaries (cdr summaries)))))
649 (defun wl-save-status (&optional keep-summary)
650 (message "Saving summary and folder status...")
652 (let ((summaries (wl-collect-summary)))
654 (with-current-buffer (car summaries)
656 (wl-summary-cleanup-temp-marks))
657 (wl-summary-save-view)
658 (elmo-folder-commit wl-summary-buffer-elmo-folder)
660 (kill-buffer (car summaries))))
661 (setq summaries (cdr summaries)))))
662 (wl-refile-alist-save)
663 (wl-folder-info-save)
664 (and (featurep 'wl-fldmgr) (wl-fldmgr-exit))
665 (and (featurep 'wl-spam) (wl-spam-save-status))
666 (elmo-crosspost-message-alist-save)
667 (message "Saving summary and folder status...done"))
671 (when (or (not wl-interactive-exit)
672 (y-or-n-p "Do you really want to quit Wanderlust? "))
674 (when wl-use-acap (funcall (symbol-function 'wl-acap-exit)))
676 (elmo-clear-signal-slots)
677 (run-hooks 'wl-exit-hook)
679 (wl-folder-cleanup-variables)
680 (wl-message-buffer-cache-clean-up)
684 (list wl-folder-buffer-name
687 (when wl-delete-startup-frame-function
688 (funcall wl-delete-startup-frame-function))
689 ;; (if (and wl-folder-use-frame
690 ;; (> (length (visible-frame-list)) 1))
693 (remove-hook 'kill-emacs-hook 'wl-save-status)
694 (elmo-passwd-alist-clear)
696 (message "") ; empty minibuffer.
701 (require 'mime-setup)
702 (setq elmo-plugged wl-plugged)
703 (add-hook 'kill-emacs-hook 'wl-save-status)
706 (wl-refile-alist-setup)
710 (fset 'wl-summary-from-func-internal
711 (symbol-value 'wl-summary-from-function))
712 (fset 'wl-summary-subject-func-internal
713 (symbol-value 'wl-summary-subject-function))
714 (fset 'wl-summary-subject-filter-func-internal
715 (symbol-value 'wl-summary-subject-filter-function))
716 (wl-summary-define-sort-command)
717 (wl-summary-define-mark-action)
718 (dolist (spec wl-summary-flag-alist)
721 (format "wl-highlight-summary-%s-flag-face" (car spec))))
723 (setq elmo-get-folder-function #'wl-folder-make-elmo-folder)
724 (setq elmo-no-from wl-summary-no-from-message)
725 (setq elmo-no-subject wl-summary-no-subject-message)
726 (elmo-global-flags-initialize (mapcar 'car wl-summary-flag-alist))
729 'message-number-changed
731 (elmo-define-signal-handler (listener folder old-number new-number)
732 (dolist (buffer (wl-collect-draft))
733 (with-current-buffer buffer
734 (wl-draft-buffer-change-number old-number new-number)))
735 (wl-draft-rename-saved-config old-number new-number))
736 (elmo-define-signal-filter (listener folder old-number new-number)
738 (string= (elmo-folder-name-internal folder) wl-draft-folder))))
741 ;; This hook may contain the functions `wl-plugged-init-icons' and
742 ;; `wl-biff-init-icons' for reasons of system internal to accord
743 ;; facilities for the Emacs variants.
744 (run-hooks 'wl-init-hook)))
746 (defun wl-check-environment (no-check-folder)
747 (unless wl-from (error "Please set `wl-from' to your mail address"))
749 (when wl-insert-message-id
750 (let ((message-id (funcall wl-message-id-function))
752 (unless (string-match "^<\\([^@]*\\)@\\([^@]*\\)>$" message-id)
754 ((string-match "@" wl-message-id-domain)
755 (error "Please remove `@' from `wl-message-id-domain'"))
758 "Check around `wl-message-id-function' to get valid Message-ID string"))))
759 (setq domain (match-string 2 message-id))
760 (if (or (not (string-match "[^.]\\.[^.]" domain))
761 (string= domain "localhost.localdomain"))
763 "Please set `wl-message-id-domain' to get valid Message-ID string."))))
765 (when (not no-check-folder)
766 (let ((draft-folder (wl-folder-get-elmo-folder wl-draft-folder))
767 (queue-folder (wl-folder-get-elmo-folder wl-queue-folder))
768 (lost+found-folder (wl-folder-get-elmo-folder
769 elmo-lost+found-folder)))
770 (unless (elmo-folder-exists-p draft-folder)
772 (format "Draft Folder %s does not exist, create it? "
774 (elmo-folder-create draft-folder)
775 (error "Draft Folder is not created")))
776 (if (and wl-draft-enable-queuing
777 (not (elmo-folder-exists-p queue-folder)))
779 (format "Queue Folder %s does not exist, create it? "
781 (elmo-folder-create queue-folder)
782 (error "Queue Folder is not created")))
783 (when (not (eq no-check-folder 'wl-draft))
784 (unless (elmo-folder-exists-p lost+found-folder)
785 (elmo-folder-create lost+found-folder)))
787 (unless (file-exists-p wl-temporary-file-directory)
789 (format "Temp directory (to save multipart) %s does not exist, create it now? "
790 wl-temporary-file-directory))
791 (make-directory wl-temporary-file-directory)
792 (error "Temp directory is not created"))))))
794 (defconst wl-check-variables-alist
795 '((numberp . elmo-pop3-default-port)
796 (symbolp . elmo-pop3-default-authenticate-type)
797 (numberp . elmo-imap4-default-port)
798 (symbolp . elmo-imap4-default-authenticate-type)
799 (numberp . elmo-nntp-default-port)
800 (numberp . wl-pop-before-smtp-port)
801 (symbolp . wl-pop-before-smtp-authenticate-type)))
803 (defun wl-check-variables ()
804 (let ((type-variables wl-check-variables-alist)
806 (while (setq type (car type-variables))
807 (if (and (eval (cdr type))
808 (not (funcall (car type)
810 (error "%s must be %s: %S"
812 (substring (format "%s" (car type)) 0 -1)
814 (setq type-variables (cdr type-variables)))))
816 (defun wl-check-variables-2 ()
817 (if (< wl-message-buffer-cache-size 1)
818 (error "`wl-message-buffer-cache-size' must be larger than 0"))
819 (when wl-message-buffer-prefetch-depth
820 (if (not (< wl-message-buffer-prefetch-depth
821 wl-message-buffer-cache-size))
823 "`wl-message-buffer-prefetch-depth' must be smaller than "
824 "`wl-message-buffer-cache-size' - 1.")))))
827 (defun wl (&optional arg)
828 "Start Wanderlust -- Yet Another Message Interface On Emacsen.
829 If ARG (prefix argument) is specified, folder checkings are skipped."
834 (let (demo-buf check)
836 (if wl-demo (setq demo-buf (wl-demo)))
843 (message "Checking environment...")
844 (wl-check-environment arg)
845 (message "Checking environment...done")
846 (message "Checking type of variables...")
848 (wl-check-variables-2)
849 (message "Checking type of variables...done")))
850 (let ((inhibit-quit t))
851 (wl-plugged-init (wl-folder)))
853 (run-hooks 'wl-auto-check-folder-pre-hook)
854 (wl-folder-auto-check)
855 (run-hooks 'wl-auto-check-folder-hook)))
857 (if (buffer-live-p demo-buf)
858 (kill-buffer demo-buf))
859 (signal (car obj)(cdr obj)))
861 (when wl-biff-check-folder-list
862 (unless arg (wl-biff-check-folders))
864 (if (buffer-live-p demo-buf)
865 (kill-buffer demo-buf)))
866 (run-hooks 'wl-hook))
868 (defvar wl-delete-startup-frame-function nil)
871 (defun wl-other-frame (&optional arg)
872 "Pop up a frame to read messages via Wanderlust."
874 (if wl-folder-use-frame
876 (let ((focusing-functions (append '(raise-frame select-frame)
877 (if (fboundp 'x-focus-frame)
880 (folder (get-buffer wl-folder-buffer-name))
881 window frame wl-folder-use-frame)
883 (setq window (get-buffer-window folder t))
884 (window-live-p window)
885 (setq frame (window-frame window)))
887 (while focusing-functions
888 (funcall (car focusing-functions) frame)
889 (setq focusing-functions (cdr focusing-functions)))
891 (setq frame (make-frame))
892 (while focusing-functions
893 (funcall (car focusing-functions) frame)
894 (setq focusing-functions (cdr focusing-functions)))
895 (setq wl-delete-startup-frame-function
897 (setq wl-delete-startup-frame-function nil)
898 (let ((frame ,frame))
899 (if (eq (selected-frame) frame)
900 (delete-frame frame)))))
903 ;; Define some autoload functions WL might use.
905 ;; This little mapcar goes through the list below and marks the
906 ;; symbols in question as autoloaded functions.
910 (let ((interactive (nth 1 (memq ':interactive package))))
915 (when (consp function)
916 (setq keymap (car (memq 'keymap function)))
917 (setq function (car function)))
918 (autoload function (car package) nil interactive keymap))))
919 (if (eq (nth 1 package) ':interactive)
922 '(("wl-fldmgr" :interactive t
923 wl-fldmgr-access-display-all wl-fldmgr-access-display-normal
924 wl-fldmgr-add wl-fldmgr-clear-cut-entity-list wl-fldmgr-copy
925 wl-fldmgr-copy-region wl-fldmgr-cut wl-fldmgr-cut-region
926 wl-fldmgr-make-access-group wl-fldmgr-make-filter
927 wl-fldmgr-make-group wl-fldmgr-make-multi
928 wl-fldmgr-reconst-entity-hashtb wl-fldmgr-rename wl-fldmgr-delete
929 wl-fldmgr-save-folders wl-fldmgr-set-petname wl-fldmgr-sort
930 wl-fldmgr-subscribe wl-fldmgr-subscribe-region
931 wl-fldmgr-unsubscribe wl-fldmgr-unsubscribe-region wl-fldmgr-yank )
932 ("wl-acap" wl-acap-init)
933 ("wl-acap" :interactive t wl-acap-store)
935 (wl-fldmgr-mode-map keymap)
936 wl-fldmgr-add-entity-hashtb)
937 ("wl-expire" :interactive t
938 wl-folder-archive-current-entity
939 wl-folder-expire-current-entity wl-summary-archive
942 wl-score-save wl-summary-rescore-msgs wl-summary-score-headers
943 wl-summary-score-update-all-lines )
944 ("wl-score" :interactive t
945 wl-score-change-score-file wl-score-edit-current-scores
946 wl-score-edit-file wl-score-flush-cache wl-summary-rescore
947 wl-score-set-mark-below wl-score-set-expunge-below
948 wl-summary-increase-score wl-summary-lower-score )
949 ("wl-draft" wl-draft-rename-saved-config))))
951 ;; for backward compatibility
952 (defalias 'wl-summary-from-func-petname 'wl-summary-default-from)
955 (product-provide (provide 'wl) (require 'wl-version))