diff options
| author | Glenn Morris | 2009-02-18 04:34:04 +0000 |
|---|---|---|
| committer | Glenn Morris | 2009-02-18 04:34:04 +0000 |
| commit | 8e7a0f839f84aec582e1cd42c8f3f09c7d7aa8ac (patch) | |
| tree | 14ffd3e4e848677c5b6cf294fc9bc509b1118b99 | |
| parent | 8ad667fabbe04c6eec97f51d84958a4cadc90c37 (diff) | |
| download | emacs-8e7a0f839f84aec582e1cd42c8f3f09c7d7aa8ac.tar.gz emacs-8e7a0f839f84aec582e1cd42c8f3f09c7d7aa8ac.zip | |
(rmail-get-new-mail-1): Fix the spam beep test.
(rmail-get-new-mail-filter-spam): Simplify. Don't mess with
rmail-deleted-vector.
(rmail-insert-inbox-text, rmail-collect-deleted)
(rmail-set-message-deleted-p, rmail-only-expunge)
(rmail-make-in-reply-to-field): Replace ?\ with ?\s.
(rmail-get-labels): Remove unused local `blurb'.
(rmail-message-attr-p, rmail-message-unseen-p, rmail-message-labels-p)
(rmail-msgend, rmail-msgbeg, rmail-message-deleted-p)
(rmail-set-message-deleted-p): Doc fixes.
| -rw-r--r-- | lisp/mail/rmail.el | 98 |
1 files changed, 46 insertions, 52 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 7b241a0b1ea..a3d603197c1 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -1383,6 +1383,7 @@ If so restore the actual mbox message collection." | |||
| 1383 | (let* ((revert-buffer-function (default-value 'revert-buffer-function)) | 1383 | (let* ((revert-buffer-function (default-value 'revert-buffer-function)) |
| 1384 | (rmail-enable-multibyte enable-multibyte-characters) | 1384 | (rmail-enable-multibyte enable-multibyte-characters) |
| 1385 | ;; See similar code in `rmail'. | 1385 | ;; See similar code in `rmail'. |
| 1386 | ;; FIXME needs updating? | ||
| 1386 | (coding-system-for-read (and rmail-enable-multibyte 'raw-text)) | 1387 | (coding-system-for-read (and rmail-enable-multibyte 'raw-text)) |
| 1387 | (before-revert-hook 'rmail-swap-buffers-maybe)) | 1388 | (before-revert-hook 'rmail-swap-buffers-maybe)) |
| 1388 | ;; Call our caller again, but this time it does the default thing. | 1389 | ;; Call our caller again, but this time it does the default thing. |
| @@ -1707,47 +1708,37 @@ It returns t if it got any new messages." | |||
| 1707 | (rmail-select-summary (rmail-update-summary))) | 1708 | (rmail-select-summary (rmail-update-summary))) |
| 1708 | (setq suffix (if (= 1 new-messages) "" "s")) | 1709 | (setq suffix (if (= 1 new-messages) "" "s")) |
| 1709 | (message "%d new message%s read%s" new-messages suffix blurb) | 1710 | (message "%d new message%s read%s" new-messages suffix blurb) |
| 1710 | (when spam-filter-p | 1711 | (unless (string-equal blurb "") ; there was spam |
| 1711 | (if rsf-beep (beep t)) | 1712 | (if rsf-beep (beep t)) |
| 1713 | ;; FIXME This doesn't seem a very good feature, e.g. it delays the | ||
| 1714 | ;; appearance of the summary, and leaves the raw buffer visible. | ||
| 1712 | (sleep-for rsf-sleep-after-message)) | 1715 | (sleep-for rsf-sleep-after-message)) |
| 1713 | |||
| 1714 | ;; Establish the return value. | 1716 | ;; Establish the return value. |
| 1715 | (setq result (> new-messages 0)) | 1717 | (setq result (> new-messages 0)) |
| 1716 | result)))) | 1718 | result)))) |
| 1717 | 1719 | ||
| 1718 | (defun rmail-get-new-mail-filter-spam (new-message-count) | 1720 | (defun rmail-get-new-mail-filter-spam (nnew) |
| 1719 | "Process new messages for spam." | 1721 | "Check the most NNEW recent messages for spam." |
| 1720 | (let* ((old-messages (- rmail-total-messages new-message-count)) | 1722 | (let* ((nold (- rmail-total-messages nnew)) |
| 1721 | (rsf-number-of-spam 0) | 1723 | (nspam 0) |
| 1722 | (rsf-scanned-message-number (1+ old-messages)) | 1724 | (nscan (1+ nold))) |
| 1723 | ;; save deletion flags of old messages: vector starts at zero | 1725 | (while (<= nscan rmail-total-messages) |
| 1724 | ;; (is one longer than no of messages), therefore take 1+ | 1726 | (or (rmail-spam-filter nscan) |
| 1725 | ;; old-messages | 1727 | (setq nspam (1+ nspam))) |
| 1726 | (save-deleted (substring rmail-deleted-vector 0 (1+ old-messages))) | 1728 | (setq nscan (1+ nscan))) |
| 1727 | blurb) | 1729 | ;; FIXME the expunge prompt leaves the raw mbox buffer showing, |
| 1728 | ;; set all messages to undeleted | 1730 | ;; but it's not straightforward to show a message at this point |
| 1729 | (setq rmail-deleted-vector (make-string (1+ rmail-total-messages) ?\ )) | 1731 | ;; without messing up the rest of get-new-mail. |
| 1730 | (while (<= rsf-scanned-message-number rmail-total-messages) | 1732 | (and (> nspam 0) |
| 1731 | (progn | 1733 | (rmail-expunge-confirmed) |
| 1732 | (if (not (rmail-spam-filter rsf-scanned-message-number)) | 1734 | (rmail-only-expunge t)) |
| 1733 | (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam)))) | 1735 | ;; Return a message based on the number of spam messages found. |
| 1734 | (setq rsf-scanned-message-number (1+ rsf-scanned-message-number)))) | ||
| 1735 | (if (> rsf-number-of-spam 0) | ||
| 1736 | (progn | ||
| 1737 | (when (rmail-expunge-confirmed) | ||
| 1738 | (rmail-only-expunge t)))) | ||
| 1739 | (setq rmail-deleted-vector | ||
| 1740 | (concat save-deleted | ||
| 1741 | (make-string (- rmail-total-messages old-messages) ?\ ))) | ||
| 1742 | ;; Generate a return value message based on the number of spam | ||
| 1743 | ;; messages found. | ||
| 1744 | (cond | 1736 | (cond |
| 1745 | ((zerop rsf-number-of-spam) "") | 1737 | ((zerop nspam) "") |
| 1746 | ((= 1 new-message-count) ", and appears to be spam") | 1738 | ((= 1 nnew) ", and it appears to be spam") |
| 1747 | ((= rsf-number-of-spam new-message-count) ", and all appear to be spam") | 1739 | ((= nspam nnew) ", and all appear to be spam") |
| 1748 | ((> rsf-number-of-spam 1) | 1740 | (t (format ", and %d appear%s to be spam" nspam |
| 1749 | (format ", and %d appear to be spam" rsf-number-of-spam)) | 1741 | (if (= 1 nspam) "s" "")))))) |
| 1750 | (t ", and 1 appears to be spam")))) | ||
| 1751 | 1742 | ||
| 1752 | (defun rmail-parse-url (file) | 1743 | (defun rmail-parse-url (file) |
| 1753 | "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD) | 1744 | "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD) |
| @@ -1882,7 +1873,7 @@ is non-nil if the user has supplied the password interactively. | |||
| 1882 | nil | 1873 | nil |
| 1883 | (set-buffer errors) | 1874 | (set-buffer errors) |
| 1884 | (subst-char-in-region (point-min) (point-max) | 1875 | (subst-char-in-region (point-min) (point-max) |
| 1885 | ?\n ?\ ) | 1876 | ?\n ?\s) |
| 1886 | (goto-char (point-max)) | 1877 | (goto-char (point-max)) |
| 1887 | (skip-chars-backward " \t") | 1878 | (skip-chars-backward " \t") |
| 1888 | (delete-region (point) (point-max)) | 1879 | (delete-region (point) (point-max)) |
| @@ -2078,7 +2069,7 @@ It is put in comma-separated form. | |||
| 2078 | MSG, if non-nil, identifies the message number to use. | 2069 | MSG, if non-nil, identifies the message number to use. |
| 2079 | If nil, that means the current message." | 2070 | If nil, that means the current message." |
| 2080 | (or msg (setq msg rmail-current-message)) | 2071 | (or msg (setq msg rmail-current-message)) |
| 2081 | (let (blurb attr-names keywords) | 2072 | (let (attr-names keywords) |
| 2082 | ;; Combine the message attributes and keywords | 2073 | ;; Combine the message attributes and keywords |
| 2083 | ;; into a comma-separated list. | 2074 | ;; into a comma-separated list. |
| 2084 | (setq attr-names (rmail-get-attr-names msg) | 2075 | (setq attr-names (rmail-get-attr-names msg) |
| @@ -2184,26 +2175,26 @@ change; nil means current message." | |||
| 2184 | (set-buffer-modified-p t))))) | 2175 | (set-buffer-modified-p t))))) |
| 2185 | 2176 | ||
| 2186 | (defun rmail-message-attr-p (msg attrs) | 2177 | (defun rmail-message-attr-p (msg attrs) |
| 2187 | "Return t if the attributes header for message MSG matches regexp ATTRS." | 2178 | "Return non-nil if message number MSG has attributes matching regexp ATTRS." |
| 2188 | (let ((value (rmail-get-header rmail-attribute-header msg))) | 2179 | (let ((value (rmail-get-header rmail-attribute-header msg))) |
| 2189 | (and value (string-match attrs value)))) | 2180 | (and value (string-match attrs value)))) |
| 2190 | 2181 | ||
| 2191 | (defun rmail-message-unseen-p (msgnum) | 2182 | (defun rmail-message-unseen-p (msgnum) |
| 2192 | "Test the unseen attribute for message MSGNUM. | 2183 | "Return non-nil if message number MSGNUM has the unseen attribute." |
| 2193 | Return non-nil if the unseen attribute is set, nil otherwise." | ||
| 2194 | (rmail-message-attr-p msgnum "......U")) | 2184 | (rmail-message-attr-p msgnum "......U")) |
| 2195 | 2185 | ||
| 2196 | ;; Return t if the attributes/keywords line of msg number MSG | ||
| 2197 | ;; contains a match for the regexp LABELS. | ||
| 2198 | (defun rmail-message-labels-p (msg labels) | 2186 | (defun rmail-message-labels-p (msg labels) |
| 2187 | "Return non-nil if message number MSG has labels matching regexp LABELS." | ||
| 2199 | (string-match labels (rmail-get-labels msg))) | 2188 | (string-match labels (rmail-get-labels msg))) |
| 2200 | 2189 | ||
| 2201 | ;;;; *** Rmail Message Selection And Support *** | 2190 | ;;;; *** Rmail Message Selection And Support *** |
| 2202 | 2191 | ||
| 2203 | (defun rmail-msgend (n) | 2192 | (defun rmail-msgend (n) |
| 2193 | "Return the start position for message number N." | ||
| 2204 | (marker-position (aref rmail-message-vector (1+ n)))) | 2194 | (marker-position (aref rmail-message-vector (1+ n)))) |
| 2205 | 2195 | ||
| 2206 | (defun rmail-msgbeg (n) | 2196 | (defun rmail-msgbeg (n) |
| 2197 | "Return the end position for message number N." | ||
| 2207 | (marker-position (aref rmail-message-vector n))) | 2198 | (marker-position (aref rmail-message-vector n))) |
| 2208 | 2199 | ||
| 2209 | (defun rmail-apply-in-message (msgnum function &rest args) | 2200 | (defun rmail-apply-in-message (msgnum function &rest args) |
| @@ -2364,7 +2355,7 @@ the message. Point is at the beginning of the message." | |||
| 2364 | (cons (if (and (search-forward (concat rmail-attribute-header ": ") message-end t) | 2355 | (cons (if (and (search-forward (concat rmail-attribute-header ": ") message-end t) |
| 2365 | (looking-at "?D")) | 2356 | (looking-at "?D")) |
| 2366 | ?D | 2357 | ?D |
| 2367 | ?\ ) deleted-head)))) | 2358 | ?\s) deleted-head)))) |
| 2368 | 2359 | ||
| 2369 | (defun rmail-set-message-counters-counter (&optional stop) | 2360 | (defun rmail-set-message-counters-counter (&optional stop) |
| 2370 | ;; Collect the start position for each message into 'messages-head. | 2361 | ;; Collect the start position for each message into 'messages-head. |
| @@ -3080,10 +3071,13 @@ If N is negative, go forwards instead." | |||
| 3080 | ;;;; *** Rmail Message Deletion Commands *** | 3071 | ;;;; *** Rmail Message Deletion Commands *** |
| 3081 | 3072 | ||
| 3082 | (defun rmail-message-deleted-p (n) | 3073 | (defun rmail-message-deleted-p (n) |
| 3074 | "Return non-nil if message number N is deleted (in `rmail-deleted-vector')." | ||
| 3083 | (= (aref rmail-deleted-vector n) ?D)) | 3075 | (= (aref rmail-deleted-vector n) ?D)) |
| 3084 | 3076 | ||
| 3085 | (defun rmail-set-message-deleted-p (n state) | 3077 | (defun rmail-set-message-deleted-p (n state) |
| 3086 | (aset rmail-deleted-vector n (if state ?D ?\ ))) | 3078 | "Set the deleted state of message number N (in `rmail-deleted-vector'). |
| 3079 | STATE non-nil means mark as deleted." | ||
| 3080 | (aset rmail-deleted-vector n (if state ?D ?\s))) | ||
| 3087 | 3081 | ||
| 3088 | (defun rmail-delete-message () | 3082 | (defun rmail-delete-message () |
| 3089 | "Delete this message and stay on it." | 3083 | "Delete this message and stay on it." |
| @@ -3229,7 +3223,7 @@ See also user-option `rmail-confirm-expunge'." | |||
| 3229 | (setq rmail-current-message new-message-number | 3223 | (setq rmail-current-message new-message-number |
| 3230 | rmail-total-messages counter | 3224 | rmail-total-messages counter |
| 3231 | rmail-message-vector (apply 'vector messages-head) | 3225 | rmail-message-vector (apply 'vector messages-head) |
| 3232 | rmail-deleted-vector (make-string (1+ counter) ?\ ) | 3226 | rmail-deleted-vector (make-string (1+ counter) ?\s) |
| 3233 | rmail-summary-vector (vconcat (nreverse new-summary)) | 3227 | rmail-summary-vector (vconcat (nreverse new-summary)) |
| 3234 | rmail-msgref-vector (apply 'vector (nreverse new-msgref)) | 3228 | rmail-msgref-vector (apply 'vector (nreverse new-msgref)) |
| 3235 | win t))) | 3229 | win t))) |
| @@ -3449,10 +3443,10 @@ which is an element of rmail-msgref-vector." | |||
| 3449 | (end (match-end 1))) | 3443 | (end (match-end 1))) |
| 3450 | ;; Trim whitespace which above regexp match allows | 3444 | ;; Trim whitespace which above regexp match allows |
| 3451 | (while (and (< start end) | 3445 | (while (and (< start end) |
| 3452 | (memq (aref from start) '(?\t ?\ ))) | 3446 | (memq (aref from start) '(?\t ?\s))) |
| 3453 | (setq start (1+ start))) | 3447 | (setq start (1+ start))) |
| 3454 | (while (and (< start end) | 3448 | (while (and (< start end) |
| 3455 | (memq (aref from (1- end)) '(?\t ?\ ))) | 3449 | (memq (aref from (1- end)) '(?\t ?\s))) |
| 3456 | (setq end (1- end))) | 3450 | (setq end (1- end))) |
| 3457 | (let ((field (substring from start end))) | 3451 | (let ((field (substring from start end))) |
| 3458 | (if date (setq field (concat "message from " field " on " date))) | 3452 | (if date (setq field (concat "message from " field " on " date))) |
| @@ -3984,15 +3978,15 @@ encoded string (and the same mask) will decode the string." | |||
| 3984 | ;;;; Desktop support | 3978 | ;;;; Desktop support |
| 3985 | 3979 | ||
| 3986 | (defun rmail-restore-desktop-buffer (desktop-buffer-file-name | 3980 | (defun rmail-restore-desktop-buffer (desktop-buffer-file-name |
| 3987 | desktop-buffer-name | 3981 | desktop-buffer-name |
| 3988 | desktop-buffer-misc) | 3982 | desktop-buffer-misc) |
| 3989 | "Restore an rmail buffer specified in a desktop file." | 3983 | "Restore an rmail buffer specified in a desktop file." |
| 3990 | (condition-case error | 3984 | (condition-case error |
| 3991 | (progn | 3985 | (progn |
| 3992 | (rmail-input desktop-buffer-file-name) | 3986 | (rmail-input desktop-buffer-file-name) |
| 3993 | (if (eq major-mode 'rmail-mode) | 3987 | (if (eq major-mode 'rmail-mode) |
| 3994 | (current-buffer) | 3988 | (current-buffer) |
| 3995 | rmail-buffer)) | 3989 | rmail-buffer)) |
| 3996 | (file-locked | 3990 | (file-locked |
| 3997 | (kill-buffer (current-buffer)) | 3991 | (kill-buffer (current-buffer)) |
| 3998 | nil))) | 3992 | nil))) |