aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2001-01-22 17:14:47 +0000
committerEli Zaretskii2001-01-22 17:14:47 +0000
commitfd4976b812a6eeffc631b27e249013e0cc953848 (patch)
tree5ebab0a9fdc3967690a2b1b78c551f7496e3db93
parent4ddb57b2a25ff44c2ec2a5661b1b55637ced0f82 (diff)
downloademacs-fd4976b812a6eeffc631b27e249013e0cc953848.tar.gz
emacs-fd4976b812a6eeffc631b27e249013e0cc953848.zip
(rmail-redecode-body): New function.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/mail/rmail.el60
2 files changed, 62 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 403d179f34e..bd39533b70b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12001-01-22 Eli Zaretskii <eliz@is.elta.co.il> 12001-01-22 Eli Zaretskii <eliz@is.elta.co.il>
2 2
3 * mail/rmail.el (rmail-redecode-body): New function.
4
3 * icomplete.el (icomplete-minibuffer-setup-hook): Doc fix. 5 * icomplete.el (icomplete-minibuffer-setup-hook): Doc fix.
4 6
52001-01-22 Gerd Moellmann <gerd@gnu.org> 72001-01-22 Gerd Moellmann <gerd@gnu.org>
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index dfe32731794..e6bb8b3acf7 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2257,6 +2257,66 @@ If summary buffer is currently displayed, update current message there also."
2257 (if blurb 2257 (if blurb
2258 (message blurb)))))) 2258 (message blurb))))))
2259 2259
2260(defun rmail-redecode-body (coding)
2261 "Decode the body of the current message using coding system CODING.
2262This is useful with mail messages that have malformed or missing
2263charset= headers.
2264
2265This function assumes that the current message is already decoded
2266and displayed in the RMAIL buffer, but the coding system used to
2267decode it was incorrect. It then encodes the message back to its
2268original form, and decodes it again, using the coding system you
2269supply at the prompt.
2270
2271Note that if Emacs erroneously auto-detected one of the iso-2022
2272encodings in the message, this function might fail because the escape
2273sequences that switch between character sets and also single-shift and
2274locking-shift codes are impossible to recover. This function is meant
2275to be used to fix messages encoded with 8-bit encodings, such as
2276iso-8859, koi8-r, etc."
2277 (interactive "zCoding system for re-decoding this message: ")
2278 (when (not rmail-enable-mime)
2279 (or (eq major-mode 'rmail-mode)
2280 (switch-to-buffer rmail-buffer))
2281 (save-excursion
2282 (unwind-protect
2283 (let ((msgbeg (rmail-msgbeg rmail-current-message))
2284 (msgend (rmail-msgend rmail-current-message))
2285 x-coding-header)
2286 (narrow-to-region msgbeg msgend)
2287 (goto-char (point-min))
2288 (when (search-forward "\n*** EOOH ***\n" (point-max) t)
2289 (narrow-to-region msgbeg (point)))
2290 (goto-char (point-min))
2291 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
2292 (let ((old-coding (intern (match-string 1)))
2293 (buffer-read-only nil))
2294 (check-coding-system old-coding)
2295 ;; Make sure the new coding system uses the same EOL
2296 ;; conversion, to prevent ^M characters from popping
2297 ;; up all over the place.
2298 (setq coding
2299 (coding-system-change-eol-conversion
2300 coding
2301 (coding-system-eol-type old-coding)))
2302 (setq x-coding-header (point-marker))
2303 (narrow-to-region msgbeg msgend)
2304 (encode-coding-region (point) msgend old-coding)
2305 (decode-coding-region (point) msgend coding)
2306 (setq last-coding-system-used coding)
2307 ;; Rewrite the coding-system header according
2308 ;; to what we did.
2309 (goto-char x-coding-header)
2310 (delete-region (point)
2311 (save-excursion
2312 (beginning-of-line)
2313 (point)))
2314 (insert "X-Coding-System: "
2315 (symbol-name last-coding-system-used))
2316 (set-marker x-coding-header nil)
2317 (rmail-show-message))
2318 (error "No X-Coding-System header found")))))))
2319
2260;; Find all occurrences of certain fields, and highlight them. 2320;; Find all occurrences of certain fields, and highlight them.
2261(defun rmail-highlight-headers () 2321(defun rmail-highlight-headers ()
2262 ;; Do this only if the system supports faces. 2322 ;; Do this only if the system supports faces.