diff options
| author | Richard M. Stallman | 1997-01-21 01:51:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-01-21 01:51:46 +0000 |
| commit | 4144e5cba0fe2b99da2f04a239462269169168a4 (patch) | |
| tree | 7f608e965b4661bffd0243acaf8c90b84cd245fe | |
| parent | e4377f536f72d366c6928cc67c949b767ad1b6cf (diff) | |
| download | emacs-4144e5cba0fe2b99da2f04a239462269169168a4.tar.gz emacs-4144e5cba0fe2b99da2f04a239462269169168a4.zip | |
(rmail-preserve-inbox): New variable.
(rmail-get-new-mail): If rmail-preserve-inbox is non-nil, then
don't truncate the inboxes after retrieving mail from them.
| -rw-r--r-- | lisp/mail/rmail.el | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 30493fea700..ba2b8ae6ad7 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -60,6 +60,10 @@ | |||
| 60 | (defvar rmail-pop-password-required nil | 60 | (defvar rmail-pop-password-required nil |
| 61 | "*Non-nil if a password is required when reading mail using POP.") | 61 | "*Non-nil if a password is required when reading mail using POP.") |
| 62 | 62 | ||
| 63 | (defvar rmail-preserve-inbox nil | ||
| 64 | "*Non-nil if incoming mail should be left in the user's inbox, | ||
| 65 | rather than deleted, after it is retrieved.") | ||
| 66 | |||
| 63 | ;;;###autoload | 67 | ;;;###autoload |
| 64 | (defvar rmail-dont-reply-to-names nil "\ | 68 | (defvar rmail-dont-reply-to-names nil "\ |
| 65 | *A regexp specifying names to prune of reply to messages. | 69 | *A regexp specifying names to prune of reply to messages. |
| @@ -891,6 +895,9 @@ file of new mail is not changed or deleted. Noninteractively, you can | |||
| 891 | pass the inbox file name as an argument. Interactively, a prefix | 895 | pass the inbox file name as an argument. Interactively, a prefix |
| 892 | argument causes us to read a file name and use that file as the inbox. | 896 | argument causes us to read a file name and use that file as the inbox. |
| 893 | 897 | ||
| 898 | If the variable `rmail-preserve-inbox' is non-nil, new mail will | ||
| 899 | always be left in inbox files rather than deleted. | ||
| 900 | |||
| 894 | This function runs `rmail-get-new-mail-hook' before saving the updated file. | 901 | This function runs `rmail-get-new-mail-hook' before saving the updated file. |
| 895 | It returns t if it got any new messages." | 902 | It returns t if it got any new messages." |
| 896 | (interactive | 903 | (interactive |
| @@ -1074,34 +1081,42 @@ It returns t if it got any new messages." | |||
| 1074 | (not (file-exists-p file)))) | 1081 | (not (file-exists-p file)))) |
| 1075 | nil) | 1082 | nil) |
| 1076 | ((and (not movemail) (not popmail)) | 1083 | ((and (not movemail) (not popmail)) |
| 1077 | ;; Try copying. If that fails (perhaps no space), | 1084 | ;; Try copying. If that fails (perhaps no space) and |
| 1078 | ;; rename instead. | 1085 | ;; we're allowed to blow away the inbox, rename instead. |
| 1079 | (condition-case nil | 1086 | (if rmail-preserve-inbox |
| 1080 | (copy-file file tofile nil) | 1087 | (copy-file file tofile nil) |
| 1081 | (error | 1088 | (condition-case nil |
| 1082 | ;; Third arg is t so we can replace existing file TOFILE. | 1089 | (copy-file file tofile nil) |
| 1083 | (rename-file file tofile t))) | 1090 | (error |
| 1091 | ;; Third arg is t so we can replace existing file TOFILE. | ||
| 1092 | (rename-file file tofile t)))) | ||
| 1084 | ;; Make the real inbox file empty. | 1093 | ;; Make the real inbox file empty. |
| 1085 | ;; Leaving it deleted could cause lossage | 1094 | ;; Leaving it deleted could cause lossage |
| 1086 | ;; because mailers often won't create the file. | 1095 | ;; because mailers often won't create the file. |
| 1087 | (condition-case () | 1096 | (if (not rmail-preserve-inbox) |
| 1088 | (write-region (point) (point) file) | 1097 | (condition-case () |
| 1089 | (file-error nil))) | 1098 | (write-region (point) (point) file) |
| 1099 | (file-error nil)))) | ||
| 1090 | (t | 1100 | (t |
| 1091 | (let ((errors nil)) | 1101 | (let ((errors nil)) |
| 1092 | (unwind-protect | 1102 | (unwind-protect |
| 1093 | (save-excursion | 1103 | (save-excursion |
| 1094 | (setq errors (generate-new-buffer " *rmail loss*")) | 1104 | (setq errors (generate-new-buffer " *rmail loss*")) |
| 1095 | (buffer-disable-undo errors) | 1105 | (buffer-disable-undo errors) |
| 1096 | (if rmail-pop-password | 1106 | (let ((args |
| 1097 | (call-process | 1107 | (append |
| 1098 | (or rmail-movemail-program | 1108 | (list (or rmail-movemail-program |
| 1099 | (expand-file-name "movemail" exec-directory)) | 1109 | (expand-file-name "movemail" |
| 1100 | nil errors nil file tofile rmail-pop-password) | 1110 | exec-directory)) |
| 1101 | (call-process | 1111 | nil errors nil) |
| 1102 | (or rmail-movemail-program | 1112 | (if rmail-preserve-inbox |
| 1103 | (expand-file-name "movemail" exec-directory)) | 1113 | (list "-p") |
| 1104 | nil errors nil file tofile)) | 1114 | nil) |
| 1115 | (list file tofile) | ||
| 1116 | (if rmail-pop-password | ||
| 1117 | (list rmail-pop-password) | ||
| 1118 | nil)))) | ||
| 1119 | (apply 'call-process args)) | ||
| 1105 | (if (not (buffer-modified-p errors)) | 1120 | (if (not (buffer-modified-p errors)) |
| 1106 | ;; No output => movemail won | 1121 | ;; No output => movemail won |
| 1107 | nil | 1122 | nil |
| @@ -1132,7 +1147,8 @@ It returns t if it got any new messages." | |||
| 1132 | (or (= (preceding-char) ?\n) | 1147 | (or (= (preceding-char) ?\n) |
| 1133 | (zerop size) | 1148 | (zerop size) |
| 1134 | (insert ?\n)) | 1149 | (insert ?\n)) |
| 1135 | (setq delete-files (cons tofile delete-files)))) | 1150 | (if (not (and rmail-preserve-inbox (string= file tofile))) |
| 1151 | (setq delete-files (cons tofile delete-files))))) | ||
| 1136 | (message "") | 1152 | (message "") |
| 1137 | (setq files (cdr files))) | 1153 | (setq files (cdr files))) |
| 1138 | delete-files)) | 1154 | delete-files)) |