/[emacs]/emacs/lisp/gnus/mm-util.el
ViewVC logotype

Diff of /emacs/lisp/gnus/mm-util.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by miles, Thu Nov 4 08:12:39 2004 UTC revision 1.35 by miles, Sun Dec 26 23:33:51 2004 UTC
# Line 576  This affects whether coding conversion s Line 576  This affects whether coding conversion s
576                  (length (memq (coding-system-base b) priorities)))                  (length (memq (coding-system-base b) priorities)))
577             t))))             t))))
578    
579    (eval-when-compile
580      (autoload 'latin-unity-massage-name "latin-unity")
581      (autoload 'latin-unity-maybe-remap "latin-unity")
582      (autoload 'latin-unity-representations-feasible-region "latin-unity")
583      (autoload 'latin-unity-representations-present-region "latin-unity")
584      (defvar latin-unity-coding-systems)
585      (defvar latin-unity-ucs-list))
586    
587    (defun mm-xemacs-find-mime-charset-1 (begin end)
588      "Determine which MIME charset to use to send region as message.
589    This uses the XEmacs-specific latin-unity package to better handle the
590    case where identical characters from diverse ISO-8859-? character sets
591    can be encoded using a single one of the corresponding coding systems.
592    
593    It treats `mm-coding-system-priorities' as the list of preferred
594    coding systems; a useful example setting for this list in Western
595    Europe would be '(iso-8859-1 iso-8859-15 utf-8), which would default
596    to the very standard Latin 1 coding system, and only move to coding
597    systems that are less supported as is necessary to encode the
598    characters that exist in the buffer.
599    
600    Latin Unity doesn't know about those non-ASCII Roman characters that
601    are available in various East Asian character sets.  As such, its
602    behavior if you have a JIS 0212 LATIN SMALL LETTER A WITH ACUTE in a
603    buffer and it can otherwise be encoded as Latin 1, won't be ideal.
604    But this is very much a corner case, so don't worry about it."
605      (let ((systems mm-coding-system-priorities) csets psets curset)
606    
607        ;; Load the Latin Unity library, if available.
608        (when (and (not (featurep 'latin-unity)) (locate-library "latin-unity"))
609          (require 'latin-unity))
610    
611        ;; Now, can we use it?
612        (if (featurep 'latin-unity)
613            (progn
614              (setq csets (latin-unity-representations-feasible-region begin end)
615                    psets (latin-unity-representations-present-region begin end))
616    
617              (catch 'done
618    
619                ;; Pass back the first coding system in the preferred list
620                ;; that can encode the whole region.
621                (dolist (curset systems)
622                  (setq curset (latin-unity-massage-name 'buffer-default curset))
623    
624                  ;; If the coding system is a universal coding system, then
625                  ;; it can certainly encode all the characters in the region.
626                  (if (memq curset latin-unity-ucs-list)
627                      (throw 'done (list curset)))
628    
629                  ;; If a coding system isn't universal, and isn't in
630                  ;; the list that latin unity knows about, we can't
631                  ;; decide whether to use it here. Leave that until later
632                  ;; in `mm-find-mime-charset-region' function, whence we
633                  ;; have been called.
634                  (unless (memq curset latin-unity-coding-systems)
635                    (throw 'done nil))
636    
637                  ;; Right, we know about this coding system, and it may
638                  ;; conceivably be able to encode all the characters in
639                  ;; the region.
640                  (if (latin-unity-maybe-remap begin end curset csets psets t)
641                      (throw 'done (list curset))))
642    
643                ;; Can't encode using anything from the
644                ;; `mm-coding-system-priorities' list.
645                ;; Leave `mm-find-mime-charset' to do most of the work.
646                nil))
647    
648          ;; Right, latin unity isn't available; let `mm-find-charset-region'
649          ;; take its default action, which equally applies to GNU Emacs.
650          nil)))
651    
652    (defmacro mm-xemacs-find-mime-charset (begin end)
653      (when (featurep 'xemacs)
654        `(mm-xemacs-find-mime-charset-1 ,begin ,end)))
655    
656  (defun mm-find-mime-charset-region (b e &optional hack-charsets)  (defun mm-find-mime-charset-region (b e &optional hack-charsets)
657    "Return the MIME charsets needed to encode the region between B and E.    "Return the MIME charsets needed to encode the region between B and E.
658  nil means ASCII, a single-element list represents an appropriate MIME  nil means ASCII, a single-element list represents an appropriate MIME
# Line 617  charset, and a longer list means no appr Line 694  charset, and a longer list means no appr
694                           (setq systems nil                           (setq systems nil
695                                 charsets (list cs))))))                                 charsets (list cs))))))
696                 charsets))                 charsets))
697          ;; Otherwise we're not multibyte, we're XEmacs, or a single          ;; If we're XEmacs, and some coding system is appropriate,
698          ;; coding system won't cover it.          ;; mm-xemacs-find-mime-charset will return an appropriate list.
699            ;; Otherwise, we'll get nil, and the next setq will get invoked.
700            (setq charsets (mm-xemacs-find-mime-charset b e))
701    
702            ;; We're not multibyte, or a single coding system won't cover it.
703          (setq charsets          (setq charsets
704                (mm-delete-duplicates                (mm-delete-duplicates
705                 (mapcar 'mm-mime-charset                 (mapcar 'mm-mime-charset

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26