Mercurial > emacs
changeset 88246:80cb86e7ac6d
(rmail-redecode-body): Simplify.
(rmail-get-inbox-list): Stop on name conflict.
(rmail-show-message): Set `rmail-view-buffer' to `rmail-buffer` if
not using MIME. Make sure we go to `point-min' before setting
window point as searching for coding header might move point.
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Sat, 21 Jan 2006 00:12:07 +0000 |
parents | e2d921647a85 |
children | 244362bb8500 |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 48 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Sat Jan 21 00:11:44 2006 +0000 +++ b/lisp/mail/rmail.el Sat Jan 21 00:12:07 2006 +0000 @@ -1418,12 +1418,14 @@ ;; Pull files off rmail-inbox-list onto files as long as there is no ;; name conflict. A conflict happens when two inbox file names have ;; the same last component. - (let (list last-names) - (dolist (file rmail-inbox-list) - (unless (member (file-name-nondirectory file) last-names) - (push file list)) - (push (file-name-nondirectory file) last-names)) - (nreverse list))) + (let (files last-names) + (catch 'conflict + (dolist (file rmail-inbox-list) + (if (member (file-name-nondirectory file) last-names) + (throw 'conflict t) + (push file files)) + (push (file-name-nondirectory file) last-names))) + (nreverse files))) ;; RLK feature not added in this version: ;; argument specifies inbox file or files in various ways. @@ -2164,12 +2166,14 @@ ;; Deal with MIME (if (eq rmail-enable-mime t) (funcall rmail-show-mime-function) + (setq rmail-view-buffer rmail-buffer)) ;; Deal with the message headers and URLs.. (rmail-header-hide-headers) (rmail-highlight-headers) (when transient-mark-mode (deactivate-mark)) ;; Make sure that point in the Rmail window is at the beginning ;; of the buffer. + (goto-char (point-min)) (set-window-point (get-buffer-window rmail-buffer) (point)) ;; Run any User code. (run-hooks 'rmail-show-message-hook) @@ -2188,9 +2192,8 @@ (rmail-auto-file)) ;; Post back any status messages. (when blurb - (message blurb))))))) - -;;; NOT DONE + (message blurb)))))) + (defun rmail-redecode-body (coding) "Decode the body of the current message using coding system CODING. This is useful with mail messages that have malformed or missing @@ -2208,49 +2211,42 @@ to be used to fix messages encoded with 8-bit encodings, such as iso-8859, koi8-r, etc." (interactive "zCoding system for re-decoding this message: ") - (when (not rmail-enable-mime) - (or (eq major-mode 'rmail-mode) - (switch-to-buffer rmail-buffer)) - (save-excursion - (unwind-protect - (let ((msgbeg (rmail-desc-get-start rmail-current-message)) - (msgend (rmail-desc-get-end rmail-current-message)) - x-coding-header) - ;; We need the message headers pruned (we later restore - ;; the pruned stat to what it was, see the end of - ;; unwind-protect form). - (rmail-header-show-headers) - (narrow-to-region msgbeg msgend) - (goto-char (point-min)) - (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t) - (let ((old-coding (intern (match-string 1))) - (buffer-read-only nil)) - (check-coding-system old-coding) - ;; Make sure the new coding system uses the same EOL - ;; conversion, to prevent ^M characters from popping - ;; up all over the place. - (setq coding - (coding-system-change-eol-conversion - coding - (coding-system-eol-type old-coding))) - (setq x-coding-header (point-marker)) - (narrow-to-region msgbeg msgend) - (encode-coding-region (point) msgend old-coding) - (decode-coding-region (point) msgend coding) - (setq last-coding-system-used coding) - ;; Rewrite the coding-system header according - ;; to what we did. - (goto-char x-coding-header) - (delete-region (point) - (save-excursion - (beginning-of-line) - (point))) - (insert "X-Coding-System: " - (symbol-name last-coding-system-used)) - (set-marker x-coding-header nil) - (rmail-show-message)) - (error "No X-Coding-System header found"))) - (rmail-header-hide-headers))))) + (unless rmail-enable-mime + (with-current-buffer rmail-buffer + (save-excursion + (unwind-protect + (let ((start (rmail-desc-get-start rmail-current-message)) + (end (rmail-desc-get-end rmail-current-message)) + header) + ;; We need the message headers pruned (we later restore + ;; the pruned stat to what it was, see the end of + ;; unwind-protect form). + (rmail-header-show-headers) + (narrow-to-region start end) + (setq header (rmail-header-get-header "X-Coding-System")) + (if header + (let ((old-coding (intern header)) + (buffer-read-only nil)) + (check-coding-system old-coding) + ;; Make sure the new coding system uses the same EOL + ;; conversion, to prevent ^M characters from popping + ;; up all over the place. + (setq coding + (coding-system-change-eol-conversion + coding + (coding-system-eol-type old-coding))) + ;; Do the actual recoding. + (encode-coding-region start end old-coding) + (decode-coding-region start end coding) + ;; Rewrite the x-coding-system header according to + ;; what we did. + (setq last-coding-system-used coding) + (rmail-header-add-header + "X-Coding-System" + (symbol-name last-coding-system-used)) + (rmail-show-message rmail-current-message)) + (error "No X-Coding-System header found"))) + (rmail-header-hide-headers)))))) ;; Find all occurrences of certain fields, and highlight them. (defun rmail-highlight-headers ()