Mercurial > emacs
comparison lisp/mail/rmail.el @ 88203:0afa819977c5
(rmail-get-inbox-list): New function.
(rmail-get-new-mail): Use it.
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Wed, 18 Jan 2006 12:15:29 +0000 |
parents | 845dd39e284d |
children | f400fb7ee08a |
comparison
equal
deleted
inserted
replaced
88202:4ece5630c0fb | 88203:0afa819977c5 |
---|---|
1395 '("Output Rmail File" . rmail-disable-menu))))) | 1395 '("Output Rmail File" . rmail-disable-menu))))) |
1396 | 1396 |
1397 | 1397 |
1398 ;;;; *** Rmail input *** | 1398 ;;;; *** Rmail input *** |
1399 | 1399 |
1400 (defun rmail-get-inbox-list () | |
1401 ;; Pull files off rmail-inbox-list onto files as long as there is no | |
1402 ;; name conflict. A conflict happens when two inbox file names have | |
1403 ;; the same last component. | |
1404 (let (list last-names) | |
1405 (dolist (file rmail-inbox-list) | |
1406 (unless (member (file-name-nondirectory file) last-names) | |
1407 (push file list)) | |
1408 (push (file-name-nondirectory file) last-names)) | |
1409 (nreverse list))) | |
1410 | |
1400 ;; RLK feature not added in this version: | 1411 ;; RLK feature not added in this version: |
1401 ;; argument specifies inbox file or files in various ways. | 1412 ;; argument specifies inbox file or files in various ways. |
1402 | 1413 |
1403 ;;; DOC NOT DONE | 1414 ;;; DOC NOT DONE |
1404 (defun rmail-get-new-mail (&optional file-name) | 1415 (defun rmail-get-new-mail (&optional file-name) |
1429 (set-buffer rmail-buffer) | 1440 (set-buffer rmail-buffer) |
1430 (widen) | 1441 (widen) |
1431 ;; Get rid of all undo records for this buffer. | 1442 ;; Get rid of all undo records for this buffer. |
1432 (unless (eq buffer-undo-list t) | 1443 (unless (eq buffer-undo-list t) |
1433 (setq buffer-undo-list nil)) | 1444 (setq buffer-undo-list nil)) |
1434 (let ((all-files (if file-name (list file-name) | 1445 (let ((files (if file-name (list file-name) (rmail-get-inbox-list))) |
1435 rmail-inbox-list)) | |
1436 (rmail-enable-multibyte (default-value 'enable-multibyte-characters)) | 1446 (rmail-enable-multibyte (default-value 'enable-multibyte-characters)) |
1437 found current-message) | 1447 found current-message) |
1438 (condition-case nil | 1448 (condition-case nil |
1439 (progn | 1449 (progn |
1440 (while all-files | 1450 (let ((opoint (point)) |
1441 (let ((opoint (point)) | 1451 (new-messages 0) |
1442 (new-messages 0) | 1452 (delete-files ()) |
1443 (delete-files ()) | 1453 ;; If buffer has not changed yet, and has not been saved yet, |
1444 ;; If buffer has not changed yet, and has not been saved yet, | 1454 ;; don't replace the old backup file now. |
1445 ;; don't replace the old backup file now. | 1455 (make-backup-files (and make-backup-files (buffer-modified-p))) |
1446 (make-backup-files (and make-backup-files (buffer-modified-p))) | 1456 (buffer-read-only nil) |
1447 (buffer-read-only nil) | 1457 ;; Don't make undo records for what we do in getting mail. |
1448 ;; Don't make undo records for what we do in getting mail. | 1458 (buffer-undo-list t)) |
1449 (buffer-undo-list t) | 1459 (save-excursion |
1450 ;; Files to insert this time around. | 1460 (save-restriction |
1451 files | 1461 (goto-char (point-max)) |
1452 ;; Last names of those files. | 1462 (narrow-to-region (point) (point)) |
1453 file-last-names) | 1463 ;; Read in the contents of the inbox files, renaming |
1454 ;; Pull files off all-files onto files as long as there is | 1464 ;; them as necessary, and adding to the list of files |
1455 ;; no name conflict. A conflict happens when two inbox | 1465 ;; to delete eventually. |
1456 ;; file names have the same last component. | 1466 (if file-name |
1457 (while (and all-files | 1467 (rmail-insert-inbox-text files nil) |
1458 (not (member (file-name-nondirectory (car all-files)) | 1468 (setq delete-files (rmail-insert-inbox-text files t))) |
1459 file-last-names))) | 1469 (unless (equal (point-min) (point-max)) |
1460 (setq files (cons (car all-files) files) | 1470 (setq new-messages (rmail-process-new-messages) |
1461 file-last-names | 1471 rmail-current-message (1+ rmail-total-messages) |
1462 (cons (file-name-nondirectory (car all-files)) files)) | 1472 rmail-total-messages (rmail-desc-get-count)) |
1463 (setq all-files (cdr all-files))) | 1473 (run-hooks 'rmail-get-new-mail-hook) |
1464 ;; Put them back in their original order. | 1474 (save-buffer)) |
1465 (setq files (nreverse files)) | 1475 ;; Delete the old files, now that the RMAIL file is |
1466 | 1476 ;; saved. |
1467 (save-excursion | 1477 (dolist (i delete-files) |
1468 (save-restriction | 1478 (condition-case nil |
1469 (goto-char (point-max)) | 1479 ;; First, try deleting. |
1470 (narrow-to-region (point) (point)) | 1480 (condition-case nil |
1471 ;; Read in the contents of the inbox files, renaming | 1481 (delete-file i) |
1472 ;; them as necessary, and adding to the list of files | 1482 ;; If we can't delete it, truncate it. |
1473 ;; to delete eventually. | 1483 (file-error (write-region (point) (point) i))) |
1474 (if file-name | 1484 (file-error nil))))) |
1475 (rmail-insert-inbox-text files nil) | 1485 (if (= new-messages 0) |
1476 (setq delete-files (rmail-insert-inbox-text files t))) | 1486 (progn (goto-char opoint) |
1477 (unless (equal (point-min) (point-max)) | 1487 (when (or file-name rmail-inbox-list) |
1478 (setq new-messages (rmail-process-new-messages) | 1488 (message "(No new mail has arrived)"))) |
1479 rmail-current-message (1+ rmail-total-messages) | 1489 ;; Make the first unseen message the current message |
1480 rmail-total-messages (rmail-desc-get-count)) | 1490 ;; and update the summary buffer, if one exists. |
1481 (run-hooks 'rmail-get-new-mail-hook) | 1491 (setq current-message (rmail-first-unseen-message)) |
1482 (save-buffer)) | 1492 (if (rmail-summary-exists) |
1483 ;; Delete the old files, now that the RMAIL file is | 1493 (with-current-buffer rmail-summary-buffer |
1484 ;; saved. | 1494 (rmail-update-summary))) |
1485 (dolist (i delete-files) | 1495 ;; Process the new messages for spam using the |
1486 (condition-case nil | 1496 ;; integrated spam filter. The spam filter can mark |
1487 ;; First, try deleting. | 1497 ;; messages for deletion and can output a message. |
1488 (condition-case nil | 1498 (if rmail-use-spam-filter |
1489 (delete-file i) | 1499 ;; Loop through the new messages processing each |
1490 ;; If we can't delete it, truncate it. | 1500 ;; message for spam. |
1491 (file-error (write-region (point) (point) i))) | 1501 (while (<= current-message rmail-total-messages) |
1492 (file-error nil))))) | 1502 (rmail-spam-filter current-message) |
1493 (if (= new-messages 0) | 1503 (setq current-message (1+ current-message)))) |
1494 (progn (goto-char opoint) | 1504 |
1495 (when (or file-name rmail-inbox-list) | 1505 ;; Position the mail cursor again. |
1496 (message "(No new mail has arrived)"))) | 1506 (setq current-message (rmail-first-unseen-message)) |
1497 ;; Make the first unseen message the current message | 1507 (if (rmail-summary-exists) |
1498 ;; and update the summary buffer, if one exists. | 1508 (with-current-buffer rmail-summary-buffer |
1499 (setq current-message (rmail-first-unseen-message)) | 1509 (rmail-update-summary) |
1500 (if (rmail-summary-exists) | 1510 (rmail-summary-goto-msg current-message)) |
1501 (with-current-buffer rmail-summary-buffer | 1511 (rmail-show-message current-message)) |
1502 (rmail-update-summary))) | 1512 |
1503 ;; Process the new messages for spam using the | 1513 ;; Run the after get new mail hook. |
1504 ;; integrated spam filter. The spam filter can mark | 1514 (run-hooks 'rmail-after-get-new-mail-hook) |
1505 ;; messages for deletion and can output a message. | 1515 (message "%d new message%s read" |
1506 (if rmail-use-spam-filter | 1516 new-messages (if (= 1 new-messages) "" "s")) |
1507 ;; Loop through the new messages processing each | 1517 (setq found t))) |
1508 ;; message for spam. | |
1509 (while (<= current-message rmail-total-messages) | |
1510 (rmail-spam-filter current-message) | |
1511 (setq current-message (1+ current-message)))) | |
1512 | |
1513 ;; Position the mail cursor again. | |
1514 (setq current-message (rmail-first-unseen-message)) | |
1515 (if (rmail-summary-exists) | |
1516 (with-current-buffer rmail-summary-buffer | |
1517 (rmail-update-summary) | |
1518 (rmail-summary-goto-msg current-message)) | |
1519 (rmail-show-message current-message)) | |
1520 | |
1521 ;; Run the after get new mail hook. | |
1522 (run-hooks 'rmail-after-get-new-mail-hook) | |
1523 (message "%d new message%s read" | |
1524 new-messages (if (= 1 new-messages) "" "s")) | |
1525 (setq found t)))) | |
1526 found) | 1518 found) |
1527 ;; Don't leave the buffer screwed up if we get a disk-full error. | 1519 ;; Don't leave the buffer screwed up if we get a disk-full error. |
1528 (file-error (or found (rmail-show-message)))))) | 1520 (file-error (or found (rmail-show-message)))))) |
1529 | 1521 |
1530 (defun rmail-parse-url (file) | 1522 (defun rmail-parse-url (file) |