changeset 88251:5f2ee806ffbb

(rmail-process-new-messages): Simplify. (rmail-decode-quoted-printable): Delete unused function. (rmail-hex-string-to-integer): Likewise. (rmail-hex-char-to-integer): Likewise. (rmail-decode-mail-file): Renamed from `rmail-decode-mbox-file'.
author Henrik Enberg <henrik.enberg@telia.com>
date Sat, 21 Jan 2006 03:22:43 +0000
parents 61c503e4cee5
children aaab5dd1b031
files lisp/mail/rmail.el
diffstat 1 files changed, 27 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Sat Jan 21 01:30:30 2006 +0000
+++ b/lisp/mail/rmail.el	Sat Jan 21 03:22:43 2006 +0000
@@ -839,7 +839,7 @@
       (goto-char (point-max))
       (rmail-mode-2)
       ;; setup files coding system
-      (rmail-decode-mbox-file)
+      (rmail-decode-mail-file)
       ;;  We use `run-mail-hook' to remember whether we should run
       ;; `rmail-mode-hook' at the end.
       (setq run-mail-hook t)
@@ -862,26 +862,6 @@
     (if run-mail-hook
         (run-hooks 'rmail-mode-hook))))
 
-(defun rmail-decode-mbox-file ()
-  "Decode file to a suitable conding system."
-  (when (and (not rmail-enable-mime) rmail-enable-multibyte)
-    (let ((modifiedp (buffer-modified-p))
-	  (buffer-read-only nil)
-	  (coding-system rmail-file-coding-system))
-      (unless (and coding-system (coding-system-p coding-system))
-	(setq coding-system
-	      (car (detect-coding-with-priority
-		    (point-min) (point-max)
-		    '((coding-category-emacs-mule . emacs-mule))))))
-      (unless (memq coding-system '(undecided undecided-unix))
-	(set-buffer-modified-p t) ;; avoid locking when decoding
-	(let ((buffer-undo-list t))
-	  (decode-coding-region (point-min) (point-max) coding-system))
-	(setq coding-system last-coding-system-used))
-      (set-buffer-modified-p modifiedp)
-      (setq buffer-file-coding-system nil)
-      (setq save-buffer-coding-system (or coding-system 'undecided)))))
-
 (defun rmail-initialize-messages ()
   "Initialize message state based on messages in the buffer."
   (setq rmail-total-messages 0
@@ -1700,44 +1680,25 @@
 	(setq last-coding-system-used
 	      (coding-system-change-eol-conversion coding 0))))
 
-(defun rmail-hex-char-to-integer (character)
-  "Return CHARACTER's value interpreted as a hex digit."
-  (if (and (>= character ?0) (<= character ?9))
-      (- character ?0)
-    (let ((ch (logior character 32)))
-      (if (and (>= ch ?a) (<= ch ?f))
-	  (- ch (- ?a 10))
-	(error "Invalid hex digit `%c'" ch)))))
-
-(defun rmail-hex-string-to-integer (hex-string)
-  "Return decimal integer for HEX-STRING."
-  (let ((hex-num 0)
-	(index 0))
-    (while (< index (length hex-string))
-      (setq hex-num (+ (* hex-num 16)
-		       (rmail-hex-char-to-integer (aref hex-string index))))
-      (setq index (1+ index)))
-    hex-num))
-
-(defun rmail-decode-quoted-printable (from to)
-  "Decode Quoted-Printable in the region between FROM and TO."
-  (interactive "r")
-  (goto-char from)
-  (or (markerp to)
-      (setq to (copy-marker to)))
-  (while (search-forward "=" to t)
-    (cond ((eq (following-char) ?\n)
-	   (delete-char -1)
-	   (delete-char 1))
-	  ((looking-at "[0-9A-F][0-9A-F]")
-	   (let ((byte (rmail-hex-string-to-integer
-			(buffer-substring (point) (+ 2 (point))))))
-	     (delete-region (1- (point)) (+ 2 (point)))
-	     (insert byte)))
-	  ((looking-at "=")
-	   (delete-char 1))
-	  (t
-	   (message "Malformed MIME quoted-printable message")))))
+(defun rmail-decode-mail-file ()
+  "Decode mail file to a suitable conding system."
+  (when (and (not rmail-enable-mime) rmail-enable-multibyte)
+    (let ((modifiedp (buffer-modified-p))
+	  (buffer-read-only nil)
+	  (coding-system rmail-file-coding-system))
+      (unless (and coding-system (coding-system-p coding-system))
+	(setq coding-system
+	      (car (detect-coding-with-priority
+		    (point-min) (point-max)
+		    '((coding-category-emacs-mule . emacs-mule))))))
+      (unless (memq coding-system '(undecided undecided-unix))
+	(set-buffer-modified-p t) ;; avoid locking when decoding
+	(let ((buffer-undo-list t))
+	  (decode-coding-region (point-min) (point-max) coding-system))
+	(setq coding-system last-coding-system-used))
+      (set-buffer-modified-p modifiedp)
+      (setq buffer-file-coding-system nil)
+      (setq save-buffer-coding-system (or coding-system 'undecided)))))
 
 
 ;;;; *** Rmail Message Formatting and Header Manipulation ***
@@ -1966,14 +1927,13 @@
 	  (or rmail-enable-mime
 	      (not rmail-enable-multibyte)
 	      (let ((mime-charset
-		     (if (and rmail-decode-mime-charset
-			      (save-excursion
-				(goto-char start)
-				(search-forward "\n\n" nil t)
-				(let ((case-fold-search t))
-				  (re-search-backward
-				   rmail-mime-charset-pattern
-				   start t))))
+		     (when (and rmail-decode-mime-charset
+				(save-excursion
+				  (goto-char (rmail-header-get-limit))
+				  (let ((case-fold-search t))
+				    (re-search-backward
+				     rmail-mime-charset-pattern
+				     (point-min) t))))
 			 (intern (downcase (match-string 1))))))
 		(rmail-decode-region start (point) mime-charset)))