;;; gnus-ofsetup.el --- Setup advisor for Offline reading for Mail/News.
-;;;
-;;; Copyright (C) 1998 Tatsuya Ichikawa
-;;; Author: Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
-;;; Tsukamoto Tetsuo <czkmt@remus.dti.ne.jp>
-;;;
-;;; This file is part of Semi-gnus.
-;;;
-;;; GNU Emacs is free software; you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 2, or (at your option)
-;;; any later version.
-
-;;; GNU Emacs is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Emacs; see the file COPYING. If not, write to the
-;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;;; Boston, MA 02111-1307, USA.
-;;;
-;;;; Commentary:
-;;; How to use.
-;;;
-;;; M-x load[RET]gnus-ofsetup
-;;; M-x gnus-setup-for-offline
-;;;
+
+;; Copyright (C) 1998 Tatsuya Ichikawa
+
+;; Author: Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
+;; Tsukamoto Tetsuo <czkmt@remus.dti.ne.jp>
+;;
+;; This file is part of Semi-gnus.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+;;
+
+;;; Commentary:
+
+;; How to use.
+;;
+;; M-x load[RET]gnus-ofsetup
+;; M-x gnus-setup-for-offline
+;;
;;; Code:
(eval-when-compile (require 'cl))
+(eval-when-compile (require 'gnus-clfns))
+
+(require 'read-passwd)
(eval-and-compile
(defvar gnus-offline-lang
(insert "(setq gnus-offline-MTA-type '"
(prin1-to-string MTA-type) ")\n")
- ;; Offline setting for gnus-nntp-*
- (insert "(setq gnus-nntp-service nil)\n")
- (insert "(setq gnus-nntp-server nil)\n")
-
;; Write setting about hooks.
- (insert (format "%s %s %s\n"
- "(add-hook"
- "'gnus-group-mode-hook"
- "'gnus-offline-processed-by-timer t)"))
- (insert (format "%s %s %s\n"
- "(add-hook"
- "'gnus-group-mode-hook"
- "'gnus-offline-error-check t)"))
- (insert (format "%s %s %s\n"
- "(add-hook"
- "'gnus-after-getting-new-news-hook"
- "'gnus-offline-after-get-new-news)"))
(when (eq news-method 'nnspool)
(insert (format "%s %s %s\n"
"(add-hook"
"'gnus-before-startup-hook"
"(lambda () (setq nnmail-spool-file nil)
(setq mail-sources nil)))")))
- (insert (format "%s %s %s\n"
- "(add-hook"
- "'message-send-hook"
- "'gnus-offline-message-add-header)"))
;; Write stting about mail-source.el
(insert "(setq gnus-offline-mail-source '"
(prin1-to-string mail-source) ")\n")
(insert "(setq mail-sources gnus-offline-mail-source)\n")
- (insert "(require 'read-passwd)\n")
- (insert "(setq mail-source-read-passwd 'read-pw-read-passwd)\n")
- (insert (format "%s %s %s\n"
- "(add-hook"
- "'gnus-setup-news-hook"
- "'read-pw-set-mail-source-passwd-cache)"))
(if save-passwd
(insert "(add-hook 'gnus-setup-news-hook
(lambda ()
(setup-8 . "Use MIEE post/send message ")
(setup-9 . "News spool directory for sending: ")
(setup-10 . "Mail spool directory for sending: ")
- (setup-11 . "How many e-mail address do you have: ")
- (setup-12 . "Mail Account name : ")
- (setup-13 . "Mail server : ")
- (setup-14 . "Authentification Method (TAB to completion): ")
- (setup-15 . "Do you use pop3.el to fetch mail? ")
- (setup-16 . "movemail program name: ")
- (setup-17 . "movemail options: ")
- (setup-18 . "Do you save password information to newsrc file? ")
+ (setup-11 . "How many mail sources will get mails from? : ")
+ (setup-12 . "What type of the mail source? ")
+ (setup-13 . "Mail Account name : ")
+ (setup-14 . "Mail server : ")
+ (setup-15 . "Authentification Method ")
+ (setup-16 . "Do you use pop3.el to fetch mail? ")
+ (setup-17 . "movemail program name: ")
+ (setup-18 . "movemail options: ")
+ (setup-19 . "What network stream? ")
+ (setup-20 . "File: ")
+ (setup-21 . "Directory: ")
+ (setup-22 . "Do you save password information to newsrc file? ")
+
(param-news-method-1 . "News Method")
(param-news-method-2 . "Gnus Agent")
(param-news-method-3 . "nnspool")
(setup-8 . "\e$B%a%C%;!<%8$NAw?.$K\e(B MIEE \e$B$r;H$$$^$9$+\e(B? ")
(setup-9 . "\e$B%K%e!<%9$N%9%W!<%k%G%#%l%/%H%j\e(B: ")
(setup-10 . "\e$B%a!<%k$N%9%W!<%k%G%#%l%/%H%j\e(B: ")
- (setup-11 . "\e$B%a!<%k%"%+%&%s%H$N?t$rEz$($F$/$@$5$$\e(B: ")
- (setup-12 . "\e$B%a!<%k$N%"%+%&%s%HL>\e(B: ")
- (setup-13 . "\e$B$=$N%"%+%&%s%H$N$"$k%a!<%k%5!<%PL>\e(B: ")
- (setup-14 . "\e$B$=$N%5!<%P$G$NG'>ZJ}<0$O\e(B? (TAB \e$B$GJd40$7$^$9\e(B): ")
- (setup-15 . "\e$B%a!<%k$N<u?.$K$O\e(B pop3.el \e$B$r;H$$$^$9$+\e(B? ")
- (setup-16 . "movemail \e$B%W%m%0%i%`$NL>A0\e(B: ")
- (setup-17 . "movemail \e$B%W%m%0%i%`$KEO$90z?t\e(B: ")
- (setup-18 . "newsrc \e$B%U%!%$%k$K\e(B POP \e$B%Q%9%o!<%I$rJ]B8$7$^$9$+\e(B? ")
+ (setup-11 . "\e$B@_Dj$9$k%a!<%k<hF@@h$N?t$O\e(B? (\e$B8e$GDI2C$G$-$^$9\e(B): ")
+ (setup-12 . "\e$B%a!<%k<hF@@h$N%?%$%W$O\e(B? ")
+ (setup-13 . "\e$B%a!<%k$N%"%+%&%s%HL>\e(B: ")
+ (setup-14 . "\e$B$=$N%"%+%&%s%H$N$"$k%a!<%k%5!<%PL>\e(B: ")
+ (setup-15 . "\e$BG'>ZJ}<0$O\e(B? ")
+ (setup-16 . "\e$B%a!<%k$N<u?.$K$O\e(B pop3.el \e$B$r;H$$$^$9$+\e(B? ")
+ (setup-17 . "movemail \e$B%W%m%0%i%`$NL>A0\e(B: ")
+ (setup-18 . "movemail \e$B%W%m%0%i%`$KEO$90z?t\e(B: ")
+ (setup-19 . "\e$B@\B3J}<0$O\e(B? ")
+ (setup-20 . "\e$B%U%!%$%k\e(B: ")
+ (setup-21 . "\e$B%G%#%l%/%H%j\e(B: ")
+ (setup-22 . "newsrc \e$B%U%!%$%k$K\e(B POP \e$B%Q%9%o!<%I$rJ]B8$7$^$9$+\e(B? ")
(param-news-method-4 . "\
\e$B%K%e!<%95-;v$r<hF@$9$kJ}K!$G$9!#\e(B")
msg
(gnus-ofsetup-gettext 'completing-read-symbol-1))
(mapcar
- (lambda (sym)
- (list (symbol-name sym)))
+ #'(lambda (sym)
+ (list (symbol-name sym)))
syms)
nil t nil)))
-(defun gnus-setup-for-offline ()
+(defun gnus-setup-for-offline (&optional force)
"*Set up Gnus for offline environment."
- (interactive)
- (unless (file-exists-p gnus-offline-setting-file)
+ (interactive "P")
+ (unless (and (file-exists-p gnus-offline-setting-file) (not force))
(let (news-method
mail-method agent-directory drafts-queue-type news-spool mail-spool
use-miee MTA-type dialup-program dialup-program-arguments
hangup-program hangup-program-arguments interval
- num-of-address i mail-source save-passwd)
+ num-of-address i n mail-source save-passwd)
(setq news-method
(gnus-ofsetup-completing-read-symbol
(gnus-ofsetup-gettext 'setup-1)
(gnus-ofsetup-prepare gnus-ofsetup-prepare-for-miee))
;; Set drafts type gnus-agent.
(setq drafts-queue-type 'agent))
- ;; Set E-Mail Address and pop3 movemail type.
+ ;; Create a list of mail source specifiers.
(setq num-of-address
(read-from-minibuffer (gnus-ofsetup-gettext 'setup-11)))
- (setq i (string-to-int num-of-address))
+ (setq i (setq n (string-to-int num-of-address)))
+ ;;
(while (> i 0)
- (let ((user (read-from-minibuffer (gnus-ofsetup-gettext 'setup-12)))
- (server (read-from-minibuffer
- (gnus-ofsetup-gettext 'setup-13)))
- (auth (completing-read
- (gnus-ofsetup-gettext 'setup-14)
- '(("password") ("apop")) nil t nil))
- (islisp (y-or-n-p (gnus-ofsetup-gettext 'setup-15)))
- source)
- (if (not islisp)
- (let ((prog (read-file-name (gnus-ofsetup-gettext 'setup-16)
- exec-directory "movemail"))
- (args (read-from-minibuffer
- (gnus-ofsetup-gettext 'setup-17)
- "-pf")))
- (setq source `(pop
- :user ,user
- :server ,server
- :program ,(format "%s %s %s %s %s"
- prog
- args
- "po:%u"
- "%t"
- "%p"))))
- (setq source `(pop
- :user ,user
- :server ,server)))
- (setq mail-source
- (nconc mail-source
- (list
- (if (string-equal "apop" auth)
- (nconc source '(:authentication apop))
- source)))))
+ (let* ((j (- n (1- i)))
+ (type (gnus-ofsetup-completing-read-symbol
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-12))
+ 'pop 'imap 'file 'directory 'maildir))
+ user server authentication stream islisp source
+ prog args program path)
+ ;; Prepare.
+ (when (or (string= type "pop") (string= type "imap"))
+ (setq user (read-from-minibuffer
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-13))))
+ (setq server (read-from-minibuffer
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-14)))))
+ (when (string= type "pop")
+ (setq authentication (gnus-ofsetup-completing-read-symbol
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-15))
+ 'password 'apop))
+ (setq islisp (y-or-n-p
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-16))))
+ (unless islisp
+ (setq prog (read-file-name
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-17))
+ exec-directory "movemail"))
+ (setq args (read-from-minibuffer
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-18) "-pf")))
+ (setq program (format "%s %s %s %s %s"
+ prog args "po:%u" "%t" "%p"))))
+ (when (string= type "imap")
+ (setq stream (gnus-ofsetup-completing-read-symbol
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-19))
+ 'kerberos4 'starttls 'ssl 'network))
+ (setq authentication (gnus-ofsetup-completing-read-symbol
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-14))
+ 'kerberos4 'digest-md5 'cram-md5 'login
+ 'anonymous)))
+ (when (string= type "file")
+ (setq path (read-file-name
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-20)))))
+ (when (or (string= type "directory") (string= type "maildir"))
+ (setq path (read-file-name
+ (format "<%d of %d> %s" j n
+ (gnus-ofsetup-gettext 'setup-21)))))
+ ;; Now set a mail source specifier.
+ (setq source `(,type))
+ (mapc
+ #'(lambda (sym)
+ (when (symbol-value sym)
+ (setq source
+ (nconc source
+ (list
+ (make-symbol
+ (format ":%s" sym))
+ (symbol-value sym))))))
+ '(path user server authentication stream program))
+ (setq mail-source (nconc mail-source (list source))))
(setq i (1- i)))
(setq save-passwd
- (y-or-n-p (gnus-ofsetup-gettext 'setup-18)))
+ (y-or-n-p (gnus-ofsetup-gettext 'setup-22)))
;;
(gnus-ofsetup-prepare gnus-ofsetup-update-setting-file)))
(load gnus-offline-setting-file))
"Edit the gnus-offline parameters."
(interactive)
(let* ((params (gnus-ofsetup-find-parameters))
- (types (mapcar (lambda (entry)
- `(cons :format "%v%h\n"
- :doc ,(nth 2 entry)
- (const :format "" ,(nth 0 entry))
- ,(nth 1 entry)))
+ (types (mapcar #'(lambda (entry)
+ `(cons :format "%v%h\n"
+ :doc ,(nth 2 entry)
+ (const :format "" ,(nth 0 entry))
+ ,(nth 1 entry)))
params)))
(kill-buffer (gnus-get-buffer-create "*Gnus Offline Customize*"))
(switch-to-buffer (gnus-get-buffer-create "*Gnus Offline Customize*"))
;;; Code for making Gnus and Gnus Offline cooperate with each other.
-;; advice.
+;; Advice.
(defadvice gnus (around gnus-ofsetup-advice activate preactivate)
"Setup offline environment when Gnus is invoked."
(require 'gnus-offline) ad-do-it (gnus-offline-setup))
-;; gnus-ofsetup.el Ends here.
+;; Miscellaneous settings.
+
+(setq gnus-nntp-service nil)
+(setq gnus-nntp-server nil)
+(eval-after-load "gnus-start"
+ '(add-hook 'gnus-after-getting-new-news-hook 'gnus-offline-after-get-new-news))
+(eval-after-load "message"
+ '(add-hook 'message-send-hook 'gnus-offline-message-add-header))
+(setq mail-source-read-passwd 'read-pw-read-passwd)
+(add-hook 'gnus-setup-news-hook 'read-pw-set-mail-source-passwd-cache)
+
+(provide 'gnus-ofsetup)
+
+;;; gnus-ofsetup.el ends here