Mercurial > emacs
comparison lisp/mail/rmail.el @ 90650:02cf29720f31
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 490-504)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 161-163)
- Update from CVS
- Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-130
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 07 Nov 2006 23:22:48 +0000 |
parents | 8dd8c8286063 e1c32a83bd29 |
children | 95d0cdf160ea |
comparison
equal
deleted
inserted
replaced
90649:d53934e7ddef | 90650:02cf29720f31 |
---|---|
2826 (with-current-buffer rmail-buffer | 2826 (with-current-buffer rmail-buffer |
2827 (rmail-auto-file)) | 2827 (rmail-auto-file)) |
2828 (if blurb | 2828 (if blurb |
2829 (message blurb)))))) | 2829 (message blurb)))))) |
2830 | 2830 |
2831 (defun rmail-redecode-body (coding) | 2831 (defun rmail-redecode-body (coding &optional raw) |
2832 "Decode the body of the current message using coding system CODING. | 2832 "Decode the body of the current message using coding system CODING. |
2833 This is useful with mail messages that have malformed or missing | 2833 This is useful with mail messages that have malformed or missing |
2834 charset= headers. | 2834 charset= headers. |
2835 | 2835 |
2836 This function assumes that the current message is already decoded | 2836 This function assumes that the current message is already decoded |
2837 and displayed in the RMAIL buffer, but the coding system used to | 2837 and displayed in the RMAIL buffer, but the coding system used to |
2838 decode it was incorrect. It then encodes the message back to its | 2838 decode it was incorrect. It then encodes the message back to its |
2839 original form, and decodes it again, using the coding system CODING. | 2839 original form, and decodes it again, using the coding system CODING. |
2840 | |
2841 Optional argument RAW, if non-nil, means don't encode the message | |
2842 before decoding it with the new CODING. This is useful if the current | |
2843 message text was produced by some function which invokes `insert', | |
2844 since `insert' leaves unibyte character codes 128 through 255 unconverted | |
2845 to multibyte. One example of such a situation is when the text was | |
2846 produced by `base64-decode-region'. | |
2847 | |
2848 Interactively, invoke the function with a prefix argument to set RAW | |
2849 non-nil. | |
2840 | 2850 |
2841 Note that if Emacs erroneously auto-detected one of the iso-2022 | 2851 Note that if Emacs erroneously auto-detected one of the iso-2022 |
2842 encodings in the message, this function might fail because the escape | 2852 encodings in the message, this function might fail because the escape |
2843 sequences that switch between character sets and also single-shift and | 2853 sequences that switch between character sets and also single-shift and |
2844 locking-shift codes are impossible to recover. This function is meant | 2854 locking-shift codes are impossible to recover. This function is meant |
2847 (interactive "zCoding system for re-decoding this message: ") | 2857 (interactive "zCoding system for re-decoding this message: ") |
2848 (when (not rmail-enable-mime) | 2858 (when (not rmail-enable-mime) |
2849 (or (eq major-mode 'rmail-mode) | 2859 (or (eq major-mode 'rmail-mode) |
2850 (switch-to-buffer rmail-buffer)) | 2860 (switch-to-buffer rmail-buffer)) |
2851 (save-excursion | 2861 (save-excursion |
2852 (let ((pruned (rmail-msg-is-pruned))) | 2862 (let ((pruned (rmail-msg-is-pruned)) |
2863 (raw (or raw current-prefix-arg))) | |
2853 (unwind-protect | 2864 (unwind-protect |
2854 (let ((msgbeg (rmail-msgbeg rmail-current-message)) | 2865 (let ((msgbeg (rmail-msgbeg rmail-current-message)) |
2855 (msgend (rmail-msgend rmail-current-message)) | 2866 (msgend (rmail-msgend rmail-current-message)) |
2856 x-coding-header) | 2867 x-coding-header) |
2857 ;; We need the message headers pruned (we later restore | 2868 ;; We need the message headers pruned (we later restore |
2881 (if (memq (coding-system-base old-coding) '(nil undecided)) | 2892 (if (memq (coding-system-base old-coding) '(nil undecided)) |
2882 (setq old-coding | 2893 (setq old-coding |
2883 (car (find-coding-systems-region msgbeg msgend)))) | 2894 (car (find-coding-systems-region msgbeg msgend)))) |
2884 (setq x-coding-header (point-marker)) | 2895 (setq x-coding-header (point-marker)) |
2885 (narrow-to-region msgbeg msgend) | 2896 (narrow-to-region msgbeg msgend) |
2886 (encode-coding-region (point) msgend old-coding) | 2897 (and (null raw) |
2898 ;; If old and new encoding are the same, it | |
2899 ;; clearly doesn't make sense to encode. | |
2900 (not (coding-system-equal | |
2901 (coding-system-base old-coding) | |
2902 (coding-system-base coding))) | |
2903 ;; If the body includes only eight-bit-* | |
2904 ;; characters, encoding might fail, e.g. with | |
2905 ;; UTF-8, and isn't needed anyway. | |
2906 (> (length (delq 'ascii | |
2907 (delq 'eight-bit-graphic | |
2908 (delq 'eight-bit-control | |
2909 (find-charset-region | |
2910 msgbeg msgend))))) | |
2911 0) | |
2912 (encode-coding-region (point) msgend old-coding)) | |
2887 (decode-coding-region (point) msgend coding) | 2913 (decode-coding-region (point) msgend coding) |
2888 (setq last-coding-system-used coding) | 2914 (setq last-coding-system-used coding) |
2889 ;; Rewrite the coding-system header according | 2915 ;; Rewrite the coding-system header according |
2890 ;; to what we did. | 2916 ;; to what we did. |
2891 (goto-char x-coding-header) | 2917 (goto-char x-coding-header) |