annotate lisp/efs/efs-vm.el @ 179:9ad43877534d r20-3b16

Import from CVS: tag r20-3b16
author cvs
date Mon, 13 Aug 2007 09:52:19 +0200
parents 8b8b7f3559a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: efs-vm.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
42
8b8b7f3559a2 Import from CVS: tag r19-15b104
cvs
parents: 22
diff changeset
6 ;; Version: #Revision: 1.1 $
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Description: Allows the VM mail reader to access folders using efs.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; If you are looking for support for VM/CMS, see efs-cms.el.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; Author: Sandy Rutherford <sandy@ibm550.sissa.it>
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;; Created: Mon Nov 9 23:49:18 1992 by sandy on riemann
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;; Modified: Sun Nov 27 18:44:07 1994 by sandy on gandalf
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;; If vm-get-new-mail (usually bound to "g") is given a prefix, it
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;; will prompt for a folder from which to collect mail. With
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18 ;; efs-vm, this folder can be in efs syntax. As is usual
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 ;; with VM, this folder will not be deleted. If at the folder prompt,
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 ;; you give "/user@host:", efs-vm will collect mail from the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 ;; spool file on the remote machine. The spool file will be deleted if
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;; the mail is successfully collected. It is not necessary for
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;; movemail, nor even emacs, to be installed on the remote machine.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 ;; The functionality of movemail is mimicked with FTP commands. Both
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;; local and remote crashboxes are used, so that mail will not be lost
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;; if the FTP connection is lost.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 ;; To use efs-vm, put (require 'efs-vm) in your .vm file.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 ;; Works for vm 5.56 through 5.72. May not work with older versions.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 ;; If vm grows some file-name-handler-alist support, we should use it.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 ;; Actually it has. I just haven't gotten around to this yet.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 ;;; Known Bugs:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 ;; 1. efs-vm will not be able to collect mail from a spool file if
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 ;; you do not have write permission in the spool directory.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 ;; I think that this precludes HP-UX.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 ;; I hope to do something about this.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 ;; 2. efs-vm is as clever as at can be about spool file locking.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 ;; i.e. not very clever at all. At least it uses a rename command
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 ;; to minimize the window for problems. Use POP if you want to
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 ;; be careful.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 ;;; Provisions, requirements, and autoloads
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (provide 'efs-vm)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 (require 'efs-cu)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 (require 'efs-ovwrt)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 (require 'vm)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 ;(require 'vm-folder) ; not provided
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 (if (or (not (fboundp 'vm-get-new-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 (eq (car-safe (symbol-function 'vm-get-new-mail)) 'autoload))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 (load-library "vm-folder"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 (autoload 'efs-make-tmp-name "efs")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (autoload 'efs-del-tmp-name "efs")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (autoload 'efs-send-cmd "efs")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (autoload 'efs-re-read-dir "efs")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (autoload 'efs-copy-file-internal "efs")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 ;;; User variables
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (defvar efs-vm-spool-files nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 "Association list of \( USER@MACHINE . SPOOLFILES \) pairs that
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 specify the location of the default remote spool file for MACHINE. SPOOLFILES
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 is a list of remote spool files.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 (defvar efs-vm-crash-box "~/EFS.INBOX.CRASH"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 "Local file where efs keeps its local crash boxes.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 ;;; Internal variables
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 (defconst efs-vm-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 (concat (substring "$efs release: 1.15 $" 14 -2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 "/"
42
8b8b7f3559a2 Import from CVS: tag r19-15b104
cvs
parents: 22
diff changeset
78 (substring "#Revision: 1.1 $" 11 -2)))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 (defun efs-vm-get-new-mail (&optional arg)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 "Documented as original"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (interactive "P")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (vm-select-folder-buffer)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 (vm-check-for-killed-summary)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 (vm-error-if-virtual-folder)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (vm-error-if-folder-read-only)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 (cond
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 ((null arg)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (if (not (eq major-mode 'vm-mode))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (vm-mode))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (if (consp (car (vm-spool-files)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (message "Checking for new mail for %s..." buffer-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (message "Checking for new mail..."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (let (new-messages totals-blurb)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 (if (and (vm-get-spooled-mail)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 (setq new-messages (vm-assimilate-new-messages t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (if vm-arrived-message-hook
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (while new-messages
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (vm-run-message-hook (car new-messages)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 'vm-arrived-message-hook)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 (setq new-messages (cdr new-messages))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 ;; say this NOW, before the non-previewers read
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 ;; a message, alter the new message count and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 ;; confuse themselves.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (setq totals-blurb (vm-emit-totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (if (vm-thoughtfully-select-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (vm-preview-current-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (vm-update-summary-and-mode-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (message totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (if (consp (car (vm-spool-files)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (message "No new mail for %s" buffer-file-name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (message "No new mail."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (sit-for 4)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 (message ""))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 (let* ((buffer-read-only nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 (folder (read-file-name "Gather mail from folder: "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 vm-folder-directory t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (parsed (efs-ftp-path folder))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 mcount new-messages totals-blurb)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124 (if parsed
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 (if (string-equal (nth 2 parsed) "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126 ;; a spool file
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 (if (not (and (efs-vm-get-remote-spooled-mail folder)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (setq new-messages
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129 (vm-assimilate-new-messages t))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (message
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 "No new mail, or mail couldn't be retrieved by ftp.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 ;; don't let this message stay up forever...
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (sit-for 4)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 (message ""))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (if vm-arrived-message-hook
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 (while new-messages
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 (vm-run-message-hook (car new-messages)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 'vm-arrived-message-hook)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (setq new-messages (cdr new-messages))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 ;; say this NOW, before the non-previewers read
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 ;; a message, alter the new message count and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 ;; confuse themselves.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 (setq totals-blurb (vm-emit-totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 (if (vm-thoughtfully-select-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 (vm-preview-current-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 (vm-update-summary-and-mode-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 (message totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 ;; a remote folder
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 (let ((tmp-file (car (efs-make-tmp-name nil (car parsed))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 (folder (expand-file-name folder)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 (efs-copy-file-internal
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157 folder parsed tmp-file nil t nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 (format "Getting %s" folder)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
159 ;; asynch worries me here
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
160 nil nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
161 (if (and vm-check-folder-types
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
162 (not (vm-compatible-folder-p tmp-file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
163 (error
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
164 "Folder %s is not the same format as this folder."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
165 folder))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
166 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
167 (vm-save-restriction
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
168 (widen)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
169 (goto-char (point-max))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
170 (insert-file-contents tmp-file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
171 (setq mcount (length vm-message-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
172 (if (setq new-messages (vm-assimilate-new-messages))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
173 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
174 (if vm-arrived-message-hook
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
175 (while new-messages
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
176 (vm-run-message-hook (car new-messages)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
177 'vm-arrived-message-hook)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
178 (setq new-messages (cdr new-messages))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
179 ;; say this NOW, before the non-previewers read
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
180 ;; a message, alter the new message count and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
181 ;; confuse themselves.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
182 (setq totals-blurb (vm-emit-totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
183 (vm-display nil nil '(vm-get-new-mail)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
184 '(vm-get-new-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
185 (if (vm-thoughtfully-select-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
186 (vm-preview-current-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
187 (vm-update-summary-and-mode-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
188 (message totals-blurb)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
189 ;; The gathered messages are actually still on disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
190 ;; unless the user deletes the folder himself.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
191 ;; However, users may not understand what happened if
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
192 ;; the messages go away after a "quit, no save".
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
193 (setq vm-messages-not-on-disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
194 (+ vm-messages-not-on-disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
195 (- (length vm-message-list)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
196 mcount))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
197 (message "No messages gathered."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
198 (efs-del-tmp-name tmp-file)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
199
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
200 ;; local
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
201
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
202 (if (and vm-check-folder-types
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
203 (not (vm-compatible-folder-p folder)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
204 (error "Folder %s is not the same format as this folder."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
205 folder))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
206 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
207 (vm-save-restriction
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
208 (widen)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
209 (goto-char (point-max))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
210 (insert-file-contents folder)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
211 (setq mcount (length vm-message-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
212 (if (setq new-messages (vm-assimilate-new-messages))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
213 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
214 (if vm-arrived-message-hook
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
215 (while new-messages
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
216 (vm-run-message-hook (car new-messages)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
217 'vm-arrived-message-hook)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
218 (setq new-messages (cdr new-messages))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
219 ;; say this NOW, before the non-previewers read
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
220 ;; a message, alter the new message count and
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
221 ;; confuse themselves.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
222 (setq totals-blurb (vm-emit-totals-blurb))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
223 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
224 (if (vm-thoughtfully-select-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
225 (vm-preview-current-message)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
226 (vm-update-summary-and-mode-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
227 (message totals-blurb)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
228 ;; The gathered messages are actually still on disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
229 ;; unless the user deletes the folder himself.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
230 ;; However, users may not understand what happened if
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
231 ;; the messages go away after a "quit, no save".
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
232 (setq vm-messages-not-on-disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
233 (+ vm-messages-not-on-disk
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
234 (- (length vm-message-list)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
235 mcount))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
236 (message "No messages gathered.")))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
237
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
238 (defun efs-vm-gobble-remote-crash-box (remote-crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
239 (let ((remote-crash-box (expand-file-name remote-crash-box))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
240 (crash-box (expand-file-name efs-vm-crash-box))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
241 lsize)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
242 (if (file-exists-p vm-crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
243 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
244 ;; This should never happen, but let's make sure that we never
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
245 ;; clobber mail.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
246 (message "Recovering messages from local crash box...")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
247 (vm-gobble-crash-box efs-vm-crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
248 (message "Recovering messages from local crash box... done")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
249 (efs-copy-file-internal remote-crash-box (efs-ftp-path remote-crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
250 crash-box nil nil nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
251 (format "Getting %s" remote-crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
252 ;; asynch worries me here
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
253 nil nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
254 ;; only delete the remote crash box if we are sure that we have everything
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
255 (if (and (setq lsize (nth 7 (file-attributes crash-box)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
256 (eq lsize (nth 7 (file-attributes remote-crash-box)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
257 (vm-compatible-folder-p crash-box))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
258 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
259 (vm-gobble-crash-box crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
260 (delete-file remote-crash-box))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
261 ;; don't leave garbage in the local crash box
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
262 (condition-case () (delete-file crash-box) (error nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
263 (error "Problem reading remote crash box %s" remote-crash-box))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
264
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
265 (defun efs-vm-get-remote-spooled-mail (remote-path)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
266 ;; remote-path is usually of the form /user@machine:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
267 ;; Usually vm sets inhibit-quit to t for this. This is probably
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
268 ;; a bad idea if there is ftp activity.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
269 ;; I don't want to assume that the remote machine has movemail.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
270 ;; Try to mimic movemail with ftp commands as best as possible.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
271 ;; For this to work, we need to be able to create a subdirectory
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
272 ;; in the spool directory.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
273 (if vm-block-new-mail
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
274 (error "Can't get new mail until you save this folder."))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
275 (let* ((parsed (efs-ftp-path remote-path))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
276 (host (car parsed))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
277 (user (nth 1 parsed))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
278 (spool-files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
279 (or (cdr (assoc (concat user "@" host)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
280 efs-vm-spool-files))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
281 (list (concat "/usr/spool/mail/" user))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
282 got-mail)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
283 (while spool-files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
284 (let* ((s-file (car spool-files))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
285 (spool-file (format efs-path-format-string user host s-file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
286 ;; rmdir and mkdir bomb if this path ends in a /.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
287 (c-dir (concat s-file ".CRASHBOX"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
288 (rc-file (concat c-dir "/CRASHBOX"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
289 (crash-dir (concat spool-file ".CRASHBOX/"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
290 (remote-crash-file (concat crash-dir "CRASHBOX"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
291 (crash-box (expand-file-name efs-vm-crash-box)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
292 (if (file-exists-p crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
293 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
294 (message "Recovering messages from crash box...")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
295 (vm-gobble-crash-box crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
296 (message "Recovering messages from crash box... done")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
297 (setq got-mail t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
298 (if (let ((efs-allow-child-lookup nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
299 (file-exists-p remote-crash-file))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
300 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
301 (message "Recovering messages from remote crash box...")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
302 (efs-vm-gobble-remote-crash-box remote-crash-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
303 (message "Recovering messages from remote crash box... done")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
304 (setq got-mail t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
305 (if (file-exists-p crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
306 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
307 (message "Recovering messages from crash box...")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
308 (vm-gobble-crash-box crash-box)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
309 (message "Recovering messages from crash box... done")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
310 (setq got-mail t)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
311 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
312 (if (car
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
313 (efs-send-cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
314 host user (list 'mkdir c-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
315 (format "Making crash directory %s" crash-dir)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
316 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
317 (efs-re-read-dir crash-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
318 (message "Unable to make crash directory %s" crash-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
319 (ding))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
320 (or (car
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
321 (efs-send-cmd host user (list 'rename s-file rc-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
322 (format "Checking spool file %s" spool-file)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
323 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
324 (message "Getting new mail from %s..." spool-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
325 ;; The rename above wouldn't have updated the cash.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
326 (efs-re-read-dir crash-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
327 (efs-vm-gobble-remote-crash-box remote-crash-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
328 (message "Getting new mail from %s... done" spool-file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
329 (setq got-mail t))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
330 (condition-case nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
331 (efs-send-cmd
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
332 host user (list 'rmdir c-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
333 "Removing crash directory")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
334 (error nil))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
335 (setq spool-files (cdr spool-files)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
336 got-mail))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
337
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
338 ;;; Overwrite existing functions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
339
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
340 (efs-overwrite-fn "efs" 'vm-get-new-mail)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
341
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
342 ;;; end of efs-vm.el