1 |
;;; nndraft.el --- draft article access for Gnus |
;;; nndraft.el --- draft article access for Gnus |
2 |
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 |
|
3 |
|
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003 |
4 |
;; Free Software Foundation, Inc. |
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
33 |
(require 'nnmh) |
(require 'nnmh) |
34 |
(require 'nnoo) |
(require 'nnoo) |
35 |
(require 'mm-util) |
(require 'mm-util) |
36 |
(eval-when-compile |
(eval-when-compile (require 'cl)) |
|
(require 'cl) |
|
|
;; This is just to shut up the byte-compiler. |
|
|
(fset 'nndraft-request-group 'ignore)) |
|
37 |
|
|
38 |
(nnoo-declare nndraft |
(nnoo-declare nndraft |
39 |
nnmh) |
nnmh) |
111 |
(when (and (file-exists-p newest) |
(when (and (file-exists-p newest) |
112 |
(let ((nnmail-file-coding-system |
(let ((nnmail-file-coding-system |
113 |
(if (file-newer-than-file-p file auto) |
(if (file-newer-than-file-p file auto) |
114 |
(if (equal group "drafts") |
(if (member group '("drafts" "delayed")) |
115 |
message-draft-coding-system |
message-draft-coding-system |
116 |
mm-text-coding-system) |
mm-text-coding-system) |
117 |
mm-auto-save-coding-system))) |
mm-auto-save-coding-system))) |
122 |
;; If there's a mail header separator in this file, |
;; If there's a mail header separator in this file, |
123 |
;; we remove it. |
;; we remove it. |
124 |
(when (re-search-forward |
(when (re-search-forward |
125 |
(concat "^" mail-header-separator "$") nil t) |
(concat "^" (regexp-quote mail-header-separator) "$") nil t) |
126 |
(replace-match "" t t))) |
(replace-match "" t t))) |
127 |
t)))) |
t)))) |
128 |
|
|
132 |
(when (nndraft-request-article article group server (current-buffer)) |
(when (nndraft-request-article article group server (current-buffer)) |
133 |
(message-remove-header "xref") |
(message-remove-header "xref") |
134 |
(message-remove-header "lines") |
(message-remove-header "lines") |
135 |
|
;; Articles in nndraft:queue are considered as sent messages. The |
136 |
|
;; Date field should be the time when they are sent. |
137 |
|
;;(message-remove-header "date") |
138 |
t)) |
t)) |
139 |
|
|
140 |
(deffoo nndraft-request-update-info (group info &optional server) |
(deffoo nndraft-request-update-info (group info &optional server) |
152 |
nil)))) |
nil)))) |
153 |
t) |
t) |
154 |
|
|
155 |
|
(defun nndraft-generate-headers () |
156 |
|
(save-excursion |
157 |
|
(message-generate-headers |
158 |
|
(message-headers-to-generate |
159 |
|
message-required-headers message-draft-headers nil)))) |
160 |
|
|
161 |
(deffoo nndraft-request-associate-buffer (group) |
(deffoo nndraft-request-associate-buffer (group) |
162 |
"Associate the current buffer with some article in the draft group." |
"Associate the current buffer with some article in the draft group." |
163 |
(nndraft-open-server "") |
(nndraft-open-server "") |
174 |
(setq buffer-file-name (expand-file-name file) |
(setq buffer-file-name (expand-file-name file) |
175 |
buffer-auto-save-file-name (make-auto-save-file-name)) |
buffer-auto-save-file-name (make-auto-save-file-name)) |
176 |
(clear-visited-file-modtime) |
(clear-visited-file-modtime) |
177 |
|
(make-local-variable 'write-contents-hooks) |
178 |
|
(push 'nndraft-generate-headers write-contents-hooks) |
179 |
article)) |
article)) |
180 |
|
|
181 |
|
(deffoo nndraft-request-group (group &optional server dont-check) |
182 |
|
(nndraft-possibly-change-group group) |
183 |
|
(unless dont-check |
184 |
|
(let* ((pathname (nnmail-group-pathname group nndraft-directory)) |
185 |
|
(file-name-coding-system nnmail-pathname-coding-system) |
186 |
|
dir file) |
187 |
|
(nnheader-re-read-dir pathname) |
188 |
|
(setq dir (mapcar (lambda (name) (string-to-int (substring name 1))) |
189 |
|
(ignore-errors (directory-files |
190 |
|
pathname nil "^#[0-9]+#$" t)))) |
191 |
|
(dolist (n dir) |
192 |
|
(unless (file-exists-p |
193 |
|
(setq file (expand-file-name (int-to-string n) pathname))) |
194 |
|
(rename-file (nndraft-auto-save-file-name file) file))))) |
195 |
|
(nnoo-parent-function 'nndraft |
196 |
|
'nnmh-request-group |
197 |
|
(list group server dont-check))) |
198 |
|
|
199 |
|
(deffoo nndraft-request-move-article (article group server |
200 |
|
accept-form &optional last) |
201 |
|
(nndraft-possibly-change-group group) |
202 |
|
(let ((buf (get-buffer-create " *nndraft move*")) |
203 |
|
result) |
204 |
|
(and |
205 |
|
(nndraft-request-article article group server) |
206 |
|
(save-excursion |
207 |
|
(set-buffer buf) |
208 |
|
(erase-buffer) |
209 |
|
(insert-buffer-substring nntp-server-buffer) |
210 |
|
(setq result (eval accept-form)) |
211 |
|
(kill-buffer (current-buffer)) |
212 |
|
result) |
213 |
|
(null (nndraft-request-expire-articles (list article) group server 'force)) |
214 |
|
result))) |
215 |
|
|
216 |
(deffoo nndraft-request-expire-articles (articles group &optional server force) |
(deffoo nndraft-request-expire-articles (articles group &optional server force) |
217 |
(nndraft-possibly-change-group group) |
(nndraft-possibly-change-group group) |
218 |
(let* ((nnmh-allow-delete-final t) |
(let* ((nnmh-allow-delete-final t) |
245 |
(deffoo nndraft-request-replace-article (article group buffer) |
(deffoo nndraft-request-replace-article (article group buffer) |
246 |
(nndraft-possibly-change-group group) |
(nndraft-possibly-change-group group) |
247 |
(let ((nnmail-file-coding-system |
(let ((nnmail-file-coding-system |
248 |
(if (equal group "drafts") |
(if (member group '("drafts" "delayed")) |
249 |
mm-auto-save-coding-system |
message-draft-coding-system |
250 |
mm-text-coding-system))) |
mm-text-coding-system))) |
251 |
(nnoo-parent-function 'nndraft 'nnmh-request-replace-article |
(nnoo-parent-function 'nndraft 'nnmh-request-replace-article |
252 |
(list article group buffer)))) |
(list article group buffer)))) |
303 |
nnmh-request-group |
nnmh-request-group |
304 |
nnmh-close-group |
nnmh-close-group |
305 |
nnmh-request-list |
nnmh-request-list |
306 |
nnmh-request-newsgroups |
nnmh-request-newsgroups)) |
|
nnmh-request-move-article)) |
|
307 |
|
|
308 |
(provide 'nndraft) |
(provide 'nndraft) |
309 |
|
|