[Mew-Win32 02562] mew-offline.el for 1.95bxx.
Shuichi KITAGUCHI ( 北口修一 )
kit at example.com
2000年 4月 16日 (日) 19:34:34 JST
北口です。
1.95bxx で mew-offline.el を動くようにしました。
IIJ-PPP(FreeBSD 付属のもの)でも動くようになっています。
設定は、基本的に
(require 'mew-offline)
だけでよいはずです。デフォルトの設定やキーバインドを奪ってしまうのは
考えた方が良いかもしれませんので、意見があれば言ってください。
おまけ: IIJ-PPP の設定方法
1. ppp.conf に
set socket <port_no> <password> # 指定ポート番号での制御を受け付ける
set filter dial 0 deny 0/0 0/0 # auto-dial を無効化
を追加し、
# ppp -auto <config_name>
で起動して background で動かす。
2. ~/.emacs に、
(setq rascon-current-entry '("config_name" "0" ""))
(setq mew-offline-ppp-port "<port_no>")
(setq mew-offline-ppp-passwd "<password>")
を追加(config_name は ppp.conf 中の設定名を、port_no/password は
ppp.conf に記述したものと同じものを指定)。
これで使えるはず、です。ppp 自体の設定がちゃんとできているかは、
# pppctl -p <password> <port_no> dial
でチェックできると思います。
# って Win32 ネタじゃないですね...
--
Shuichi Kitaguchi <kit at example.com>
-------------- next part --------------
;;; mew-offline.el --- Providing offline mode for Mew on Win32
;; Author: Shuichi Kitaguchi <kit at example.com>
;; Created: Jun 25, 1998
;; Time-stamp: <2000/04/16 19:17:21 kit>
;;
;; Usage:
;; ~/.im/Config
;; JustQueuing=yes
;; All sending mail operation is queued.
;;
;; ~/.emacs
;; (require 'mew-offline)
;;
;; Configuration:
;; mew-offline-dialup-p If nil, do not auto dial-up.
;; (Default is t)
;; mew-offline-hangup-p If nil, do not auto hang-up.
;; (Default is t)
;; mew-offline-use-mvm-p If non-nil, Use offline mode with
;; mew-win32-mvm.el (Default is nil)
;;
;; History:
;; 0.10 : support rascon.el 0.20
;; 0.11 : support mew-win32-mvm.el 0.09
;; add mew-offline-use-rascon variable.
;; 0.12 : if status is offline, do not flush queue.
;; delete mew-offline-use-rascon.
;; 0.13 : mew-offline-use-rascon comes back.
;;
;;; Code:
(defconst mew-offline-version "mew-offline.el version 0.13")
;; variables
(defvar mew-offline-dialup-p t
"*If nil, do not dial-up.")
(defvar mew-offline-hangup-p t
"*If nil, do not hang-up.")
(defvar mew-offline-use-mvm-p nil
"*If not nil, use offline mode with mew-win32-mvm.")
;; internal variable
(defvar mew-offline-use-rascon nil)
;; fake variables/functions for non-Win32 system.
(if (not (eq system-type 'windows-nt))
(progn
(defconst rascon-buffer " *RASCON*")
(defvar rascon-mode-indicator nil)
(defvar rascon-current-entry '("default" "0" ""))
(defvar rascon-dialup-wait 10)
(defvar rascon-hangup-wait 2)
(defvar mew-offline-ppp-port 0)
(defvar mew-offline-ppp-passwd "")
(defun rascon-generate-entry-table ()
(if (not (get-buffer rascon-buffer))
(get-buffer-create rascon-buffer))
(set-buffer rascon-buffer)
(erase-buffer)
(call-process "pppctl" nil rascon-buffer nil
"-p" mew-offline-ppp-passwd mew-offline-ppp-port
"show" "link")
(goto-char (point-min))
(cond
((re-search-forward "State:[ \t]*open" nil t)
(setq rascon-mode-indicator t))
(t
(setq rascon-mode-indicator nil)))
(kill-buffer rascon-buffer))
(defun rascon-dialup (&optional nowait)
"*Dialup following current dialup configuration."
(interactive)
(message "Dialing %s ..." (car rascon-current-entry))
(call-process "pppctl" nil nil nil
"-p" mew-offline-ppp-passwd mew-offline-ppp-port "dial")
(sit-for rascon-dialup-wait)
(if (not (get-buffer rascon-buffer))
(get-buffer-create rascon-buffer))
(set-buffer rascon-buffer)
(erase-buffer)
(catch 'loop
(while (not rascon-mode-indicator)
(erase-buffer)
(call-process "pppctl" nil rascon-buffer nil
"-p" mew-offline-ppp-passwd mew-offline-ppp-port
"show" "link")
(goto-char (point-min))
(cond
((re-search-forward "State:[ \t]*open" nil t)
(message "Dialing %s ... Done." (car rascon-current-entry))
(setq rascon-mode-indicator t))
((or (re-search-forward "State:[ \t]*closed" nil t)
(not (search-forward "State: " nil t))) ; unknown error?
(message "Dialing %s ... Failed." (car rascon-current-entry))
(throw 'loop t)))
(sit-for 2)))
(kill-buffer rascon-buffer))
(defun rascon-hangup (&optional force)
"*Hangup."
(interactive)
(message "Haning up %s ..." (car rascon-current-entry))
(call-process "pppctl" nil nil nil
"-p" mew-offline-ppp-passwd mew-offline-ppp-port "close")
(sit-for rascon-hangup-wait)
(if (not (get-buffer rascon-buffer))
(get-buffer-create rascon-buffer))
(set-buffer rascon-buffer)
(erase-buffer)
(catch 'loop
(while rascon-mode-indicator
(erase-buffer)
(call-process "pppctl" nil rascon-buffer nil
"-p" mew-offline-ppp-passwd mew-offline-ppp-port
"show" "link")
(goto-char (point-min))
(cond
((re-search-forward "State:[ \t]*closed" nil t)
(message "Hanging up %s ... Done." (car rascon-current-entry))
(setq rascon-mode-indicator nil))
((not (search-forward "State: " nil t)) ; unknown error?
(message "Hanging up %s ... Failed." (car rascon-current-entry))
(throw 'loop t)))
(sit-for 2)))
(kill-buffer rascon-buffer))
))
(if (or mew-offline-dialup-p mew-offline-hangup-p)
(progn
(setq mew-offline-use-rascon t)
(if (eq system-type 'windows-nt)
(require 'rascon))))
;; setup
(setq mew-auto-get nil)
;(setq mew-auto-flush-queue nil)
;; hooks
(add-hook 'mew-summary-mode-hook
(lambda ()
(progn
(define-key mew-summary-mode-map "i" 'mew-offline-summary-get)
(define-key mew-summary-mode-map "\C-c\C-c"
'mew-offline-summary-send-message)
)))
(add-hook 'mew-smtp-flush-hook 'mew-offline-hangup)
;; dialup
(defun mew-offline-dialup ()
(interactive)
(if mew-offline-dialup-p
(progn
(rascon-generate-entry-table)
(if (not rascon-mode-indicator)
(rascon-dialup)))))
(defun mew-offline-process-match (str)
(let ((plst (process-list)))
(if plst
(catch 'loop
(while plst
(if (string-match str (process-name (car plst)))
(throw 'loop t)
(setq plst (cdr plst))))))
plst))
;; hangup
(defun mew-offline-hangup ()
(interactive)
(let ((pplst (list mew-smtp-process-prefix))) ; process prefix list
(if mew-offline-hangup-p
(progn
(catch 'loop
(while pplst
(if (mew-offline-process-match (format "%s*" (car pplst)))
(throw 'loop t)
(setq pplst (cdr pplst)))))
(if (not pplst)
(progn
(rascon-generate-entry-table)
(if rascon-mode-indicator
(rascon-hangup))))))))
;; flush queue if status is online
(defun mew-offline-summary-send-message ()
(interactive)
(mew-offline-dialup)
(if (not mew-offline-use-rascon)
(mew-summary-send-message)
(if rascon-mode-indicator
(mew-summary-send-message)))
(mew-offline-hangup))
;; for mew-win32-mvm
(if mew-offline-use-mvm-p
(progn
(require 'mew-win32-mvm)
(if (boundp 'mew-win32-mvm-finish-hook)
(add-hook 'mew-win32-mvm-finish-hook 'mew-offline-hangup))))
;; dial-up, message get/put
(defun mew-offline-summary-get (&optional arg)
(interactive "P")
(mew-offline-dialup)
(if (not mew-offline-use-rascon)
(if mew-offline-use-mvm-p
(mew-win32-mvm-get arg)
(mew-summary-get arg))
(if rascon-mode-indicator
(if mew-offline-use-mvm-p
(mew-win32-mvm-get arg)
(mew-summary-get arg)))))
(provide 'mew-offline)
;;; Copyright Notice:
;; Copyright (C) 1998, 1999, 2000 Shuichi Kitaguchi <kit at example.com>
;; All rights reserved.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; 1. Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;; 2. Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; 3. Neither the name of the team nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; mew-offline.el ends here
-------------- next part --------------
Index: mew-smtp.el
===================================================================
RCS file: /usr/local/cvsroot/mew/mew-smtp.el,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 mew-smtp.el
--- mew-smtp.el 2000/04/13 13:02:09 1.1.1.3
+++ mew-smtp.el 2000/04/16 10:13:56
@@ -198,7 +198,8 @@
(if flushp
(progn
(message "Flushing %s ... " qfld)
- (mew-smtp-send-message)))))))
+ (mew-smtp-send-message))
+ (run-hooks 'mew-smtp-flush-hook))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@@ -259,7 +260,8 @@
(mew-smtp-set-error pnm nil)
(mew-smtp-set-lock pnm nil)
(if (processp sshpro) (delete-process sshpro))
- (mew-smtp-set-ssh-process pnm nil)))
+ (mew-smtp-set-ssh-process pnm nil)
+ (run-hooks 'mew-smtp-flush-hook)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Index: mew-vars.el
===================================================================
RCS file: /usr/local/cvsroot/mew/mew-vars.el,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 mew-vars.el
--- mew-vars.el 2000/04/13 13:02:09 1.1.1.3
+++ mew-vars.el 2000/04/16 10:14:06
@@ -286,6 +286,8 @@
(defvar mew-smtp-server "localhost")
(defvar mew-smtp-port "smtp")
+(defvar mew-smtp-flush-hook nil)
+
(defvar mew-smtp-ssh-server nil)
(defvar mew-smtp-keep-connection nil
Mew-win32 メーリングリストの案内