From: Karl Heuer Date: Thu, 20 Feb 1997 05:49:08 +0000 (+0000) Subject: (rmail-file-coding-system): New variable. X-Git-Tag: emacs-20.1~2934 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d0c3269a29e943036a4373cb9e28a9520b953ed3;p=emacs.git (rmail-file-coding-system): New variable. (rmail-insert-inbox-text): Perform character code conversion according to rmail-file-coding-system. (rmail-only-expunge): Pay attention to multibyte characters. --- diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 10dc8e70eb2..c4565650fe2 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -1014,6 +1014,9 @@ It returns t if it got any new messages." ;; Don't leave the buffer screwed up if we get a disk-full error. (rmail-show-message)))) +(defvar rmail-file-coding-system 'coding-system-iso2022-7 + "Coding system used in RMAIL file.") + (defun rmail-insert-inbox-text (files renamep) ;; Detect a locked file now, so that we avoid moving mail ;; out of the real inbox file. (That could scare people.) @@ -1143,7 +1146,27 @@ It returns t if it got any new messages." (if (file-exists-p tofile) (let (size) (goto-char (point-max)) - (setq size (nth 1 (insert-file-contents tofile))) + ;; At first, read the file as is (i.e. no decoding). + (setq size (nth 1 (let ((coding-system-for-read 'no-conversion)) + (insert-file-contents tofile)))) + ;; Then, decode the contents one by one. + (let ((pos (point))) + (cond ((looking-at "^From ") ; new mails. + (forward-line 1) + (while (not (eobp)) + (setq pos (point)) + (search-forward "\nFrom " nil 'move) + (decode-coding-region pos (point) + 'automatic-conversion))) + ((looking-at "BABYL OPTIONS:\\|\^L") ; Babyl format + (while (not (eobp)) + (setq pos (point)) + (search-forward "\n^_" nil 'move) + (decode-coding-region pos (point) + rmail-file-coding-system))) + (t ; Perhaps MMDF format. Convert all data at once. + (decode-coding-region (point) (point-max) + 'automatic-conversion)))) (goto-char (point-max)) (or (= (preceding-char) ?\n) (zerop size) @@ -2178,7 +2201,7 @@ Deleted messages stay in the file until the \\[rmail-expunge] command is given." (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax))) (rmail-show-message (if (zerop rmail-current-message) 1 nil)) - (forward-char opoint)))) + (goto-char (+ (point) opoint))))) (defun rmail-expunge () "Erase deleted messages from Rmail file and summary buffer."