Mercurial > emacs
changeset 17011:d6a6cfeb9904
(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.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 20 Feb 1997 05:49:08 +0000 |
parents | b0a097ba0ec5 |
children | f1932b36f01d |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Thu Feb 20 05:48:39 1997 +0000 +++ b/lisp/mail/rmail.el Thu Feb 20 05:49:08 1997 +0000 @@ -1014,6 +1014,9 @@ ;; 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 @@ (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 @@ (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."