diff options
| author | Richard M. Stallman | 1994-11-17 16:48:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-11-17 16:48:10 +0000 |
| commit | ab041f09cb59d71c92976fbc781f551a466d185a (patch) | |
| tree | 4b97008f1313043313334d3b89260f347e1cbd69 | |
| parent | 8600e6edbad67efacd43e26865e20629fb459600 (diff) | |
| download | emacs-ab041f09cb59d71c92976fbc781f551a466d185a.tar.gz emacs-ab041f09cb59d71c92976fbc781f551a466d185a.zip | |
(rmail-fields-not-to-output): New variable.
(rmail-delete-unwanted-fields): New function.
(rmail-output, rmail-output-to-rmail-file): Call it.
| -rw-r--r-- | lisp/mail/rmailout.el | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el index 190c3dddff5..3d81d6a25dd 100644 --- a/lisp/mail/rmailout.el +++ b/lisp/mail/rmailout.el | |||
| @@ -119,7 +119,17 @@ starting with the current one. Deleted messages are skipped and don't count." | |||
| 119 | (beg (1+ (rmail-msgbeg rmail-current-message))) | 119 | (beg (1+ (rmail-msgbeg rmail-current-message))) |
| 120 | (end (1+ (rmail-msgend rmail-current-message)))) | 120 | (end (1+ (rmail-msgend rmail-current-message)))) |
| 121 | (if (not buf) | 121 | (if (not buf) |
| 122 | (append-to-file beg end file-name) | 122 | ;; Output to a file. |
| 123 | (if rmail-fields-not-to-output | ||
| 124 | ;; Delete some fields while we output. | ||
| 125 | (let ((obuf (current-buffer))) | ||
| 126 | (set-buffer (get-buffer-create " rmail-out-temp")) | ||
| 127 | (insert-buffer-substring obuf beg end) | ||
| 128 | (rmail-delete-unwanted-fields) | ||
| 129 | (append-to-file (point-min) (point-max) file-name) | ||
| 130 | (set-buffer obuf) | ||
| 131 | (kill-buffer (get-buffer " rmail-out-temp"))) | ||
| 132 | (append-to-file beg end file-name)) | ||
| 123 | (if (eq buf (current-buffer)) | 133 | (if (eq buf (current-buffer)) |
| 124 | (error "Can't output message to same file it's already in")) | 134 | (error "Can't output message to same file it's already in")) |
| 125 | ;; File has been visited, in buffer BUF. | 135 | ;; File has been visited, in buffer BUF. |
| @@ -143,6 +153,7 @@ starting with the current one. Deleted messages are skipped and don't count." | |||
| 143 | (widen) | 153 | (widen) |
| 144 | (search-backward "\n\^_") | 154 | (search-backward "\n\^_") |
| 145 | (narrow-to-region (point) (point-max)) | 155 | (narrow-to-region (point) (point-max)) |
| 156 | (rmail-delete-unwanted-fields) | ||
| 146 | (rmail-count-new-messages t) | 157 | (rmail-count-new-messages t) |
| 147 | (if (rmail-summary-exists) | 158 | (if (rmail-summary-exists) |
| 148 | (rmail-select-summary | 159 | (rmail-select-summary |
| @@ -151,7 +162,8 @@ starting with the current one. Deleted messages are skipped and don't count." | |||
| 151 | ;; Output file not in rmail mode => just insert at the end. | 162 | ;; Output file not in rmail mode => just insert at the end. |
| 152 | (narrow-to-region (point-min) (1+ (buffer-size))) | 163 | (narrow-to-region (point-min) (1+ (buffer-size))) |
| 153 | (goto-char (point-max)) | 164 | (goto-char (point-max)) |
| 154 | (insert-buffer-substring cur beg end))))))) | 165 | (insert-buffer-substring cur beg end) |
| 166 | (rmail-delete-unwanted-fields))))))) | ||
| 155 | (rmail-set-attribute "filed" t)) | 167 | (rmail-set-attribute "filed" t)) |
| 156 | (if redelete (rmail-set-attribute "deleted" t)))) | 168 | (if redelete (rmail-set-attribute "deleted" t)))) |
| 157 | (setq count (1- count)) | 169 | (setq count (1- count)) |
| @@ -160,6 +172,26 @@ starting with the current one. Deleted messages are skipped and don't count." | |||
| 160 | (if (> count 0) | 172 | (if (> count 0) |
| 161 | (rmail-next-undeleted-message 1)))))) | 173 | (rmail-next-undeleted-message 1)))))) |
| 162 | 174 | ||
| 175 | (defvar rmail-fields-not-to-output nil | ||
| 176 | "*Regexp describing fields to exclude when outputting a message to a file.") | ||
| 177 | |||
| 178 | ;; Delete from the buffer header fields we don't want output. | ||
| 179 | ;; NOT-RMAIL if t means this buffer does not have the full header | ||
| 180 | ;; and *** EOOH *** that a message in an Rmail file has. | ||
| 181 | (defun rmail-delete-unwanted-fields (&optional not-rmail) | ||
| 182 | (if rmail-fields-not-to-output | ||
| 183 | (save-excursion | ||
| 184 | (goto-char (point-min)) | ||
| 185 | ;; Find the end of the header. | ||
| 186 | (if (and (or not-rmail (search-forward "\n*** EOOH ***\n" nil t)) | ||
| 187 | (search-forward "\n\n" nil t)) | ||
| 188 | (let ((end (point-marker))) | ||
| 189 | (goto-char (point-min)) | ||
| 190 | (while (re-search-forward rmail-fields-not-to-output end t) | ||
| 191 | (beginning-of-line) | ||
| 192 | (delete-region (point) | ||
| 193 | (progn (forward-line 1) (point))))))))) | ||
| 194 | |||
| 163 | ;; Returns t if file FILE is an Rmail file. | 195 | ;; Returns t if file FILE is an Rmail file. |
| 164 | ;;;###autoload | 196 | ;;;###autoload |
| 165 | (defun rmail-file-p (file) | 197 | (defun rmail-file-p (file) |
| @@ -254,6 +286,7 @@ The optional fourth argument FROM-GNUS is set when called from GNUS." | |||
| 254 | (set-buffer tembuf) | 286 | (set-buffer tembuf) |
| 255 | (erase-buffer) | 287 | (erase-buffer) |
| 256 | (insert-buffer-substring rmailbuf) | 288 | (insert-buffer-substring rmailbuf) |
| 289 | (rmail-delete-unwanted-fields t) | ||
| 257 | (insert "\n") | 290 | (insert "\n") |
| 258 | (goto-char (point-min)) | 291 | (goto-char (point-min)) |
| 259 | (if mail-from | 292 | (if mail-from |