[mew-int 01201] converting mail in latin-9
Serge Basterot
serge.basterot at example.com
Tue Dec 10 05:55:29 JST 2002
Hi all,
For sending mail in french I'm using the sample that Tats gave us in
[mew-int 736], it convert mail in iso-8859-15, it's useful because
mew behavior is convert in UTF-8 outgoing mails when you reply to
mail encoded in latin-1 or latin-9. Since the 3.1rc2 mew release it
doesn't works anymore. With the sample outgoing mails are now
converting in us-ascii 7bit. Do you, Tats, or someone else, have
another sample for us ?
I have to mention too that I'm not using Mule-UCS but ucs-tables.el
for displaying latin caracters (you will find it easily on the
web). So for using Tats's sample with ucs-tables I commented out
some lines which refer to mule-ucs as following :
;;; sample.mew.el --- a sample of .mew.el related to coding system
;; This work is written by Tatsuya Kinoshita. Copyright is disclaimed.
;; You can add this to your ~/.mew.el, but there is NO WARRANTY.
(setq mew-charset-m17n "iso-8859-15")
(add-hook 'mew-send-hook 'my-mew-check-message)
(add-hook 'mew-post-hook 'my-mew-check-message)
(define-key mew-draft-body-map "\C-cu" 'my-mew-cs-unify-body)
(define-key mew-draft-body-map "\C-cU" 'my-mew-cs-force-convert-body)
(setq my-mew-charset-noask-list '("us-ascii" "iso-8859-1" "iso-2022-jp"))
(setq my-mew-cs-force-convert-default-cs mew-cs-m17n)
;; For Latin-9 environment
(setq my-mew-charset-noask-list '("us-ascii" "iso-8859-1" "iso-8859-15"))
(setq my-mew-cs-force-convert-default-cs 'iso-8859-15)
(defun my-mew-check-message ()
; (my-mew-cs-unify-body) ;; Mule-UCS is needed.
(my-mew-cs-force-convert-body) ;; Some characters will be disguised
(my-mew-charset-ask))
(defun my-mew-charset-ask ()
(let ((chset (my-mew-charset-guess-body)))
(if (and (mew-coding-system-p (mew-charset-to-cs chset))
(not (member chset my-mew-charset-noask-list)))
(if (not (y-or-n-p (format "Really encode with charset=%s? " chset)))
(error "Edit body")
))))
(defun my-mew-cs-unify-body ()
(interactive)
(let ((pos (point))
(cs 'utf-8-unix))
; (message "Evaluating (require 'un-define)...")
; (require 'un-define) ;; Mule-UCS
; (message "Evaluating (require 'un-define)...done")
; (message "Unifying...")
(when (mew-coding-system-p cs)
(mew-cs-encode-region (my-mew-body-min) (my-mew-body-max) cs)
(mew-cs-decode-region (my-mew-body-min) (my-mew-body-max) cs))
(goto-char pos)
(message "Unifying...done (charset=%s)" (my-mew-charset-guess-body))))
(defun my-mew-cs-force-convert-body (&optional arg)
(interactive "P")
(my-mew-cs-force-convert-region (my-mew-body-min) (my-mew-body-max) arg))
(defun my-mew-cs-force-convert-region (beg end &optional arg)
(interactive "r\nP")
(let* ((count (- end beg))
(default-cs my-mew-cs-force-convert-default-cs)
(tocs (if arg
(read-coding-system
(format "Coding-system (%s): " (symbol-name default-cs))
default-cs)
default-cs))
enc-beg cs-cur cs-next)
(if (not (mew-coding-system-p tocs))
(error "Unknown coding system %s" (symbol-name tocs)))
(message "Converting to %s..." (symbol-name tocs))
(push-mark end t t)
(goto-char beg)
(insert "\n") ;; for separating
(setq enc-beg (point))
(setq cs-cur nil)
(while (> count 0)
(setq cs-next (my-mew-cs-guess-region (point) (1+ (point))))
(when (not (equal cs-cur cs-next))
(mew-cs-encode-region enc-beg (point) cs-cur)
(setq enc-beg (point))
(setq cs-cur cs-next))
(goto-char (1+ (point)))
(setq count (1- count)))
(mew-cs-encode-region enc-beg (point) cs-cur)
(mew-cs-decode-region (1+ beg) (point) tocs)
(goto-char beg)
(delete-char 1) ;; delete "\n"
(message "Converting to %s...done" (symbol-name tocs))))
(defun my-mew-cs-guess-region (beg end)
(interactive "r")
(mew-charset-to-cs (mew-charset-guess-region beg end)))
(defun my-mew-charset-guess-body ()
(interactive)
(mew-charset-guess-region (my-mew-body-min) (my-mew-body-max)))
(defun my-mew-body-min ()
(interactive)
(save-excursion
(mew-header-goto-body)
(point)))
(defun my-mew-body-max ()
(interactive)
(save-excursion
(if (not (mew-attach-p))
(point-max)
(mew-attach-move-onto-body)
(setq max (point)))))
;; ends here
Thanks for help
--
Serge Basterot
More information about the Mew-int
mailing list