annotate lisp/gnus/mm-util.el @ 76149:75b3a340972a

* configure.in (xtensa-*-linux-gnu*): New configuration. * configure: Regenerate. * m/xtensa.h: New file.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 26 Feb 2007 05:40:11 +0000
parents e3694f1cb928
children f0705c4da65a 95d0cdf160ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1 ;;; mm-util.el --- Utility functions for Mule and low level things
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64736
diff changeset
2
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64736
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74214
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62943
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62943
diff changeset
23 ;; Boston, MA 02110-1301, USA.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
29 (eval-when-compile (require 'cl))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 (require 'mail-prsvr)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
32 (eval-and-compile
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
33 (mapcar
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
34 (lambda (elem)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
35 (let ((nfunc (intern (format "mm-%s" (car elem)))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
36 (if (fboundp (car elem))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
37 (defalias nfunc (car elem))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
38 (defalias nfunc (cdr elem)))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
39 '((decode-coding-string . (lambda (s a) s))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
40 (encode-coding-string . (lambda (s a) s))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
41 (encode-coding-region . ignore)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
42 (coding-system-list . ignore)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
43 (decode-coding-region . ignore)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
44 (char-int . identity)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
45 (coding-system-equal . equal)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
46 (annotationp . ignore)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
47 (set-buffer-file-coding-system . ignore)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
48 (make-char
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
49 . (lambda (charset int)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
50 (int-to-char int)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
51 (read-charset
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
52 . (lambda (prompt)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
53 "Return a charset."
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
54 (intern
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
55 (completing-read
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
56 prompt
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
57 (mapcar (lambda (e) (list (symbol-name (car e))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
58 mm-mime-mule-charset-alist)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
59 nil t))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
60 (subst-char-in-string
61424
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
61 . (lambda (from to string &optional inplace)
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
62 ;; stolen (and renamed) from nnheader.el
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
63 "Replace characters in STRING from FROM to TO.
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
64 Unless optional argument INPLACE is non-nil, return a new string."
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
65 (let ((string (if inplace string (copy-sequence string)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
66 (len (length string))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
67 (idx 0))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
68 ;; Replace all occurrences of FROM with TO.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
69 (while (< idx len)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
70 (when (= (aref string idx) from)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
71 (aset string idx to))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
72 (setq idx (1+ idx)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
73 string)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
74 (string-as-unibyte . identity)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
75 (string-make-unibyte . identity)
61434
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
76 ;; string-as-multibyte often doesn't really do what you think it does.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
77 ;; Example:
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
78 ;; (aref (string-as-multibyte "\201") 0) -> 129 (aka ?\201)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
79 ;; (aref (string-as-multibyte "\300") 0) -> 192 (aka ?\300)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
80 ;; (aref (string-as-multibyte "\300\201") 0) -> 192 (aka ?\300)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
81 ;; (aref (string-as-multibyte "\300\201") 1) -> 129 (aka ?\201)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
82 ;; but
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
83 ;; (aref (string-as-multibyte "\201\300") 0) -> 2240
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
84 ;; (aref (string-as-multibyte "\201\300") 1) -> <error>
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
85 ;; Better use string-to-multibyte or encode-coding-string.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
86 ;; If you really need string-as-multibyte somewhere it's usually
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
87 ;; because you're using the internal emacs-mule representation (maybe
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
88 ;; because you're using string-as-unibyte somewhere), which is
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
89 ;; generally a problem in itself.
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
90 ;; Here is an approximate equivalence table to help think about it:
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
91 ;; (string-as-multibyte s) ~= (decode-coding-string s 'emacs-mule)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
92 ;; (string-to-multibyte s) ~= (decode-coding-string s 'binary)
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
93 ;; (string-make-multibyte s) ~= (decode-coding-string s locale-coding-system)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
94 (string-as-multibyte . identity)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
95 (multibyte-string-p . ignore)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
96 (insert-byte . insert-char)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
97 (multibyte-char-to-unibyte . identity))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
98
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
99 (eval-and-compile
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
100 (cond
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
101 ((fboundp 'replace-in-string)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
102 (defalias 'mm-replace-in-string 'replace-in-string))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
103 ((fboundp 'replace-regexp-in-string)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
104 (defun mm-replace-in-string (string regexp newtext &optional literal)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
105 "Replace all matches for REGEXP with NEWTEXT in STRING.
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
106 If LITERAL is non-nil, insert NEWTEXT literally. Return a new
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
107 string containing the replacements.
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
108
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
109 This is a compatibility function for different Emacsen."
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
110 (replace-regexp-in-string regexp newtext string nil literal)))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
111 (t
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
112 (defun mm-replace-in-string (string regexp newtext &optional literal)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
113 "Replace all matches for REGEXP with NEWTEXT in STRING.
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
114 If LITERAL is non-nil, insert NEWTEXT literally. Return a new
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
115 string containing the replacements.
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
116
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
117 This is a compatibility function for different Emacsen."
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
118 (let ((start 0) tail)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
119 (while (string-match regexp string start)
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
120 (setq tail (- (length string) (match-end 0)))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
121 (setq string (replace-match newtext nil literal string))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
122 (setq start (- (length string) tail))))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
123 string))))
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
124
74214
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
125 (defalias 'mm-string-to-multibyte
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
126 (cond
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
127 ((featurep 'xemacs)
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
128 'identity)
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
129 ((fboundp 'string-to-multibyte)
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
130 'string-to-multibyte)
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
131 (t
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
132 (lambda (string)
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
133 "Return a multibyte string with the same individual chars as string."
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
134 (mapconcat
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
135 (lambda (ch) (mm-string-as-multibyte (char-to-string ch)))
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
136 string "")))))
7cf0e45e7c70 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73546
diff changeset
137
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
138 (eval-and-compile
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
139 (defalias 'mm-char-or-char-int-p
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
140 (cond
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
141 ((fboundp 'char-or-char-int-p) 'char-or-char-int-p)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
142 ((fboundp 'char-valid-p) 'char-valid-p)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
143 (t 'identity))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
144
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
145 ;; Fixme: This seems always to be used to read a MIME charset, so it
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
146 ;; should be re-named and fixed (in Emacs) to offer completion only on
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
147 ;; proper charset names (base coding systems which have a
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
148 ;; mime-charset defined). XEmacs doesn't believe in mime-charset;
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
149 ;; test with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
150 ;; `(or (coding-system-get 'iso-8859-1 'mime-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
151 ;; (coding-system-get 'iso-8859-1 :mime-charset))'
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
152 ;; Actually, there should be an `mm-coding-system-mime-charset'.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
153 (eval-and-compile
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
154 (defalias 'mm-read-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
155 (cond
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
156 ((fboundp 'read-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
157 (if (and (featurep 'xemacs)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
158 (<= (string-to-number emacs-version) 21.1))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
159 (lambda (prompt &optional default-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
160 (read-coding-system prompt))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
161 'read-coding-system))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
162 (t (lambda (prompt &optional default-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
163 "Prompt the user for a coding system."
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
164 (completing-read
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
165 prompt (mapcar (lambda (s) (list (symbol-name (car s))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
166 mm-mime-mule-charset-alist)))))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
167
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
168 (defvar mm-coding-system-list nil)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
169 (defun mm-get-coding-system-list ()
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
170 "Get the coding system list."
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
171 (or mm-coding-system-list
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
172 (setq mm-coding-system-list (mm-coding-system-list))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
173
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
174 (defun mm-coding-system-p (cs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
175 "Return non-nil if CS is a symbol naming a coding system.
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
176 In XEmacs, also return non-nil if CS is a coding system object.
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
177 If CS is available, return CS itself in Emacs, and return a coding
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
178 system object in XEmacs."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
179 (if (fboundp 'find-coding-system)
61424
ad05d91d3598 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-243
Miles Bader <miles@gnu.org>
parents: 61126
diff changeset
180 (and cs (find-coding-system cs))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
181 (if (fboundp 'coding-system-p)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
182 (when (coding-system-p cs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
183 cs)
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68940
diff changeset
184 ;; no-MULE XEmacs:
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
185 (car (memq cs (mm-get-coding-system-list))))))
36556
8af75e618534 (mm-mime-mule-charset-alist): Move it after definition of
Dave Love <fx@gnu.org>
parents: 36539
diff changeset
186
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
187 (defun mm-codepage-setup (number &optional alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
188 "Create a coding system cpNUMBER.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
189 The coding system is created using `codepage-setup'. If ALIAS is
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
190 non-nil, an alias is created and added to
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
191 `mm-charset-synonym-alist'. If ALIAS is a string, it's used as
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
192 the alias. Else windows-NUMBER is used."
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
193 (interactive
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
194 (let ((completion-ignore-case t)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
195 (candidates (cp-supported-codepages)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
196 (list (completing-read "Setup DOS Codepage: (default 437) " candidates
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
197 nil t nil nil "437"))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
198 (when alias
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
199 (setq alias (if (stringp alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
200 (intern alias)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
201 (intern (format "windows-%s" number)))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
202 (let* ((cp (intern (format "cp%s" number))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
203 (unless (mm-coding-system-p cp)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
204 (codepage-setup number))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
205 (when (and alias
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
206 ;; Don't add alias if setup of cp failed.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
207 (mm-coding-system-p cp))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
208 (add-to-list 'mm-charset-synonym-alist (cons alias cp)))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
209
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
210 (defvar mm-charset-synonym-alist
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
211 `(
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
212 ;; Not in XEmacs, but it's not a proper MIME charset anyhow.
40621
11741b5b7d18 2001-11-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40542
diff changeset
213 ,@(unless (mm-coding-system-p 'x-ctext)
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
214 '((x-ctext . ctext)))
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
215 ;; ISO-8859-15 is very similar to ISO-8859-1. But it's _different_ in 8
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
216 ;; positions!
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
217 ,@(unless (mm-coding-system-p 'iso-8859-15)
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
218 '((iso-8859-15 . iso-8859-1)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
219 ;; BIG-5HKSCS is similar to, but different than, BIG-5.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
220 ,@(unless (mm-coding-system-p 'big5-hkscs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
221 '((big5-hkscs . big5)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
222 ;; A Microsoft misunderstanding.
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
223 ,@(when (and (not (mm-coding-system-p 'unicode))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
224 (mm-coding-system-p 'utf-16-le))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
225 '((unicode . utf-16-le)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
226 ;; A Microsoft misunderstanding.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
227 ,@(unless (mm-coding-system-p 'ks_c_5601-1987)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
228 (if (mm-coding-system-p 'cp949)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
229 '((ks_c_5601-1987 . cp949))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
230 '((ks_c_5601-1987 . euc-kr))))
71926
e5faa9959a89 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71262
diff changeset
231 ;; Windows-31J is Windows Codepage 932.
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
232 ,@(when (and (not (mm-coding-system-p 'windows-31j))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
233 (mm-coding-system-p 'cp932))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
234 '((windows-31j . cp932)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
235 )
73546
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
236 "A mapping from unknown or invalid charset names to the real charset names.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
237
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
238 See `mm-codepage-iso-8859-list' and `mm-codepage-ibm-list'.")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
239
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
240 (defcustom mm-codepage-iso-8859-list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
241 (list 1250 ;; Windows-1250 is a variant of Latin-2 heavily used by Microsoft
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
242 ;; Outlook users in Czech republic. Use this to allow reading of
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
243 ;; their e-mails. cp1250 should be defined by M-x codepage-setup
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
244 ;; (Emacs 21).
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
245 '(1252 . 1) ;; Windows-1252 is a superset of iso-8859-1 (West
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
246 ;; Europe). See also `gnus-article-dumbquotes-map'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
247 '(1254 . 9) ;; Windows-1254 is a superset of iso-8859-9 (Turkish).
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
248 '(1255 . 8));; Windows-1255 is a superset of iso-8859-8 (Hebrew).
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
249 "A list of Windows codepage numbers and iso-8859 charset numbers.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
250
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
251 If an element is a number corresponding to a supported windows
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
252 codepage, appropriate entries to `mm-charset-synonym-alist' are
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
253 added by `mm-setup-codepage-iso-8859'. An element may also be a
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
254 cons cell where the car is a codepage number and the cdr is the
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
255 corresponding number of an iso-8859 charset."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
256 :type '(list (set :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
257 (const 1250 :tag "Central and East European")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
258 (const (1252 . 1) :tag "West European")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
259 (const (1254 . 9) :tag "Turkish")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
260 (const (1255 . 8) :tag "Hebrew"))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
261 (repeat :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
262 :tag "Other options"
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
263 (choice
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
264 (integer :tag "Windows codepage number")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
265 (cons (integer :tag "Windows codepage number")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
266 (integer :tag "iso-8859 charset number")))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
267 :version "22.1" ;; Gnus 5.10.9
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
268 :group 'mime)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
269
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
270 (defcustom mm-codepage-ibm-list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
271 (list 437 ;; (US etc.)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
272 860 ;; (Portugal)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
273 861 ;; (Iceland)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
274 862 ;; (Israel)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
275 863 ;; (Canadian French)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
276 865 ;; (Nordic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
277 852 ;;
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
278 850 ;; (Latin 1)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
279 855 ;; (Cyrillic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
280 866 ;; (Cyrillic - Russian)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
281 857 ;; (Turkish)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
282 864 ;; (Arabic)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
283 869 ;; (Greek)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
284 874);; (Thai)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
285 ;; In Emacs 23 (unicode), cp... and ibm... are aliases.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
286 ;; Cf. http://thread.gmane.org/v9lkng5nwy.fsf@marauder.physik.uni-ulm.de
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
287 "List of IBM codepage numbers.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
288
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
289 The codepage mappings slighly differ between IBM and other vendors.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
290 See \"ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/IBM/README.TXT\".
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
291
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
292 If an element is a number corresponding to a supported windows
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
293 codepage, appropriate entries to `mm-charset-synonym-alist' are
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
294 added by `mm-setup-codepage-ibm'."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
295 :type '(list (set :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
296 (const 437 :tag "US etc.")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
297 (const 860 :tag "Portugal")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
298 (const 861 :tag "Iceland")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
299 (const 862 :tag "Israel")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
300 (const 863 :tag "Canadian French")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
301 (const 865 :tag "Nordic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
302 (const 852)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
303 (const 850 :tag "Latin 1")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
304 (const 855 :tag "Cyrillic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
305 (const 866 :tag "Cyrillic - Russian")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
306 (const 857 :tag "Turkish")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
307 (const 864 :tag "Arabic")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
308 (const 869 :tag "Greek")
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
309 (const 874 :tag "Thai"))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
310 (repeat :inline t
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
311 :tag "Other options"
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
312 (integer :tag "Codepage number")))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
313 :version "22.1" ;; Gnus 5.10.9
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
314 :group 'mime)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
315
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
316 (defun mm-setup-codepage-iso-8859 (&optional list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
317 "Add appropriate entries to `mm-charset-synonym-alist'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
318 Unless LIST is given, `mm-codepage-iso-8859-list' is used."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
319 (unless list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
320 (setq list mm-codepage-iso-8859-list))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
321 (dolist (i list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
322 (let (cp windows iso)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
323 (if (consp i)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
324 (setq cp (intern (format "cp%d" (car i)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
325 windows (intern (format "windows-%d" (car i)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
326 iso (intern (format "iso-8859-%d" (cdr i))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
327 (setq cp (intern (format "cp%d" i))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
328 windows (intern (format "windows-%d" i))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
329 (unless (mm-coding-system-p windows)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
330 (if (mm-coding-system-p cp)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
331 (add-to-list 'mm-charset-synonym-alist (cons windows cp))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
332 (add-to-list 'mm-charset-synonym-alist (cons windows iso)))))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
333
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
334 (defun mm-setup-codepage-ibm (&optional list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
335 "Add appropriate entries to `mm-charset-synonym-alist'.
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
336 Unless LIST is given, `mm-codepage-ibm-list' is used."
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
337 (unless list
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
338 (setq list mm-codepage-ibm-list))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
339 (dolist (number list)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
340 (let ((ibm (intern (format "ibm%d" number)))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
341 (cp (intern (format "cp%d" number))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
342 (when (and (not (mm-coding-system-p ibm))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
343 (mm-coding-system-p cp))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
344 (add-to-list 'mm-charset-synonym-alist (cons ibm cp))))))
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
345
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
346 ;; Initialize:
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
347 (mm-setup-codepage-iso-8859)
b8d97ed52a0a Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73370
diff changeset
348 (mm-setup-codepage-ibm)
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
349
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
350 (defcustom mm-charset-override-alist
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
351 `((iso-8859-1 . windows-1252))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
352 "A mapping from undesired charset names to their replacement.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
353
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
354 You may add pairs like (iso-8859-1 . windows-1252) here,
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
355 i.e. treat iso-8859-1 as windows-1252. windows-1252 is a
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
356 superset of iso-8859-1."
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
357 :type '(list (set :inline t
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
358 (const (iso-8859-1 . windows-1252))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
359 (const (undecided . windows-1252)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
360 (repeat :inline t
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
361 :tag "Other options"
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
362 (cons (symbol :tag "From charset")
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
363 (symbol :tag "To charset"))))
73224
36dcde72adad Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71926
diff changeset
364 :version "22.1" ;; Gnus 5.10.9
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
365 :group 'mime)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
366
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
367 (defcustom mm-charset-eval-alist
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
368 (if (featurep 'xemacs)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
369 nil ;; I don't know what would be useful for XEmacs.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
370 '(;; Emacs 21 offers 1250 1251 1253 1257. Emacs 22 provides autoloads for
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
371 ;; 1250-1258 (i.e. `mm-codepage-setup' does nothing).
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
372 (windows-1250 . (mm-codepage-setup 1250 t))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
373 (windows-1251 . (mm-codepage-setup 1251 t))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
374 (windows-1253 . (mm-codepage-setup 1253 t))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
375 (windows-1257 . (mm-codepage-setup 1257 t))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
376 "An alist of (CHARSET . FORM) pairs.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
377 If an article is encoded in an unknown CHARSET, FORM is
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
378 evaluated. This allows to load additional libraries providing
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
379 charsets on demand. If supported by your Emacs version, you
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
380 could use `autoload-coding-system' here."
73224
36dcde72adad Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 71926
diff changeset
381 :version "22.1" ;; Gnus 5.10.9
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
382 :type '(list (set :inline t
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
383 (const (windows-1250 . (mm-codepage-setup 1250 t)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
384 (const (windows-1251 . (mm-codepage-setup 1251 t)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
385 (const (windows-1253 . (mm-codepage-setup 1253 t)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
386 (const (windows-1257 . (mm-codepage-setup 1257 t)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
387 (const (cp850 . (mm-codepage-setup 850 nil))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
388 (repeat :inline t
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
389 :tag "Other options"
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
390 (cons (symbol :tag "charset")
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
391 (symbol :tag "form"))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
392 :group 'mime)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
393
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
394 (defvar mm-binary-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
395 (cond
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
396 ((mm-coding-system-p 'binary) 'binary)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
397 ((mm-coding-system-p 'no-conversion) 'no-conversion)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
398 (t nil))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
399 "100% binary coding system.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
400
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
401 (defvar mm-text-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
402 (or (if (memq system-type '(windows-nt ms-dos ms-windows))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
403 (and (mm-coding-system-p 'raw-text-dos) 'raw-text-dos)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
404 (and (mm-coding-system-p 'raw-text) 'raw-text))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
405 mm-binary-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
406 "Text-safe coding system (For removing ^M).")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
407
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
408 (defvar mm-text-coding-system-for-write nil
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
409 "Text coding system for write.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
410
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
411 (defvar mm-auto-save-coding-system
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
412 (cond
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
413 ((mm-coding-system-p 'utf-8-emacs) ; Mule 7
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
414 (if (memq system-type '(windows-nt ms-dos ms-windows))
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
415 (if (mm-coding-system-p 'utf-8-emacs-dos)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
416 'utf-8-emacs-dos mm-binary-coding-system)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
417 'utf-8-emacs))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
418 ((mm-coding-system-p 'emacs-mule)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
419 (if (memq system-type '(windows-nt ms-dos ms-windows))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
420 (if (mm-coding-system-p 'emacs-mule-dos)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
421 'emacs-mule-dos mm-binary-coding-system)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
422 'emacs-mule))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
423 ((mm-coding-system-p 'escape-quoted) 'escape-quoted)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
424 (t mm-binary-coding-system))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
425 "Coding system of auto save file.")
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
426
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
427 (defvar mm-universal-coding-system mm-auto-save-coding-system
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
428 "The universal coding system.")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
429
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
430 ;; Fixme: some of the cars here aren't valid MIME charsets. That
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
431 ;; should only matter with XEmacs, though.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (defvar mm-mime-mule-charset-alist
35793
46d71cfa2272 (mm-mime-mule-charset-alist)
Dave Love <fx@gnu.org>
parents: 35618
diff changeset
433 `((us-ascii ascii)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (iso-8859-1 latin-iso8859-1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (iso-8859-2 latin-iso8859-2)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (iso-8859-3 latin-iso8859-3)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (iso-8859-4 latin-iso8859-4)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (iso-8859-5 cyrillic-iso8859-5)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 ;; Non-mule (X)Emacs uses the last mule-charset for 8bit characters.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
440 ;; The fake mule-charset, gnus-koi8-r, tells Gnus that the default
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 ;; charset is koi8-r, not iso-8859-5.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (koi8-r cyrillic-iso8859-5 gnus-koi8-r)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (iso-8859-6 arabic-iso8859-6)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (iso-8859-7 greek-iso8859-7)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (iso-8859-8 hebrew-iso8859-8)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (iso-8859-9 latin-iso8859-9)
35148
a408e1d28e3d (mm-mime-mule-charset-alist): Add Latin-{8,9}.
Dave Love <fx@gnu.org>
parents: 34724
diff changeset
447 (iso-8859-14 latin-iso8859-14)
a408e1d28e3d (mm-mime-mule-charset-alist): Add Latin-{8,9}.
Dave Love <fx@gnu.org>
parents: 34724
diff changeset
448 (iso-8859-15 latin-iso8859-15)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (viscii vietnamese-viscii-lower)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (iso-2022-jp latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (euc-kr korean-ksc5601)
35838
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35793
diff changeset
452 (gb2312 chinese-gb2312)
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35793
diff changeset
453 (big5 chinese-big5-1 chinese-big5-2)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (tibetan tibetan)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (thai-tis620 thai-tis620)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
456 (windows-1251 cyrillic-iso8859-5)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (iso-2022-7bit ethiopic arabic-1-column arabic-2-column)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 chinese-gb2312 japanese-jisx0208
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
461 korean-ksc5601 japanese-jisx0212)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 chinese-gb2312 japanese-jisx0208
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 korean-ksc5601 japanese-jisx0212
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 chinese-cns11643-1 chinese-cns11643-2)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (iso-2022-int-1 latin-iso8859-1 latin-iso8859-2
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 cyrillic-iso8859-5 greek-iso8859-7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 latin-jisx0201 japanese-jisx0208-1978
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 chinese-gb2312 japanese-jisx0208
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 korean-ksc5601 japanese-jisx0212
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 chinese-cns11643-1 chinese-cns11643-2
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 chinese-cns11643-3 chinese-cns11643-4
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 chinese-cns11643-5 chinese-cns11643-6
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 chinese-cns11643-7)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
476 (iso-2022-jp-3 latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
477 japanese-jisx0213-1 japanese-jisx0213-2)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
478 (shift_jis latin-jisx0201 katakana-jisx0201 japanese-jisx0208)
71262
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
479 ,(cond ((fboundp 'unicode-precedence-list)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
480 (cons 'utf-8 (delq 'ascii (mapcar 'charset-name
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
481 (unicode-precedence-list)))))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
482 ((or (not (fboundp 'charsetp)) ;; non-Mule case
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
483 (charsetp 'unicode-a)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
484 (not (mm-coding-system-p 'mule-utf-8)))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
485 '(utf-8 unicode-a unicode-b unicode-c unicode-d unicode-e))
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
486 (t ;; If we have utf-8 we're in Mule 5+.
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
487 (append '(utf-8)
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
488 (delete 'ascii
70b055c73c8c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 70052
diff changeset
489 (coding-system-get 'mule-utf-8 'safe-charsets))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 "Alist of MIME-charset/MULE-charsets.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
492 (defun mm-enrich-utf-8-by-mule-ucs ()
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
493 "Make the `utf-8' MIME charset usable by the Mule-UCS package.
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
494 This function will run when the `un-define' module is loaded under
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
495 XEmacs, and fill the `utf-8' entry in `mm-mime-mule-charset-alist'
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
496 with Mule charsets. It is completely useless for Emacs."
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
497 (when (boundp 'unicode-basic-translation-charset-order-list)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
498 (condition-case nil
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
499 (let ((val (delq
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
500 'ascii
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
501 (copy-sequence
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
502 (symbol-value
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
503 'unicode-basic-translation-charset-order-list))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
504 (elem (assq 'utf-8 mm-mime-mule-charset-alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
505 (if elem
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
506 (setcdr elem val)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
507 (setq mm-mime-mule-charset-alist
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
508 (nconc mm-mime-mule-charset-alist
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
509 (list (cons 'utf-8 val))))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
510 (error))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
511
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
512 ;; Correct by construction, but should be unnecessary for Emacs:
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
513 (if (featurep 'xemacs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
514 (eval-after-load "un-define" '(mm-enrich-utf-8-by-mule-ucs))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
515 (when (and (fboundp 'coding-system-list)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
516 (fboundp 'sort-coding-systems))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
517 (let ((css (sort-coding-systems (coding-system-list 'base-only)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
518 cs mime mule alist)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
519 (while css
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
520 (setq cs (pop css)
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68940
diff changeset
521 mime (or (coding-system-get cs :mime-charset) ; Emacs 23 (unicode)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
522 (coding-system-get cs 'mime-charset)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
523 (when (and mime
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
524 (not (eq t (setq mule
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
525 (coding-system-get cs 'safe-charsets))))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
526 (not (assq mime alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
527 (push (cons mime (delq 'ascii mule)) alist)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
528 (setq mm-mime-mule-charset-alist (nreverse alist)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
530 (defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
531 "A list of special charsets.
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
532 Valid elements include:
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
533 `iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists.
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
534 `iso-2022-jp-2' convert ISO-2022-jp to ISO-2022-jp-2 if ISO-2022-jp-2 exists."
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
535 )
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
536
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
537 (defvar mm-iso-8859-15-compatible
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
538 '((iso-8859-1 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE")
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
539 (iso-8859-9 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xD0\xDD\xDE\xF0\xFD\xFE"))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
540 "ISO-8859-15 exchangeable coding systems and inconvertible characters.")
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
541
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
542 (defvar mm-iso-8859-x-to-15-table
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
543 (and (fboundp 'coding-system-p)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
544 (mm-coding-system-p 'iso-8859-15)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
545 (mapcar
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
546 (lambda (cs)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
547 (if (mm-coding-system-p (car cs))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
548 (let ((c (string-to-char
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
549 (decode-coding-string "\341" (car cs)))))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
550 (cons (char-charset c)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
551 (cons
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
552 (- (string-to-char
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
553 (decode-coding-string "\341" 'iso-8859-15)) c)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
554 (string-to-list (decode-coding-string (car (cdr cs))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
555 (car cs))))))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
556 '(gnus-charset 0)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
557 mm-iso-8859-15-compatible))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
558 "A table of the difference character between ISO-8859-X and ISO-8859-15.")
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
559
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
560 (defcustom mm-coding-system-priorities
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
561 (if (boundp 'current-language-environment)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
562 (let ((lang (symbol-value 'current-language-environment)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
563 (cond ((string= lang "Japanese")
57784
55829134ac17 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents: 57243
diff changeset
564 ;; Japanese users prefer iso-2022-jp to euc-japan or
55829134ac17 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents: 57243
diff changeset
565 ;; shift_jis, however iso-8859-1 should be used when
55829134ac17 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents: 57243
diff changeset
566 ;; there are only ASCII text and Latin-1 characters.
55829134ac17 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-650
Miles Bader <miles@gnu.org>
parents: 57243
diff changeset
567 '(iso-8859-1 iso-2022-jp iso-2022-jp-2 shift_jis utf-8)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
568 "Preferred coding systems for encoding outgoing messages.
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
569
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
570 More than one suitable coding system may be found for some text.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
571 By default, the coding system with the highest priority is used
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
572 to encode outgoing messages (see `sort-coding-systems'). If this
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
573 variable is set, it overrides the default priority."
57153
497f0d2ca551 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
574 :version "21.2"
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
575 :type '(repeat (symbol :tag "Coding system"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
576 :group 'mime)
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
577
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
578 ;; ??
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
579 (defvar mm-use-find-coding-systems-region
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
580 (fboundp 'find-coding-systems-region)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
581 "Use `find-coding-systems-region' to find proper coding systems.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
582
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
583 Setting it to nil is useful on Emacsen supporting Unicode if sending
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
584 mail with multiple parts is preferred to sending a Unicode one.")
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
585
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 ;;; Internal variables:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 ;;; Functions:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (defun mm-mule-charset-to-mime-charset (charset)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
591 "Return the MIME charset corresponding to the given Mule CHARSET."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
592 (if (and (fboundp 'find-coding-systems-for-charsets)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
593 (fboundp 'sort-coding-systems))
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
594 (let ((css (sort (sort-coding-systems
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
595 (find-coding-systems-for-charsets (list charset)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
596 'mm-sort-coding-systems-predicate))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
597 cs mime)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
598 (while (and (not mime)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
599 css)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
600 (when (setq cs (pop css))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
601 (setq mime (or (coding-system-get cs :mime-charset)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
602 (coding-system-get cs 'mime-charset)))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
603 mime)
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
604 (let ((alist (mapcar (lambda (cs)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
605 (assq cs mm-mime-mule-charset-alist))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
606 (sort (mapcar 'car mm-mime-mule-charset-alist)
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
607 'mm-sort-coding-systems-predicate)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
608 out)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
609 (while alist
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
610 (when (memq charset (cdar alist))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
611 (setq out (caar alist)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
612 alist nil))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
613 (pop alist))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
614 out)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
616 (defun mm-charset-to-coding-system (charset &optional lbt
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
617 allow-override)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 "Return coding-system corresponding to CHARSET.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 CHARSET is a symbol naming a MIME charset.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
621 used as the line break code type of the coding system.
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
622
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
623 If ALLOW-OVERRIDE is given, use `mm-charset-override-alist' to
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
624 map undesired charset names to their replacement. This should
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
625 only be used for decoding, not for encoding."
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
626 ;; OVERRIDE is used (only) in `mm-decode-body' and `mm-decode-string'.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (when (stringp charset)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 (setq charset (intern (downcase charset))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (when lbt
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 (setq charset (intern (format "%s-%s" charset lbt))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 (cond
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
632 ((null charset)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
633 charset)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 ;; Running in a non-MULE environment.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
635 ((or (null (mm-get-coding-system-list))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
636 (not (fboundp 'coding-system-get)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 charset)
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
638 ;; Check override list quite early. Should only used for decoding, not for
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
639 ;; encoding!
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
640 ((and allow-override
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
641 (let ((cs (cdr (assq charset mm-charset-override-alist))))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
642 (and cs (mm-coding-system-p cs) cs))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 ;; ascii
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 ((eq charset 'us-ascii)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 'ascii)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
646 ;; Check to see whether we can handle this charset. (This depends
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
647 ;; on there being some coding system matching each `mime-charset'
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
648 ;; property defined, as there should be.)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
649 ((and (mm-coding-system-p charset)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
650 ;;; Doing this would potentially weed out incorrect charsets.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
651 ;;; charset
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
652 ;;; (eq charset (coding-system-get charset 'mime-charset))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
653 )
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
654 charset)
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
655 ;; Eval expressions from `mm-charset-eval-alist'
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
656 ((let* ((el (assq charset mm-charset-eval-alist))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
657 (cs (car el))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
658 (form (cdr el)))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
659 (and cs
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
660 form
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
661 (prog2
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
662 ;; Avoid errors...
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
663 (condition-case nil (eval form) (error nil))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
664 ;; (message "Failed to eval `%s'" form))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
665 (mm-coding-system-p cs)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
666 (message "Added charset `%s' via `mm-charset-eval-alist'" cs))
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
667 cs)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
668 ;; Translate invalid charsets.
42493
84a510bb7ff6 2002-01-03 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42206
diff changeset
669 ((let ((cs (cdr (assq charset mm-charset-synonym-alist))))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
670 (and cs
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
671 (mm-coding-system-p cs)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
672 ;; (message
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
673 ;; "Using synonym `%s' from `mm-charset-synonym-alist' for `%s'"
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
674 ;; cs charset)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
675 cs)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
676 ;; Last resort: search the coding system list for entries which
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
677 ;; have the right mime-charset in case the canonical name isn't
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
678 ;; defined (though it should be).
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
679 ((let (cs)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
680 ;; mm-get-coding-system-list returns a list of cs without lbt.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
681 ;; Do we need -lbt?
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
682 (dolist (c (mm-get-coding-system-list))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
683 (if (and (null cs)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
684 (eq charset (or (coding-system-get c :mime-charset)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
685 (coding-system-get c 'mime-charset))))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
686 (setq cs c)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
687 (unless cs
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
688 ;; Warn the user about unknown charset:
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
689 (if (fboundp 'gnus-message)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
690 (gnus-message 7 "Unknown charset: %s" charset)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
691 (message "Unknown charset: %s" charset)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
692 cs))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
694 (defsubst mm-replace-chars-in-string (string from to)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
695 (mm-subst-char-in-string from to string))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
697 (eval-and-compile
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
698 (defvar mm-emacs-mule (and (not (featurep 'xemacs))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
699 (boundp 'default-enable-multibyte-characters)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
700 default-enable-multibyte-characters
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
701 (fboundp 'set-buffer-multibyte))
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
702 "True in Emacs with Mule.")
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
703
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
704 (if mm-emacs-mule
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
705 (defun mm-enable-multibyte ()
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
706 "Set the multibyte flag of the current buffer.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
707 Only do this if the default value of `enable-multibyte-characters' is
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
708 non-nil. This is a no-op in XEmacs."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
709 (set-buffer-multibyte 'to))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
710 (defalias 'mm-enable-multibyte 'ignore))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
712 (if mm-emacs-mule
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
713 (defun mm-disable-multibyte ()
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
714 "Unset the multibyte flag of in the current buffer.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
715 This is a no-op in XEmacs."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
716 (set-buffer-multibyte nil))
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
717 (defalias 'mm-disable-multibyte 'ignore)))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
718
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (defun mm-preferred-coding-system (charset)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 ;; A typo in some Emacs versions.
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
721 (or (get-charset-property charset 'preferred-coding-system)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
722 (get-charset-property charset 'prefered-coding-system)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
724 ;; Mule charsets shouldn't be used.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
725 (defsubst mm-guess-charset ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
726 "Guess Mule charset from the language environment."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
727 (or
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
728 mail-parse-mule-charset ;; cached mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
729 (progn
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
730 (setq mail-parse-mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
731 (and (boundp 'current-language-environment)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
732 (car (last
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
733 (assq 'charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
734 (assoc current-language-environment
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
735 language-info-alist))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
736 (if (or (not mail-parse-mule-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
737 (eq mail-parse-mule-charset 'ascii))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
738 (setq mail-parse-mule-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
739 (or (car (last (assq mail-parse-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
740 mm-mime-mule-charset-alist)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
741 ;; default
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
742 'latin-iso8859-1)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
743 mail-parse-mule-charset)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
744
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 (defun mm-charset-after (&optional pos)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 "Return charset of a character in current buffer at position POS.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 If POS is nil, it defauls to the current point.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 If POS is out of range, the value is nil.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 If the charset is `composition', return the actual one."
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
750 (let ((char (char-after pos)) charset)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
751 (if (< (mm-char-int char) 128)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
752 (setq charset 'ascii)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
753 ;; charset-after is fake in some Emacsen.
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
754 (setq charset (and (fboundp 'char-charset) (char-charset char)))
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
755 (if (eq charset 'composition) ; Mule 4
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
756 (let ((p (or pos (point))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
757 (cadr (find-charset-region p (1+ p))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
758 (if (and charset (not (memq charset '(ascii eight-bit-control
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
759 eight-bit-graphic))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
760 charset
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
761 (mm-guess-charset))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 (defun mm-mime-charset (charset)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
764 "Return the MIME charset corresponding to the given Mule CHARSET."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
765 (if (eq charset 'unknown)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
766 (error "The message contains non-printable characters, please use attachment"))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
767 (if (and (fboundp 'coding-system-get) (fboundp 'get-charset-property))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 ;; This exists in Emacs 20.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (or
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 (and (mm-preferred-coding-system charset)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
771 (or (coding-system-get
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
772 (mm-preferred-coding-system charset) :mime-charset)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
773 (coding-system-get
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
774 (mm-preferred-coding-system charset) 'mime-charset)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 (and (eq charset 'ascii)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 'us-ascii)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
777 (mm-preferred-coding-system charset)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 (mm-mule-charset-to-mime-charset charset))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 ;; This is for XEmacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 (mm-mule-charset-to-mime-charset charset)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781
65846
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
782 (if (fboundp 'delete-dups)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
783 (defalias 'mm-delete-duplicates 'delete-dups)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
784 (defun mm-delete-duplicates (list)
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
785 "Destructively remove `equal' duplicates from LIST.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
786 Store the result in LIST and return it. LIST must be a proper list.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
787 Of several `equal' occurrences of an element in LIST, the first
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
788 one is kept.
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
789
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
790 This is a compatibility function for Emacsen without `delete-dups'."
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
791 ;; Code from `subr.el' in Emacs 22:
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
792 (let ((tail list))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
793 (while tail
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
794 (setcdr tail (delete (car tail) (cdr tail)))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
795 (setq tail (cdr tail))))
a4e8d78ae3fb Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-574
Miles Bader <miles@gnu.org>
parents: 64754
diff changeset
796 list))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
798 ;; Fixme: This is used in places when it should be testing the
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
799 ;; default multibyteness. See mm-default-multibyte-p.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
800 (eval-and-compile
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
801 (if (and (not (featurep 'xemacs))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
802 (boundp 'enable-multibyte-characters))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
803 (defun mm-multibyte-p ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
804 "Non-nil if multibyte is enabled in the current buffer."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
805 enable-multibyte-characters)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
806 (defun mm-multibyte-p () (featurep 'mule))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
807
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
808 (defun mm-default-multibyte-p ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
809 "Return non-nil if the session is multibyte.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
810 This affects whether coding conversion should be attempted generally."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
811 (if (featurep 'mule)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
812 (if (boundp 'default-enable-multibyte-characters)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
813 default-enable-multibyte-characters
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
814 t)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
816 (defun mm-iso-8859-x-to-15-region (&optional b e)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
817 (if (fboundp 'char-charset)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
818 (let (charset item c inconvertible)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
819 (save-restriction
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
820 (if e (narrow-to-region b e))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
821 (goto-char (point-min))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
822 (skip-chars-forward "\0-\177")
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
823 (while (not (eobp))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
824 (cond
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
825 ((not (setq item (assq (char-charset (setq c (char-after)))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
826 mm-iso-8859-x-to-15-table)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
827 (forward-char))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
828 ((memq c (cdr (cdr item)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
829 (setq inconvertible t)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
830 (forward-char))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
831 (t
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
832 (insert-before-markers (prog1 (+ c (car (cdr item)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
833 (delete-char 1)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
834 (skip-chars-forward "\0-\177")))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
835 (not inconvertible))))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
836
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
837 (defun mm-sort-coding-systems-predicate (a b)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
838 (let ((priorities
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
839 (mapcar (lambda (cs)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
840 ;; Note: invalid entries are dropped silently
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
841 (and (setq cs (mm-coding-system-p cs))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
842 (coding-system-base cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
843 mm-coding-system-priorities)))
57923
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
844 (and (setq a (mm-coding-system-p a))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
845 (if (setq b (mm-coding-system-p b))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
846 (> (length (memq (coding-system-base a) priorities))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
847 (length (memq (coding-system-base b) priorities)))
d7def5572cf3 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 57784
diff changeset
848 t))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
849
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
850 (eval-when-compile
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
851 (autoload 'latin-unity-massage-name "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
852 (autoload 'latin-unity-maybe-remap "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
853 (autoload 'latin-unity-representations-feasible-region "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
854 (autoload 'latin-unity-representations-present-region "latin-unity")
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
855 (defvar latin-unity-coding-systems)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
856 (defvar latin-unity-ucs-list))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
857
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
858 (defun mm-xemacs-find-mime-charset-1 (begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
859 "Determine which MIME charset to use to send region as message.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
860 This uses the XEmacs-specific latin-unity package to better handle the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
861 case where identical characters from diverse ISO-8859-? character sets
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
862 can be encoded using a single one of the corresponding coding systems.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
863
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
864 It treats `mm-coding-system-priorities' as the list of preferred
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
865 coding systems; a useful example setting for this list in Western
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
866 Europe would be '(iso-8859-1 iso-8859-15 utf-8), which would default
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
867 to the very standard Latin 1 coding system, and only move to coding
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
868 systems that are less supported as is necessary to encode the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
869 characters that exist in the buffer.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
870
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
871 Latin Unity doesn't know about those non-ASCII Roman characters that
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
872 are available in various East Asian character sets. As such, its
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
873 behavior if you have a JIS 0212 LATIN SMALL LETTER A WITH ACUTE in a
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
874 buffer and it can otherwise be encoded as Latin 1, won't be ideal.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
875 But this is very much a corner case, so don't worry about it."
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
876 (let ((systems mm-coding-system-priorities) csets psets curset)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
877
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
878 ;; Load the Latin Unity library, if available.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
879 (when (and (not (featurep 'latin-unity)) (locate-library "latin-unity"))
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
880 (ignore-errors (require 'latin-unity)))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
881
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
882 ;; Now, can we use it?
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
883 (if (featurep 'latin-unity)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
884 (progn
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
885 (setq csets (latin-unity-representations-feasible-region begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
886 psets (latin-unity-representations-present-region begin end))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
887
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
888 (catch 'done
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
889
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
890 ;; Pass back the first coding system in the preferred list
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
891 ;; that can encode the whole region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
892 (dolist (curset systems)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
893 (setq curset (latin-unity-massage-name 'buffer-default curset))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
894
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
895 ;; If the coding system is a universal coding system, then
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
896 ;; it can certainly encode all the characters in the region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
897 (if (memq curset latin-unity-ucs-list)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
898 (throw 'done (list curset)))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
899
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
900 ;; If a coding system isn't universal, and isn't in
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
901 ;; the list that latin unity knows about, we can't
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
902 ;; decide whether to use it here. Leave that until later
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
903 ;; in `mm-find-mime-charset-region' function, whence we
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
904 ;; have been called.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
905 (unless (memq curset latin-unity-coding-systems)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
906 (throw 'done nil))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
907
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
908 ;; Right, we know about this coding system, and it may
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
909 ;; conceivably be able to encode all the characters in
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
910 ;; the region.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
911 (if (latin-unity-maybe-remap begin end curset csets psets t)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
912 (throw 'done (list curset))))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
913
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
914 ;; Can't encode using anything from the
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
915 ;; `mm-coding-system-priorities' list.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
916 ;; Leave `mm-find-mime-charset' to do most of the work.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
917 nil))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
918
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
919 ;; Right, latin unity isn't available; let `mm-find-charset-region'
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
920 ;; take its default action, which equally applies to GNU Emacs.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
921 nil)))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
922
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
923 (defmacro mm-xemacs-find-mime-charset (begin end)
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
924 (when (featurep 'xemacs)
61126
c0aa521e0ca7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-220
Miles Bader <miles@gnu.org>
parents: 60029
diff changeset
925 `(and (featurep 'mule) (mm-xemacs-find-mime-charset-1 ,begin ,end))))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
926
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
927 (defun mm-find-mime-charset-region (b e &optional hack-charsets)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
928 "Return the MIME charsets needed to encode the region between B and E.
42206
0f4506820432 Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 41494
diff changeset
929 nil means ASCII, a single-element list represents an appropriate MIME
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
930 charset, and a longer list means no appropriate charset."
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
931 (let (charsets)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
932 ;; The return possibilities of this function are a mess...
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
933 (or (and (mm-multibyte-p)
42500
9b68dff3d385 * mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42493
diff changeset
934 mm-use-find-coding-systems-region
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
935 ;; Find the mime-charset of the most preferred coding
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
936 ;; system that has one.
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
937 (let ((systems (find-coding-systems-region b e)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
938 (when mm-coding-system-priorities
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
939 (setq systems
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
940 (sort systems 'mm-sort-coding-systems-predicate)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
941 (setq systems (delq 'compound-text systems))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
942 (unless (equal systems '(undecided))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
943 (while systems
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
944 (let* ((head (pop systems))
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
945 (cs (or (coding-system-get head :mime-charset)
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
946 (coding-system-get head 'mime-charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
947 ;; The mime-charset (`x-ctext') of
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
948 ;; `compound-text' is not in the IANA list. We
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
949 ;; shouldn't normally use anything here with a
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
950 ;; mime-charset having an `x-' prefix.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
951 ;; Fixme: Allow this to be overridden, since
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
952 ;; there is existing use of x-ctext.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
953 ;; Also people apparently need the coding system
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
954 ;; `iso-2022-jp-3' (which Mule-UCS defines with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
955 ;; mime-charset, though it's not valid).
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
956 (if (and cs
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
957 (not (string-match "^[Xx]-" (symbol-name cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
958 ;; UTF-16 of any variety is invalid for
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
959 ;; text parts and, unfortunately, has
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
960 ;; mime-charset defined both in Mule-UCS
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
961 ;; and versions of Emacs. (The name
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
962 ;; might be `mule-utf-16...' or
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
963 ;; `utf-16...'.)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
964 (not (string-match "utf-16" (symbol-name cs))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
965 (setq systems nil
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
966 charsets (list cs))))))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
967 charsets))
59089
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
968 ;; If we're XEmacs, and some coding system is appropriate,
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
969 ;; mm-xemacs-find-mime-charset will return an appropriate list.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
970 ;; Otherwise, we'll get nil, and the next setq will get invoked.
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
971 (setq charsets (mm-xemacs-find-mime-charset b e))
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
972
22da0004ae3c Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750
Miles Bader <miles@gnu.org>
parents: 57923
diff changeset
973 ;; We're not multibyte, or a single coding system won't cover it.
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
974 (setq charsets
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
975 (mm-delete-duplicates
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
976 (mapcar 'mm-mime-charset
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
977 (delq 'ascii
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
978 (mm-find-charset-region b e))))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
979 (if (and (> (length charsets) 1)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
980 (memq 'iso-8859-15 charsets)
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
981 (memq 'iso-8859-15 hack-charsets)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
982 (save-excursion (mm-iso-8859-x-to-15-region b e)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
983 (mapcar (lambda (x) (setq charsets (delq (car x) charsets)))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
984 mm-iso-8859-15-compatible))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
985 (if (and (memq 'iso-2022-jp-2 charsets)
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
986 (memq 'iso-2022-jp-2 hack-charsets))
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
987 (setq charsets (delq 'iso-2022-jp charsets)))
64736
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
988 ;; Attempt to reduce the number of charsets if utf-8 is available.
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
989 (if (and (featurep 'xemacs)
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
990 (> (length charsets) 1)
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
991 (mm-coding-system-p 'utf-8))
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
992 (let ((mm-coding-system-priorities
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
993 (cons 'utf-8 mm-coding-system-priorities)))
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
994 (setq charsets
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
995 (mm-delete-duplicates
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
996 (mapcar 'mm-mime-charset
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
997 (delq 'ascii
f62cd60b99ba Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-513
Miles Bader <miles@gnu.org>
parents: 64085
diff changeset
998 (mm-find-charset-region b e)))))))
41494
933ab100fb4a 2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 40621
diff changeset
999 charsets))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1000
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1001 (defmacro mm-with-unibyte-buffer (&rest forms)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1002 "Create a temporary buffer, and evaluate FORMS there like `progn'.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1003 Use unibyte mode for this."
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1004 `(let (default-enable-multibyte-characters)
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1005 (with-temp-buffer ,@forms)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1006 (put 'mm-with-unibyte-buffer 'lisp-indent-function 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1007 (put 'mm-with-unibyte-buffer 'edebug-form-spec '(body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1008
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1009 (defmacro mm-with-multibyte-buffer (&rest forms)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1010 "Create a temporary buffer, and evaluate FORMS there like `progn'.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1011 Use multibyte mode for this."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1012 `(let ((default-enable-multibyte-characters t))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1013 (with-temp-buffer ,@forms)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1014 (put 'mm-with-multibyte-buffer 'lisp-indent-function 0)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1015 (put 'mm-with-multibyte-buffer 'edebug-form-spec '(body))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1016
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1017 (defmacro mm-with-unibyte-current-buffer (&rest forms)
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1018 "Evaluate FORMS with current buffer temporarily made unibyte.
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1019 Also bind `default-enable-multibyte-characters' to nil.
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1020 Equivalent to `progn' in XEmacs
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1021
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1022 NOTE: Use this macro with caution in multibyte buffers (it is not
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1023 worth using this macro in unibyte buffers of course). Use of
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1024 `(set-buffer-multibyte t)', which is run finally, is generally
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1025 harmful since it is likely to modify existing data in the buffer.
69304
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69247
diff changeset
1026 For instance, it converts \"\\300\\255\" into \"\\255\" in
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69247
diff changeset
1027 Emacs 23 (unicode)."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1028 (let ((multibyte (make-symbol "multibyte"))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1029 (buffer (make-symbol "buffer")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47949
diff changeset
1030 `(if mm-emacs-mule
69247
6580c61aced7 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-134
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
1031 (let ((,multibyte enable-multibyte-characters)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1032 (,buffer (current-buffer)))
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1033 (unwind-protect
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1034 (let (default-enable-multibyte-characters)
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1035 (set-buffer-multibyte nil)
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1036 ,@forms)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1037 (set-buffer ,buffer)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1038 (set-buffer-multibyte ,multibyte)))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1039 (let (default-enable-multibyte-characters)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1040 ,@forms))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1041 (put 'mm-with-unibyte-current-buffer 'lisp-indent-function 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1042 (put 'mm-with-unibyte-current-buffer 'edebug-form-spec '(body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1043
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1044 (defmacro mm-with-unibyte (&rest forms)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1045 "Eval the FORMS with the default value of `enable-multibyte-characters' nil."
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1046 `(let (default-enable-multibyte-characters)
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1047 ,@forms))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1048 (put 'mm-with-unibyte 'lisp-indent-function 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1049 (put 'mm-with-unibyte 'edebug-form-spec '(body))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1050
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1051 (defmacro mm-with-multibyte (&rest forms)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1052 "Eval the FORMS with the default value of `enable-multibyte-characters' t."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1053 `(let ((default-enable-multibyte-characters t))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1054 ,@forms))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1055 (put 'mm-with-multibyte 'lisp-indent-function 0)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1056 (put 'mm-with-multibyte 'edebug-form-spec '(body))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1057
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1058 (defun mm-find-charset-region (b e)
33378
ab964e52e0ba Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1059 "Return a list of Emacs charsets in the region B to E."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1060 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1061 ((and (mm-multibyte-p)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1062 (fboundp 'find-charset-region))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1063 ;; Remove composition since the base charsets have been included.
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1064 ;; Remove eight-bit-*, treat them as ascii.
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1065 (let ((css (find-charset-region b e)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1066 (mapcar (lambda (cs) (setq css (delq cs css)))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1067 '(composition eight-bit-control eight-bit-graphic
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1068 control-1))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1069 css))
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1070 (t
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1071 ;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1072 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1073 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1074 (narrow-to-region b e)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1075 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1076 (skip-chars-forward "\0-\177")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1077 (if (eobp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1078 '(ascii)
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1079 (let (charset)
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1080 (setq charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1081 (and (boundp 'current-language-environment)
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1082 (car (last (assq 'charset
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1083 (assoc current-language-environment
32976
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1084 language-info-alist))))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1085 (if (eq charset 'ascii) (setq charset nil))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1086 (or charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1087 (setq charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1088 (car (last (assq mail-parse-charset
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1089 mm-mime-mule-charset-alist)))))
aa9dc4e7c5ac 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 32414
diff changeset
1090 (list 'ascii (or charset 'latin-iso8859-1)))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1091
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1092 (if (fboundp 'shell-quote-argument)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1093 (defalias 'mm-quote-arg 'shell-quote-argument)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1094 (defun mm-quote-arg (arg)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1095 "Return a version of ARG that is safe to evaluate in a shell."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1096 (let ((pos 0) new-pos accum)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1097 ;; *** bug: we don't handle newline characters properly
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1098 (while (setq new-pos (string-match "[]*[;!'`\"$\\& \t{} |()<>]" arg pos))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1099 (push (substring arg pos new-pos) accum)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1100 (push "\\" accum)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1101 (push (list (aref arg new-pos)) accum)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1102 (setq pos (1+ new-pos)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1103 (if (= pos 0)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1104 arg
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1105 (apply 'concat (nconc (nreverse accum) (list (substring arg pos))))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1106
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1107 (defun mm-auto-mode-alist ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1108 "Return an `auto-mode-alist' with only the .gz (etc) thingies."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1109 (let ((alist auto-mode-alist)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1110 out)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1111 (while alist
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1112 (when (listp (cdar alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1113 (push (car alist) out))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1114 (pop alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1115 (nreverse out)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1116
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1117 (defvar mm-inhibit-file-name-handlers
36473
c1e752e8d255 (mm-inhibit-file-name-handlers): Add
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
1118 '(jka-compr-handler image-file-handler)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1119 "A list of handlers doing (un)compression (etc) thingies.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1120
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1121 (defun mm-insert-file-contents (filename &optional visit beg end replace
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1122 inhibit)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1123 "Like `insert-file-contents', but only reads in the file.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1124 A buffer may be modified in several ways after reading into the buffer due
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1125 to advanced Emacs features, such as file-name-handlers, format decoding,
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1126 `find-file-hooks', etc.
47949
33e1238070a2 (mm-mime-mule-charset-alist): Require when compiling.
Dave Love <fx@gnu.org>
parents: 44075
diff changeset
1127 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1128 This function ensures that none of these modifications will take place."
62943
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1129 (let* ((format-alist nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1130 (auto-mode-alist (if inhibit nil (mm-auto-mode-alist)))
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1131 (default-major-mode 'fundamental-mode)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1132 (enable-local-variables nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1133 (after-insert-file-functions nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1134 (enable-local-eval nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1135 (inhibit-file-name-operation (if inhibit
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1136 'insert-file-contents
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1137 inhibit-file-name-operation))
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1138 (inhibit-file-name-handlers
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1139 (if inhibit
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1140 (append mm-inhibit-file-name-handlers
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1141 inhibit-file-name-handlers)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1142 inhibit-file-name-handlers))
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1143 (ffh (if (boundp 'find-file-hook)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1144 'find-file-hook
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1145 'find-file-hooks))
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1146 (val (symbol-value ffh)))
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1147 (set ffh nil)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1148 (unwind-protect
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1149 (insert-file-contents filename visit beg end replace)
11d53dd5abd9 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents: 61519
diff changeset
1150 (set ffh val))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1151
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1152 (defun mm-append-to-file (start end filename &optional codesys inhibit)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1153 "Append the contents of the region to the end of file FILENAME.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1154 When called from a function, expects three arguments,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1155 START, END and FILENAME. START and END are buffer positions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1156 saying what text to write.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1157 Optional fourth argument specifies the coding system to use when
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1158 encoding the file.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1159 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1160 (let ((coding-system-for-write
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1161 (or codesys mm-text-coding-system-for-write
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1162 mm-text-coding-system))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1163 (inhibit-file-name-operation (if inhibit
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1164 'append-to-file
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1165 inhibit-file-name-operation))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1166 (inhibit-file-name-handlers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1167 (if inhibit
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1168 (append mm-inhibit-file-name-handlers
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1169 inhibit-file-name-handlers)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1170 inhibit-file-name-handlers)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1171 (write-region start end filename t 'no-message)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1172 (message "Appended to %s" filename)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1173
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1174 (defun mm-write-region (start end filename &optional append visit lockname
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1175 coding-system inhibit)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1176
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1177 "Like `write-region'.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1178 If INHIBIT is non-nil, inhibit `mm-inhibit-file-name-handlers'."
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1179 (let ((coding-system-for-write
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1180 (or coding-system mm-text-coding-system-for-write
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1181 mm-text-coding-system))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1182 (inhibit-file-name-operation (if inhibit
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1183 'write-region
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1184 inhibit-file-name-operation))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1185 (inhibit-file-name-handlers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1186 (if inhibit
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1187 (append mm-inhibit-file-name-handlers
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1188 inhibit-file-name-handlers)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1189 inhibit-file-name-handlers)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1190 (write-region start end filename append visit lockname)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1191
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1192 ;; It is not a MIME function, but some MIME functions use it.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1193 (if (and (fboundp 'make-temp-file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1194 (ignore-errors
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1195 (let ((def (symbol-function 'make-temp-file)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1196 (and (byte-code-function-p def)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1197 (setq def (if (fboundp 'compiled-function-arglist)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1198 ;; XEmacs
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1199 (eval (list 'compiled-function-arglist def))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1200 (aref def 0)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1201 (>= (length def) 4)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1202 (eq (nth 3 def) 'suffix)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1203 (defalias 'mm-make-temp-file 'make-temp-file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1204 ;; Stolen (and modified for Emacs 20 and XEmacs) from Emacs 22.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1205 (defun mm-make-temp-file (prefix &optional dir-flag suffix)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1206 "Create a temporary file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1207 The returned file name (created by appending some random characters at the end
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1208 of PREFIX, and expanding against `temporary-file-directory' if necessary),
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1209 is guaranteed to point to a newly created empty file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1210 You can then use `write-region' to write new data into the file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1211
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1212 If DIR-FLAG is non-nil, create a new empty directory instead of a file.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1213
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1214 If SUFFIX is non-nil, add that at the end of the file name."
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1215 (let ((umask (default-file-modes))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1216 file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1217 (unwind-protect
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1218 (progn
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1219 ;; Create temp files with strict access rights. It's easy to
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1220 ;; loosen them later, whereas it's impossible to close the
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1221 ;; time-window of loose permissions otherwise.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1222 (set-default-file-modes 448)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1223 (while (condition-case err
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1224 (progn
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1225 (setq file
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1226 (make-temp-name
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1227 (expand-file-name
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1228 prefix
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1229 (if (fboundp 'temp-directory)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1230 ;; XEmacs
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1231 (temp-directory)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1232 temporary-file-directory))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1233 (if suffix
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1234 (setq file (concat file suffix)))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1235 (if dir-flag
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1236 (make-directory file)
73370
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1237 ;; NOTE: This is unsafe if Emacs 20
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1238 ;; users and XEmacs users don't use
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1239 ;; a secure temp directory.
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1240 (gmm-write-region "" nil file nil 'silent
7d511b8dc9c6 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 73224
diff changeset
1241 nil 'excl))
68940
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1242 nil)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1243 (file-already-exists t)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1244 ;; The Emacs 20 and XEmacs versions of
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1245 ;; `make-directory' issue `file-error'.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1246 (file-error (or (and (or (featurep 'xemacs)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1247 (= emacs-major-version 20))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1248 (file-exists-p file))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1249 (signal (car err) (cdr err)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1250 ;; the file was somehow created by someone else between
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1251 ;; `make-temp-name' and `write-region', let's try again.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1252 nil)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1253 file)
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1254 ;; Reset the umask.
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1255 (set-default-file-modes umask)))))
808f636eb13e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-93
Miles Bader <miles@gnu.org>
parents: 68633
diff changeset
1256
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1257 (defun mm-image-load-path (&optional package)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1258 (let (dir result)
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1259 (dolist (path load-path (nreverse result))
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1260 (when (and path
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1261 (file-directory-p
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1262 (setq dir (concat (file-name-directory
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1263 (directory-file-name path))
60029
210af0ad3d35 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-96
Miles Bader <miles@gnu.org>
parents: 59089
diff changeset
1264 "etc/images/" (or package "gnus/")))))
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 57153
diff changeset
1265 (push dir result))
40542
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1266 (push path result))))
93f6c74a2f60 * mm-util.el, nnultimate.el, nnweb.el, nnslashdot.el: Sync with
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 39339
diff changeset
1267
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1268 ;; Fixme: This doesn't look useful where it's used.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1269 (if (fboundp 'detect-coding-region)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1270 (defun mm-detect-coding-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1271 "Like `detect-coding-region' except returning the best one."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1272 (let ((coding-systems
61434
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
1273 (detect-coding-region start end)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1274 (or (car-safe coding-systems)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1275 coding-systems)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1276 (defun mm-detect-coding-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1277 (let ((point (point)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1278 (goto-char start)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1279 (skip-chars-forward "\0-\177" end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1280 (prog1
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1281 (if (eq (point) end) 'ascii (mm-guess-charset))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1282 (goto-char point)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1283
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1284 (if (fboundp 'coding-system-get)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1285 (defun mm-detect-mime-charset-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1286 "Detect MIME charset of the text in the region between START and END."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1287 (let ((cs (mm-detect-coding-region start end)))
70052
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
1288 (or (coding-system-get cs :mime-charset)
261c2dbe91d2 * mm-util.el (mm-charset-synonym-alist): Improve doc string.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 69304
diff changeset
1289 (coding-system-get cs 'mime-charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1290 (defun mm-detect-mime-charset-region (start end)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1291 "Detect MIME charset of the text in the region between START and END."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1292 (let ((cs (mm-detect-coding-region start end)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1293 cs)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 53617
diff changeset
1294
44075
7782e54757bb * mail-source.el (make-source-make-complex-temp-name): Use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 42500
diff changeset
1295
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1296 (provide 'mm-util)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1297
61434
6d07c19816b9 (mm-string-to-multibyte): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61424
diff changeset
1298 ;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1299 ;;; mm-util.el ends here