comparison lisp/mail/rmail.el @ 24209:d0853770c8e7

(rmail-decode-mime-charset): New variable. (rmail-mime-charset-pattern): New variable. (rmail-convert-to-babyl-format): Decode by MIME-charset if rmail-decode-mime-charset is non-nil.
author Richard M. Stallman <rms@gnu.org>
date Thu, 28 Jan 1999 03:13:51 +0000
parents ec89235ef2a6
children 33f8216be2f1
comparison
equal deleted inserted replaced
24208:6964e11724dc 24209:d0853770c8e7
356 ;;;###autoload 356 ;;;###autoload
357 (defvar rmail-mime-feature 'rmail-mime 357 (defvar rmail-mime-feature 'rmail-mime
358 "Feature to require to load MIME support in Rmail. 358 "Feature to require to load MIME support in Rmail.
359 When starting Rmail, if `rmail-enable-mime' is non-nil, 359 When starting Rmail, if `rmail-enable-mime' is non-nil,
360 this feature is required with `require'.") 360 this feature is required with `require'.")
361
362 ;;;###autoload
363 (defvar rmail-decode-mime-charset t
364 "*Non-nil means a message is decoded by MIME's charset specification.
365 If this variable is nil, or the message has not MIME specification,
366 the message is decoded as normal way.
367
368 If the variable `rmail-enable-mime' is non-nil, this variables is
369 ignored, and all the decoding work is done by a feature specified by
370 the variable `rmail-mime-feature'.")
371
372 ;;;###autoload
373 (defvar rmail-mime-charset-pattern
374 "^content-type:[ ]*text/plain;[ ]*charset=\\([^ \t\n]+\\)"
375 "Regexp to match MIME-charset specification in a header of message.
376 The first parenthesized expression should match the MIME-charset name.")
377
361 378
362 ;;; Regexp matching the delimiter of messages in UNIX mail format 379 ;;; Regexp matching the delimiter of messages in UNIX mail format
363 ;;; (UNIX From lines), minus the initial ^. Note that if you change 380 ;;; (UNIX From lines), minus the initial ^. Note that if you change
364 ;;; this expression, you must change the code in rmail-nuke-pinhead-header 381 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
365 ;;; that knows the exact ordering of the \\( \\) subexpressions. 382 ;;; that knows the exact ordering of the \\( \\) subexpressions.
1445 (if (> (length pass) 0) 1462 (if (> (length pass) 0)
1446 (setq pass (substring pass 0 -1)))))) 1463 (setq pass (substring pass 0 -1))))))
1447 (message "") 1464 (message "")
1448 (message nil) 1465 (message nil)
1449 pass)) 1466 pass))
1467
1468 ;; Decode the region specified by FROM and TO by CODING.
1469 ;; If CODING is nil or an invalid coding system, decode by `undecided'.
1470 (defun rmail-decode-region (from to coding)
1471 (if (or (not coding) (not (coding-system-p coding)))
1472 (setq coding 'undecided))
1473 (decode-coding-region from to coding))
1450 1474
1451 ;; the rmail-break-forwarded-messages feature is not implemented 1475 ;; the rmail-break-forwarded-messages feature is not implemented
1452 (defun rmail-convert-to-babyl-format () 1476 (defun rmail-convert-to-babyl-format ()
1453 (let ((count 0) start 1477 (let ((count 0) start
1454 (case-fold-search nil) 1478 (case-fold-search nil)
1603 (replace-match "\n^_")))); 2 chars: "^" and "_" 1627 (replace-match "\n^_")))); 2 chars: "^" and "_"
1604 (insert ?\^_) 1628 (insert ?\^_)
1605 (setq last-coding-system-used nil) 1629 (setq last-coding-system-used nil)
1606 (or rmail-enable-mime 1630 (or rmail-enable-mime
1607 (not rmail-enable-multibyte) 1631 (not rmail-enable-multibyte)
1608 (decode-coding-region start (point) 'undecided)) 1632 (let ((mime-charset
1633 (if (and rmail-decode-mime-charset
1634 (save-excursion
1635 (goto-char start)
1636 (search-forward "\n\n" nil t)
1637 (let ((case-fold-search t))
1638 (re-search-backward
1639 rmail-mime-charset-pattern
1640 start t))))
1641 (intern (downcase (match-string 1))))))
1642 (rmail-decode-region start (point) mime-charset)))
1609 (save-excursion 1643 (save-excursion
1610 (goto-char start) 1644 (goto-char start)
1611 (forward-line 3) 1645 (forward-line 3)
1612 (insert "X-Coding-System: " 1646 (insert "X-Coding-System: "
1613 (symbol-name last-coding-system-used) 1647 (symbol-name last-coding-system-used)