Mercurial > emacs
comparison lisp/gnus/nnml.el @ 31716:9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 19 Sep 2000 13:37:09 +0000 |
parents | 15fc6acbae7a |
children | c47be4412cfd |
comparison
equal
deleted
inserted
replaced
31715:7c896543d225 | 31716:9968f55ad26e |
---|---|
1 ;;; nnml.el --- mail spool access for Gnus | 1 ;;; nnml.el --- mail spool access for Gnus |
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc. | 2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 |
3 ;; Free Software Foundation, Inc. | |
3 | 4 |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | 5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
5 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | 6 ;; Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> |
6 ;; Keywords: news, mail | 7 ;; Keywords: news, mail |
7 | 8 |
39 | 40 |
40 (defvoo nnml-directory message-directory | 41 (defvoo nnml-directory message-directory |
41 "Spool directory for the nnml mail backend.") | 42 "Spool directory for the nnml mail backend.") |
42 | 43 |
43 (defvoo nnml-active-file | 44 (defvoo nnml-active-file |
44 (concat (file-name-as-directory nnml-directory) "active") | 45 (expand-file-name "active" nnml-directory) |
45 "Mail active file.") | 46 "Mail active file.") |
46 | 47 |
47 (defvoo nnml-newsgroups-file | 48 (defvoo nnml-newsgroups-file |
48 (concat (file-name-as-directory nnml-directory) "newsgroups") | 49 (expand-file-name "newsgroups" nnml-directory) |
49 "Mail newsgroups description file.") | 50 "Mail newsgroups description file.") |
50 | 51 |
51 (defvoo nnml-get-new-mail t | 52 (defvoo nnml-get-new-mail t |
52 "If non-nil, nnml will check the incoming mail file and split the mail.") | 53 "If non-nil, nnml will check the incoming mail file and split the mail.") |
53 | 54 |
84 | 85 |
85 (defvoo nnml-generate-active-function 'nnml-generate-active-info) | 86 (defvoo nnml-generate-active-function 'nnml-generate-active-info) |
86 | 87 |
87 (defvar nnml-nov-buffer-file-name nil) | 88 (defvar nnml-nov-buffer-file-name nil) |
88 | 89 |
90 (defvoo nnml-file-coding-system nnmail-file-coding-system) | |
91 | |
89 | 92 |
90 | 93 |
91 ;;; Interface functions. | 94 ;;; Interface functions. |
92 | 95 |
93 (nnoo-define-basics nnml) | 96 (nnoo-define-basics nnml) |
98 (set-buffer nntp-server-buffer) | 101 (set-buffer nntp-server-buffer) |
99 (erase-buffer) | 102 (erase-buffer) |
100 (let ((file nil) | 103 (let ((file nil) |
101 (number (length sequence)) | 104 (number (length sequence)) |
102 (count 0) | 105 (count 0) |
103 (file-name-coding-system 'binary) | 106 (file-name-coding-system nnmail-pathname-coding-system) |
104 (pathname-coding-system 'binary) | |
105 beg article) | 107 beg article) |
106 (if (stringp (car sequence)) | 108 (if (stringp (car sequence)) |
107 'headers | 109 'headers |
108 (if (nnml-retrieve-headers-with-nov sequence fetch-old) | 110 (if (nnml-retrieve-headers-with-nov sequence fetch-old) |
109 'nov | 111 'nov |
139 'headers)))))) | 141 'headers)))))) |
140 | 142 |
141 (deffoo nnml-open-server (server &optional defs) | 143 (deffoo nnml-open-server (server &optional defs) |
142 (nnoo-change-server 'nnml server defs) | 144 (nnoo-change-server 'nnml server defs) |
143 (when (not (file-exists-p nnml-directory)) | 145 (when (not (file-exists-p nnml-directory)) |
144 (condition-case () | 146 (ignore-errors (make-directory nnml-directory t))) |
145 (make-directory nnml-directory t) | |
146 (error))) | |
147 (cond | 147 (cond |
148 ((not (file-exists-p nnml-directory)) | 148 ((not (file-exists-p nnml-directory)) |
149 (nnml-close-server) | 149 (nnml-close-server) |
150 (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory)) | 150 (nnheader-report 'nnml "Couldn't create directory: %s" nnml-directory)) |
151 ((not (file-directory-p (file-truename nnml-directory))) | 151 ((not (file-directory-p (file-truename nnml-directory))) |
162 t) | 162 t) |
163 | 163 |
164 (deffoo nnml-request-article (id &optional group server buffer) | 164 (deffoo nnml-request-article (id &optional group server buffer) |
165 (nnml-possibly-change-directory group server) | 165 (nnml-possibly-change-directory group server) |
166 (let* ((nntp-server-buffer (or buffer nntp-server-buffer)) | 166 (let* ((nntp-server-buffer (or buffer nntp-server-buffer)) |
167 (file-name-coding-system 'binary) | 167 (file-name-coding-system nnmail-pathname-coding-system) |
168 (pathname-coding-system 'binary) | |
169 path gpath group-num) | 168 path gpath group-num) |
170 (if (stringp id) | 169 (if (stringp id) |
171 (when (and (setq group-num (nnml-find-group-number id)) | 170 (when (and (setq group-num (nnml-find-group-number id)) |
172 (cdr | 171 (cdr |
173 (assq (cdr group-num) | 172 (assq (cdr group-num) |
183 (nnheader-report 'nnml "No such article: %s" id)) | 182 (nnheader-report 'nnml "No such article: %s" id)) |
184 ((not (file-exists-p path)) | 183 ((not (file-exists-p path)) |
185 (nnheader-report 'nnml "No such file: %s" path)) | 184 (nnheader-report 'nnml "No such file: %s" path)) |
186 ((file-directory-p path) | 185 ((file-directory-p path) |
187 (nnheader-report 'nnml "File is a directory: %s" path)) | 186 (nnheader-report 'nnml "File is a directory: %s" path)) |
188 ((not (save-excursion (nnmail-find-file path))) | 187 ((not (save-excursion (let ((nnmail-file-coding-system |
188 nnml-file-coding-system)) | |
189 (nnmail-find-file path)))) | |
189 (nnheader-report 'nnml "Couldn't read file: %s" path)) | 190 (nnheader-report 'nnml "Couldn't read file: %s" path)) |
190 (t | 191 (t |
191 (nnheader-report 'nnml "Article %s retrieved" id) | 192 (nnheader-report 'nnml "Article %s retrieved" id) |
192 ;; We return the article number. | 193 ;; We return the article number. |
193 (cons (if group-num (car group-num) group) | 194 (cons (if group-num (car group-num) group) |
194 (string-to-int (file-name-nondirectory path))))))) | 195 (string-to-int (file-name-nondirectory path))))))) |
195 | 196 |
196 (deffoo nnml-request-group (group &optional server dont-check) | 197 (deffoo nnml-request-group (group &optional server dont-check) |
197 (let ((pathname-coding-system 'binary) | 198 (let ((file-name-coding-system nnmail-pathname-coding-system)) |
198 (file-name-coding-system 'binary)) | |
199 (cond | 199 (cond |
200 ((not (nnml-possibly-change-directory group server)) | 200 ((not (nnml-possibly-change-directory group server)) |
201 (nnheader-report 'nnml "Invalid group (no such directory)")) | 201 (nnheader-report 'nnml "Invalid group (no such directory)")) |
202 ((not (file-exists-p nnml-current-directory)) | 202 ((not (file-exists-p nnml-current-directory)) |
203 (nnheader-report 'nnml "Directory %s does not exist" | 203 (nnheader-report 'nnml "Directory %s does not exist" |
226 (deffoo nnml-close-group (group &optional server) | 226 (deffoo nnml-close-group (group &optional server) |
227 (setq nnml-article-file-alist nil) | 227 (setq nnml-article-file-alist nil) |
228 t) | 228 t) |
229 | 229 |
230 (deffoo nnml-request-create-group (group &optional server args) | 230 (deffoo nnml-request-create-group (group &optional server args) |
231 (nnml-possibly-change-directory nil server) | |
231 (nnmail-activate 'nnml) | 232 (nnmail-activate 'nnml) |
232 (cond | 233 (cond |
233 ((assoc group nnml-group-alist) | 234 ((assoc group nnml-group-alist) |
234 t) | 235 t) |
235 ((and (file-exists-p (nnmail-group-pathname group nnml-directory)) | 236 ((and (file-exists-p (nnmail-group-pathname group nnml-directory)) |
250 t)))) | 251 t)))) |
251 | 252 |
252 (deffoo nnml-request-list (&optional server) | 253 (deffoo nnml-request-list (&optional server) |
253 (save-excursion | 254 (save-excursion |
254 (let ((nnmail-file-coding-system nnmail-active-file-coding-system) | 255 (let ((nnmail-file-coding-system nnmail-active-file-coding-system) |
255 (file-name-coding-system 'binary) | 256 (file-name-coding-system nnmail-pathname-coding-system)) |
256 (pathname-coding-system 'binary)) | 257 (nnmail-find-file nnml-active-file)) |
257 (nnmail-find-file nnml-active-file) | |
258 ) | |
259 (setq nnml-group-alist (nnmail-get-active)) | 258 (setq nnml-group-alist (nnmail-get-active)) |
260 t)) | 259 t)) |
261 | 260 |
262 (deffoo nnml-request-newgroups (date &optional server) | 261 (deffoo nnml-request-newgroups (date &optional server) |
263 (nnml-request-list server)) | 262 (nnml-request-list server)) |
264 | 263 |
265 (deffoo nnml-request-list-newsgroups (&optional server) | 264 (deffoo nnml-request-list-newsgroups (&optional server) |
266 (save-excursion | 265 (save-excursion |
267 (nnmail-find-file nnml-newsgroups-file))) | 266 (nnmail-find-file nnml-newsgroups-file))) |
268 | 267 |
269 (deffoo nnml-request-expire-articles (articles group | 268 (deffoo nnml-request-expire-articles (articles group &optional server force) |
270 &optional server force) | |
271 (nnml-possibly-change-directory group server) | 269 (nnml-possibly-change-directory group server) |
272 (let ((active-articles | 270 (let ((active-articles |
273 (nnheader-directory-articles nnml-current-directory)) | 271 (nnheader-directory-articles nnml-current-directory)) |
274 (is-old t) | 272 (is-old t) |
275 article rest mod-time number) | 273 article rest mod-time number) |
286 (if (and (nnml-deletable-article-p group number) | 284 (if (and (nnml-deletable-article-p group number) |
287 (setq is-old | 285 (setq is-old |
288 (nnmail-expired-article-p group mod-time force | 286 (nnmail-expired-article-p group mod-time force |
289 nnml-inhibit-expiry))) | 287 nnml-inhibit-expiry))) |
290 (progn | 288 (progn |
289 ;; Allow a special target group. | |
290 (unless (eq nnmail-expiry-target 'delete) | |
291 (with-temp-buffer | |
292 (nnml-request-article number group server | |
293 (current-buffer)) | |
294 (let ((nnml-current-directory nil)) | |
295 (nnmail-expiry-target-group | |
296 nnmail-expiry-target group)))) | |
291 (nnheader-message 5 "Deleting article %s in %s" | 297 (nnheader-message 5 "Deleting article %s in %s" |
292 article group) | 298 number group) |
293 (condition-case () | 299 (condition-case () |
294 (funcall nnmail-delete-file-function article) | 300 (funcall nnmail-delete-file-function article) |
295 (file-error | 301 (file-error |
296 (push number rest))) | 302 (push number rest))) |
297 (setq active-articles (delq number active-articles)) | 303 (setq active-articles (delq number active-articles)) |
305 (nnmail-save-active nnml-group-alist nnml-active-file)) | 311 (nnmail-save-active nnml-group-alist nnml-active-file)) |
306 (nnml-save-nov) | 312 (nnml-save-nov) |
307 (nconc rest articles))) | 313 (nconc rest articles))) |
308 | 314 |
309 (deffoo nnml-request-move-article | 315 (deffoo nnml-request-move-article |
310 (article group server accept-form &optional last) | 316 (article group server accept-form &optional last) |
311 (let ((buf (get-buffer-create " *nnml move*")) | 317 (let ((buf (get-buffer-create " *nnml move*")) |
312 result) | 318 result) |
313 (nnml-possibly-change-directory group server) | 319 (nnml-possibly-change-directory group server) |
314 (nnml-update-file-alist) | 320 (nnml-update-file-alist) |
315 (and | 321 (and |
316 (nnml-deletable-article-p group article) | 322 (nnml-deletable-article-p group article) |
317 (nnml-request-article article group server) | 323 (nnml-request-article article group server) |
318 (save-excursion | 324 (let (nnml-current-directory |
319 (set-buffer buf) | 325 nnml-current-group |
320 (insert-buffer-substring nntp-server-buffer) | 326 nnml-article-file-alist) |
321 (setq result (eval accept-form)) | 327 (save-excursion |
322 (kill-buffer (current-buffer)) | 328 (set-buffer buf) |
323 result) | 329 (insert-buffer-substring nntp-server-buffer) |
330 (setq result (eval accept-form)) | |
331 (kill-buffer (current-buffer)) | |
332 result)) | |
324 (progn | 333 (progn |
325 (nnml-possibly-change-directory group server) | 334 (nnml-possibly-change-directory group server) |
326 (condition-case () | 335 (condition-case () |
327 (funcall nnmail-delete-file-function | 336 (funcall nnmail-delete-file-function |
328 (nnml-article-to-file article)) | 337 (nnml-article-to-file article)) |
366 (set-buffer buffer) | 375 (set-buffer buffer) |
367 (nnml-possibly-create-directory group) | 376 (nnml-possibly-create-directory group) |
368 (let ((chars (nnmail-insert-lines)) | 377 (let ((chars (nnmail-insert-lines)) |
369 (art (concat (int-to-string article) "\t")) | 378 (art (concat (int-to-string article) "\t")) |
370 headers) | 379 headers) |
371 (when (condition-case () | 380 (when (ignore-errors |
372 (progn | 381 (nnmail-write-region |
373 (nnmail-write-region | 382 (point-min) (point-max) |
374 (point-min) (point-max) | 383 (or (nnml-article-to-file article) |
375 (or (nnml-article-to-file article) | 384 (expand-file-name (int-to-string article) |
376 (concat nnml-current-directory | 385 nnml-current-directory)) |
377 (int-to-string article))) | 386 nil (if (nnheader-be-verbose 5) nil 'nomesg)) |
378 nil (if (nnheader-be-verbose 5) nil 'nomesg)) | 387 t) |
379 t) | |
380 (error nil)) | |
381 (setq headers (nnml-parse-head chars article)) | 388 (setq headers (nnml-parse-head chars article)) |
382 ;; Replace the NOV line in the NOV file. | 389 ;; Replace the NOV line in the NOV file. |
383 (save-excursion | 390 (save-excursion |
384 (set-buffer (nnml-open-nov group)) | 391 (set-buffer (nnml-open-nov group)) |
385 (goto-char (point-min)) | 392 (goto-char (point-min)) |
416 (setq article (pop articles)) | 423 (setq article (pop articles)) |
417 (when (file-writable-p article) | 424 (when (file-writable-p article) |
418 (nnheader-message 5 "Deleting article %s in %s..." article group) | 425 (nnheader-message 5 "Deleting article %s in %s..." article group) |
419 (funcall nnmail-delete-file-function article)))) | 426 (funcall nnmail-delete-file-function article)))) |
420 ;; Try to delete the directory itself. | 427 ;; Try to delete the directory itself. |
421 (condition-case () | 428 (ignore-errors (delete-directory nnml-current-directory))) |
422 (delete-directory nnml-current-directory) | |
423 (error nil))) | |
424 ;; Remove the group from all structures. | 429 ;; Remove the group from all structures. |
425 (setq nnml-group-alist | 430 (setq nnml-group-alist |
426 (delq (assoc group nnml-group-alist) nnml-group-alist) | 431 (delq (assoc group nnml-group-alist) nnml-group-alist) |
427 nnml-current-group nil | 432 nnml-current-group nil |
428 nnml-current-directory nil) | 433 nnml-current-directory nil) |
432 | 437 |
433 (deffoo nnml-request-rename-group (group new-name &optional server) | 438 (deffoo nnml-request-rename-group (group new-name &optional server) |
434 (nnml-possibly-change-directory group server) | 439 (nnml-possibly-change-directory group server) |
435 (let ((new-dir (nnmail-group-pathname new-name nnml-directory)) | 440 (let ((new-dir (nnmail-group-pathname new-name nnml-directory)) |
436 (old-dir (nnmail-group-pathname group nnml-directory))) | 441 (old-dir (nnmail-group-pathname group nnml-directory))) |
437 (when (condition-case () | 442 (when (ignore-errors |
438 (progn | 443 (make-directory new-dir t) |
439 (make-directory new-dir t) | 444 t) |
440 t) | |
441 (error nil)) | |
442 ;; We move the articles file by file instead of renaming | 445 ;; We move the articles file by file instead of renaming |
443 ;; the directory -- there may be subgroups in this group. | 446 ;; the directory -- there may be subgroups in this group. |
444 ;; One might be more clever, I guess. | 447 ;; One might be more clever, I guess. |
445 (let ((files (nnheader-article-to-file-alist old-dir))) | 448 (let ((files (nnheader-article-to-file-alist old-dir))) |
446 (while files | 449 (while files |
451 ;; Move .overview file. | 454 ;; Move .overview file. |
452 (let ((overview (concat old-dir nnml-nov-file-name))) | 455 (let ((overview (concat old-dir nnml-nov-file-name))) |
453 (when (file-exists-p overview) | 456 (when (file-exists-p overview) |
454 (rename-file overview (concat new-dir nnml-nov-file-name)))) | 457 (rename-file overview (concat new-dir nnml-nov-file-name)))) |
455 (when (<= (length (directory-files old-dir)) 2) | 458 (when (<= (length (directory-files old-dir)) 2) |
456 (condition-case () | 459 (ignore-errors (delete-directory old-dir))) |
457 (delete-directory old-dir) | |
458 (error nil))) | |
459 ;; That went ok, so we change the internal structures. | 460 ;; That went ok, so we change the internal structures. |
460 (let ((entry (assoc group nnml-group-alist))) | 461 (let ((entry (assoc group nnml-group-alist))) |
461 (when entry | 462 (when entry |
462 (setcar entry new-name)) | 463 (setcar entry new-name)) |
463 (setq nnml-current-directory nil | 464 (setq nnml-current-directory nil |
471 (let ((file (nnml-article-to-file article))) | 472 (let ((file (nnml-article-to-file article))) |
472 (cond | 473 (cond |
473 ((not (file-exists-p file)) | 474 ((not (file-exists-p file)) |
474 (nnheader-report 'nnml "File %s does not exist" file)) | 475 (nnheader-report 'nnml "File %s does not exist" file)) |
475 (t | 476 (t |
476 (nnheader-temp-write file | 477 (with-temp-file file |
477 (nnheader-insert-file-contents file) | 478 (nnheader-insert-file-contents file) |
478 (nnmail-replace-status name value)) | 479 (nnmail-replace-status name value)) |
479 t)))) | 480 t)))) |
480 | 481 |
481 | 482 |
483 | 484 |
484 (defun nnml-article-to-file (article) | 485 (defun nnml-article-to-file (article) |
485 (nnml-update-file-alist) | 486 (nnml-update-file-alist) |
486 (let (file) | 487 (let (file) |
487 (if (setq file (cdr (assq article nnml-article-file-alist))) | 488 (if (setq file (cdr (assq article nnml-article-file-alist))) |
488 (concat nnml-current-directory file) | 489 (expand-file-name file nnml-current-directory) |
489 ;; Just to make sure nothing went wrong when reading over NFS -- | 490 ;; Just to make sure nothing went wrong when reading over NFS -- |
490 ;; check once more. | 491 ;; check once more. |
491 (when (file-exists-p | 492 (when (file-exists-p |
492 (setq file (expand-file-name (number-to-string article) | 493 (setq file (expand-file-name (number-to-string article) |
493 nnml-current-directory))) | 494 nnml-current-directory))) |
505 | 506 |
506 ;; Find an article number in the current group given the Message-ID. | 507 ;; Find an article number in the current group given the Message-ID. |
507 (defun nnml-find-group-number (id) | 508 (defun nnml-find-group-number (id) |
508 (save-excursion | 509 (save-excursion |
509 (set-buffer (get-buffer-create " *nnml id*")) | 510 (set-buffer (get-buffer-create " *nnml id*")) |
510 (buffer-disable-undo (current-buffer)) | |
511 (let ((alist nnml-group-alist) | 511 (let ((alist nnml-group-alist) |
512 number) | 512 number) |
513 ;; We want to look through all .overview files, but we want to | 513 ;; We want to look through all .overview files, but we want to |
514 ;; start with the one in the current directory. It seems most | 514 ;; start with the one in the current directory. It seems most |
515 ;; likely that the article we are looking for is in that group. | 515 ;; likely that the article we are looking for is in that group. |
525 (and number | 525 (and number |
526 (cons (caar alist) number)))))) | 526 (cons (caar alist) number)))))) |
527 | 527 |
528 (defun nnml-find-id (group id) | 528 (defun nnml-find-id (group id) |
529 (erase-buffer) | 529 (erase-buffer) |
530 (let ((nov (concat (nnmail-group-pathname group nnml-directory) | 530 (let ((nov (expand-file-name nnml-nov-file-name |
531 nnml-nov-file-name)) | 531 (nnmail-group-pathname group nnml-directory))) |
532 number found) | 532 number found) |
533 (when (file-exists-p nov) | 533 (when (file-exists-p nov) |
534 (nnheader-insert-file-contents nov) | 534 (nnheader-insert-file-contents nov) |
535 (while (and (not found) | 535 (while (and (not found) |
536 (search-forward id nil t)) ; We find the ID. | 536 (search-forward id nil t)) ; We find the ID. |
540 (forward-line 1) | 540 (forward-line 1) |
541 (beginning-of-line) | 541 (beginning-of-line) |
542 (setq found t) | 542 (setq found t) |
543 ;; We return the article number. | 543 ;; We return the article number. |
544 (setq number | 544 (setq number |
545 (condition-case () | 545 (ignore-errors (read (current-buffer)))))) |
546 (read (current-buffer)) | |
547 (error nil))))) | |
548 number))) | 546 number))) |
549 | 547 |
550 (defun nnml-retrieve-headers-with-nov (articles &optional fetch-old) | 548 (defun nnml-retrieve-headers-with-nov (articles &optional fetch-old) |
551 (if (or gnus-nov-is-evil nnml-nov-is-evil) | 549 (if (or gnus-nov-is-evil nnml-nov-is-evil) |
552 nil | 550 nil |
553 (let ((nov (concat nnml-current-directory nnml-nov-file-name))) | 551 (let ((nov (expand-file-name nnml-nov-file-name nnml-current-directory))) |
554 (when (file-exists-p nov) | 552 (when (file-exists-p nov) |
555 (save-excursion | 553 (save-excursion |
556 (set-buffer nntp-server-buffer) | 554 (set-buffer nntp-server-buffer) |
557 (erase-buffer) | 555 (erase-buffer) |
558 (nnheader-insert-file-contents nov) | 556 (nnheader-insert-file-contents nov) |
570 (not (nnml-server-opened server))) | 568 (not (nnml-server-opened server))) |
571 (nnml-open-server server)) | 569 (nnml-open-server server)) |
572 (if (not group) | 570 (if (not group) |
573 t | 571 t |
574 (let ((pathname (nnmail-group-pathname group nnml-directory)) | 572 (let ((pathname (nnmail-group-pathname group nnml-directory)) |
575 (file-name-coding-system 'binary) | 573 (file-name-coding-system nnmail-pathname-coding-system)) |
576 (pathname-coding-system 'binary)) | |
577 (when (not (equal pathname nnml-current-directory)) | 574 (when (not (equal pathname nnml-current-directory)) |
578 (setq nnml-current-directory pathname | 575 (setq nnml-current-directory pathname |
579 nnml-current-group group | 576 nnml-current-group group |
580 nnml-article-file-alist nil)) | 577 nnml-article-file-alist nil)) |
581 (file-exists-p nnml-current-directory)))) | 578 (file-exists-p nnml-current-directory)))) |
582 | 579 |
583 (defun nnml-possibly-create-directory (group) | 580 (defun nnml-possibly-create-directory (group) |
584 (let (dir dirs) | 581 (let ((dir (nnmail-group-pathname group nnml-directory))) |
585 (setq dir (nnmail-group-pathname group nnml-directory)) | 582 (unless (file-exists-p dir) |
586 (while (not (file-directory-p dir)) | 583 (make-directory (directory-file-name dir) t) |
587 (push dir dirs) | 584 (nnheader-message 5 "Creating mail directory %s" dir)))) |
588 (setq dir (file-name-directory (directory-file-name dir)))) | |
589 (while dirs | |
590 (make-directory (directory-file-name (car dirs))) | |
591 (nnheader-message 5 "Creating mail directory %s" (car dirs)) | |
592 (setq dirs (cdr dirs))))) | |
593 | 585 |
594 (defun nnml-save-mail (group-art) | 586 (defun nnml-save-mail (group-art) |
595 "Called narrowed to an article." | 587 "Called narrowed to an article." |
596 (let (chars headers) | 588 (let (chars headers) |
597 (setq chars (nnmail-insert-lines)) | 589 (setq chars (nnmail-insert-lines)) |
650 (caar (last nnml-article-file-alist))) | 642 (caar (last nnml-article-file-alist))) |
651 (cons 1 0))) | 643 (cons 1 0))) |
652 (push (list group active) nnml-group-alist)) | 644 (push (list group active) nnml-group-alist)) |
653 (setcdr active (1+ (cdr active))) | 645 (setcdr active (1+ (cdr active))) |
654 (while (file-exists-p | 646 (while (file-exists-p |
655 (concat (nnmail-group-pathname group nnml-directory) | 647 (expand-file-name (int-to-string (cdr active)) |
656 (int-to-string (cdr active)))) | 648 (nnmail-group-pathname group nnml-directory))) |
657 (setcdr active (1+ (cdr active)))) | 649 (setcdr active (1+ (cdr active)))) |
658 (cdr active))) | 650 (cdr active))) |
659 | 651 |
660 (defun nnml-add-nov (group article headers) | 652 (defun nnml-add-nov (group article headers) |
661 "Add a nov line for the GROUP base." | 653 "Add a nov line for the GROUP base." |
691 (or (cdr (assoc group nnml-nov-buffer-alist)) | 683 (or (cdr (assoc group nnml-nov-buffer-alist)) |
692 (let ((buffer (get-buffer-create (format " *nnml overview %s*" group)))) | 684 (let ((buffer (get-buffer-create (format " *nnml overview %s*" group)))) |
693 (save-excursion | 685 (save-excursion |
694 (set-buffer buffer) | 686 (set-buffer buffer) |
695 (set (make-local-variable 'nnml-nov-buffer-file-name) | 687 (set (make-local-variable 'nnml-nov-buffer-file-name) |
696 (concat (nnmail-group-pathname group nnml-directory) | 688 (expand-file-name |
697 nnml-nov-file-name)) | 689 nnml-nov-file-name |
690 (nnmail-group-pathname group nnml-directory))) | |
698 (erase-buffer) | 691 (erase-buffer) |
699 (when (file-exists-p nnml-nov-buffer-file-name) | 692 (when (file-exists-p nnml-nov-buffer-file-name) |
700 (nnheader-insert-file-contents nnml-nov-buffer-file-name))) | 693 (nnheader-insert-file-contents nnml-nov-buffer-file-name))) |
701 (push (cons group buffer) nnml-nov-buffer-alist) | 694 (push (cons group buffer) nnml-nov-buffer-alist) |
702 buffer))) | 695 buffer))) |
736 (push (file-truename dir) seen) | 729 (push (file-truename dir) seen) |
737 ;; We descend recursively | 730 ;; We descend recursively |
738 (let ((dirs (directory-files dir t nil t)) | 731 (let ((dirs (directory-files dir t nil t)) |
739 dir) | 732 dir) |
740 (while (setq dir (pop dirs)) | 733 (while (setq dir (pop dirs)) |
741 (when (and (not (member (file-name-nondirectory dir) '("." ".."))) | 734 (when (and (not (string-match "^\\." (file-name-nondirectory dir))) |
742 (file-directory-p dir)) | 735 (file-directory-p dir)) |
743 (nnml-generate-nov-databases-1 dir seen)))) | 736 (nnml-generate-nov-databases-1 dir seen)))) |
744 ;; Do this directory. | 737 ;; Do this directory. |
745 (let ((files (sort (nnheader-article-to-file-alist dir) | 738 (let ((files (sort (nnheader-article-to-file-alist dir) |
746 'car-less-than-car))) | 739 'car-less-than-car))) |
776 (nov-buffer (get-buffer-create " *nov*")) | 769 (nov-buffer (get-buffer-create " *nov*")) |
777 chars file headers) | 770 chars file headers) |
778 (save-excursion | 771 (save-excursion |
779 ;; Init the nov buffer. | 772 ;; Init the nov buffer. |
780 (set-buffer nov-buffer) | 773 (set-buffer nov-buffer) |
781 (buffer-disable-undo (current-buffer)) | 774 (buffer-disable-undo) |
782 (erase-buffer) | 775 (erase-buffer) |
783 (set-buffer nntp-server-buffer) | 776 (set-buffer nntp-server-buffer) |
784 ;; Delete the old NOV file. | 777 ;; Delete the old NOV file. |
785 (when (file-exists-p nov) | 778 (when (file-exists-p nov) |
786 (funcall nnmail-delete-file-function nov)) | 779 (funcall nnmail-delete-file-function nov)) |