PageRenderTime 60ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/incoming/mew-1.94.2/mew-mule3.el

https://github.com/emacsmirror/ohio-archive
Emacs Lisp | 236 lines | 138 code | 35 blank | 63 comment | 0 complexity | d751fd39b903d34982eedc5b4ffca284 MD5 | raw file
  1. ;;; mew-mule3.el --- Environment of Mule version 3 for Mew
  2. ;; Author: Kazu Yamamoto <Kazu@Mew.org>
  3. ;; Created: Mar 20, 1997
  4. ;; Revised: Aug 30, 1999
  5. ;;; Code:
  6. (defconst mew-mule3-version "mew-mule3.el version 0.14")
  7. ;; must be here
  8. (if (fboundp 'find-coding-system)
  9. (fset 'mew-coding-system-p (symbol-function 'find-coding-system))
  10. (fset 'mew-coding-system-p (symbol-function 'coding-system-p)))
  11. ;; In the context of Mew, 'charset' means MIME charset.
  12. ;; 'cs' means the internal representation of Emacs (was known as Mule).
  13. ;;
  14. ;; User CS definitions
  15. ;;
  16. ;; iso-2022-7bit-ss2 is iso-2022-jp-2
  17. (cond
  18. (mew-xemacs-p
  19. (copy-coding-system 'no-conversion 'mew-cs-text)
  20. (copy-coding-system 'no-conversion-unix 'mew-cs-text-lf)
  21. (copy-coding-system 'no-conversion-dos 'mew-cs-text-crlf)
  22. (copy-coding-system 'no-conversion-mac 'mew-cs-text-cr))
  23. (t
  24. (define-coding-system-alias 'mew-cs-text 'raw-text)
  25. (define-coding-system-alias 'mew-cs-text-lf 'raw-text-unix)
  26. (define-coding-system-alias 'mew-cs-text-crlf 'raw-text-dos)
  27. (define-coding-system-alias 'mew-cs-text-cr 'raw-text-mac)))
  28. (defvar mew-cs-dummy 'binary)
  29. (defvar mew-cs-binary 'binary)
  30. (defvar mew-cs-text-for-read 'mew-cs-text)
  31. (defvar mew-cs-text-for-write 'mew-cs-text-lf)
  32. (defvar mew-cs-autoconv 'undecided)
  33. (defvar mew-cs-7bit 'iso-2022-7bit-ss2)
  34. (defvar mew-cs-7bit-crlf 'iso-2022-7bit-ss2-dos)
  35. (defvar mew-cs-mime-trans 'iso-2022-7bit-ss2)
  36. (defvar mew-cs-rfc822-trans 'iso-2022-7bit-ss2)
  37. (defvar mew-cs-draft 'iso-2022-7bit-ss2)
  38. (defvar mew-cs-scan 'ctext)
  39. (defvar mew-cs-infile 'undecided) ;; guess in +draft
  40. (defvar mew-cs-outfile 'iso-2022-7bit-ss2)
  41. (defvar mew-cs-virtual (if (mew-coding-system-p 'ctext-unix)
  42. 'ctext-unix 'ctext)) ;; ^M as it is
  43. (defvar mew-cs-pick 'euc-jp)
  44. (defvar mew-cs-database
  45. '(("us-ascii" (ascii) nil "7bit"
  46. nil "Q")
  47. ("iso-8859-1" (ascii latin-iso8859-1) iso-8859-1 "quoted-printable"
  48. iso-8859-1 "Q")
  49. ("iso-8859-2" (ascii latin-iso8859-2) iso-8859-2 "quoted-printable"
  50. iso-8859-2 "Q")
  51. ("iso-8859-3" (ascii latin-iso8859-3) iso-8859-3 "quoted-printable"
  52. iso-8859-3 "Q")
  53. ("iso-8859-4" (ascii latin-iso8859-4) iso-8859-4 "quoted-printable"
  54. iso-8859-4 "Q")
  55. ("koi8-r" (ascii cyrillic-iso8859-5) koi8-r "quoted-printable"
  56. koi8-r "Q")
  57. ("iso-8859-6" (ascii arabic-iso8859-6) iso-8859-6 "base64"
  58. iso-8859-6 "B")
  59. ("iso-8859-7" (ascii greek-iso8859-7) iso-8859-7 "base64"
  60. iso-8859-7 "B")
  61. ("iso-8859-8" (ascii hebrew-iso8859-8) iso-8859-8 "base64"
  62. iso-8859-8 "B")
  63. ("iso-8859-9" (ascii latin-iso8859-9) iso-8859-9 "quoted-printable"
  64. iso-8859-9 "Q")
  65. ("tis-620" (ascii thai-tis620) tis620 "base64"
  66. tis620 "B")
  67. ("iso-2022-jp"
  68. (ascii latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978)
  69. iso-2022-jp "7bit"
  70. iso-2022-jp "B")
  71. ("euc-kr" (ascii korean-ksc5601) euc-kr "base64"
  72. euc-kr "B")
  73. ("iso-2022-kr" (ascii korean-ksc5601) iso-2022-kr "7bit"
  74. euc-kr "B")
  75. ("gb2312" (ascii chinese-gb2312) cn-gb-2312 "base64"
  76. cn-gb-2312 "B")
  77. ("hz-gb-2312" (ascii chinese-gb2312) hz-gb-2312 "7bit"
  78. hz-gb-2312 "B")
  79. ("big5" (ascii chinese-big5-1 chinese-big5-2)
  80. chinese-big5 "base64"
  81. chinese-big5 "B")
  82. ("iso-2022-jp-2"
  83. (ascii
  84. latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978 japanese-jisx0212
  85. chinese-gb2312 korean-ksc5601 latin-iso8859-1 greek-iso8859-7)
  86. iso-2022-7bit-ss2 "7bit"
  87. iso-2022-7bit-ss2 "B")
  88. ;; charset-to-cs purpose only
  89. ("euc-jp" nil euc-japan)
  90. ("shift_jis" nil shift_jis)
  91. ("cn-gb" nil cn-gb-2312) ;; the same as gb2312 above
  92. ("cn-big5" nil chinese-big5) ;; the same as big5 above
  93. ("iso-2022-cn" nil iso-2022-cn)
  94. ("iso-2022-cn-ext" nil iso-2022-cn-ext)
  95. ("iso-2022-int-1" nil iso-2022-int-1)
  96. ))
  97. ;;
  98. ;; Leading characters
  99. ;;
  100. (defvar mew-lc-ascii 'ascii)
  101. (defvar mew-lc-jp 'japanese-jisx0208)
  102. (defvar mew-lc-kana 'katakana-jisx0201)
  103. (defalias 'mew-make-char 'make-char)
  104. (defalias 'mew-char-charset 'char-charset)
  105. ;;
  106. ;; CS
  107. ;;
  108. (defalias 'mew-find-cs-region 'find-charset-region)
  109. ;; to internal
  110. (defun mew-cs-decode-region (beg end cs)
  111. (if cs (decode-coding-region beg end cs)))
  112. ;; to extenal
  113. (defun mew-cs-encode-region (beg end cs)
  114. (if cs (encode-coding-region beg end cs)))
  115. ;; to internal
  116. (defun mew-cs-decode-string (str cs)
  117. (if cs (decode-coding-string str cs) str))
  118. ;; to external
  119. (defun mew-cs-encode-string (str cs)
  120. (if cs (encode-coding-string str cs) str))
  121. ;;
  122. ;; Process environment
  123. ;;
  124. (defun mew-set-process-cs (process read write)
  125. (set-process-coding-system process read write))
  126. (defmacro mew-plet (&rest body)
  127. `(let ((call-process-hook nil)
  128. (coding-system-for-read 'binary)
  129. (coding-system-for-write 'binary))
  130. ,@body))
  131. (defmacro mew-piolet (read write &rest body)
  132. `(let ((call-process-hook nil)
  133. (coding-system-for-read ,read)
  134. (coding-system-for-write ,write))
  135. ,@body))
  136. (defmacro mew-pioalet (read write arg &rest body)
  137. `(let ((call-process-hook nil)
  138. (coding-system-for-read ,read)
  139. (coding-system-for-write ,write)
  140. (file-name-coding-system ,arg))
  141. ,@body))
  142. (defmacro mew-flet (&rest body)
  143. `(let ((coding-system-for-read 'binary)
  144. (coding-system-for-write 'binary)
  145. jam-zcat-filename-list
  146. jka-compr-compression-info-list)
  147. ,@body))
  148. (defmacro mew-frwlet (read write &rest body)
  149. `(let ((coding-system-for-read ,read)
  150. (coding-system-for-write ,write)
  151. jam-zcat-filename-list
  152. jka-compr-compression-info-list)
  153. ,@body))
  154. ;;
  155. ;; Post conversion
  156. ;;
  157. (defun mew-cs-post-conv (cs) ()) ;; not necessary because internally applied
  158. ;;
  159. ;;
  160. ;;
  161. (cond
  162. ((and mew-temacs-p (string< emacs-version "20.2.90"))
  163. (fset 'mew-aref (symbol-function 'sref))
  164. (fset 'mew-charlen (symbol-function 'char-bytes)))
  165. (t
  166. (fset 'mew-aref (symbol-function 'aref))
  167. (defmacro mew-charlen (c) (` 1)))
  168. )
  169. ;;
  170. ;;
  171. ;;
  172. (require 'mew-mule)
  173. (provide 'mew-mule3)
  174. ;;; Copyright Notice:
  175. ;; Copyright (C) 1997, 1998, 1999 Mew developing team.
  176. ;; All rights reserved.
  177. ;; Redistribution and use in source and binary forms, with or without
  178. ;; modification, are permitted provided that the following conditions
  179. ;; are met:
  180. ;;
  181. ;; 1. Redistributions of source code must retain the above copyright
  182. ;; notice, this list of conditions and the following disclaimer.
  183. ;; 2. Redistributions in binary form must reproduce the above copyright
  184. ;; notice, this list of conditions and the following disclaimer in the
  185. ;; documentation and/or other materials provided with the distribution.
  186. ;; 3. Neither the name of the team nor the names of its contributors
  187. ;; may be used to endorse or promote products derived from this software
  188. ;; without specific prior written permission.
  189. ;;
  190. ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
  191. ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  192. ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  193. ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
  194. ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  195. ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  196. ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  197. ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  198. ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  199. ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  200. ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  201. ;;; mew-mule3.el ends here