(defvar my-wl-fetchmail-proc nil) (defun my-wl-fetchmail () (interactive) (let* ((process-environment (copy-sequence process-environment)) (buffer-to-select (or (get-buffer-window "Folder") (get-buffer-window "Summary")))) (setenv "LANG" "C") (if buffer-to-select (select-window buffer-to-select)) (if (and my-wl-fetchmail-proc (eq (process-status my-wl-fetchmail-proc) 'run)) (progn (delete-process my-wl-fetchmail-proc) (message "fetchmail process killed!")) (progn (message "Getting by fetchmail...") (setq my-wl-fetchmail-proc (start-process "fetchmail" "*fetchmail*" "fetchmail")) (set-process-coding-system my-wl-fetchmail-proc 'undecided-dos 'sjis-unix) (set-process-filter my-wl-fetchmail-proc 'my-wl-fetchmail-proc-filter) (set-process-sentinel my-wl-fetchmail-proc 'my-wl-fetchmail-proc-sentinel)) ))) (defun my-wl-fetchmail-proc-filter (proc string) (let ((buffer (process-buffer proc))) (set-buffer buffer) (insert string) (if (or (string-match "^reading message.*" string) (string-match "^fetchmail:.*" string)) (message (substring string (match-beginning 0) (match-end 0)))) )) (defun my-wl-fetchmail-proc-sentinel (proc string) (let ((buffer (process-buffer proc))) (set-buffer buffer) (insert string) (if (memq (process-status proc) '(signal exit)) (progn (if (= 0 (process-exit-status proc)) (prom-wl)) ;; need procmail/prom-wl (setq my-wl-fetchmail-proc nil))) )) (add-hook 'wl-folder-mode-hook (lambda () (define-key wl-folder-mode-map [(shift ?g)] 'my-wl-fetchmail) (define-key wl-summary-mode-map [(shift ?g)] 'my-wl-fetchmail) ))