File: gnus-charset.el

package info (click to toggle)
xemacs20 20.4-13
  • links: PTS
  • area: main
  • in suites: slink
  • size: 67,324 kB
  • ctags: 57,643
  • sloc: lisp: 586,197; ansic: 184,662; sh: 4,296; asm: 3,179; makefile: 2,021; perl: 1,059; csh: 96; sed: 22
file content (173 lines) | stat: -rw-r--r-- 5,888 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
;;; gnus-charset.el --- MIME charset extension for Gnus

;; Copyright (C) 1995,1996 Free Software Foundation, Inc.

;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
;; Created: 1996/8/6
;; Version:
;;	$Id: gnus-charset.el,v 0.16 1997/03/10 11:33:16 morioka Exp $
;; Keywords: news, MIME, multimedia, multilingual, encoded-word

;; This file is not part of GNU Emacs yet.

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.

;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Code:

(require 'gnus)

(defvar gnus-is-red-gnus-or-later
  (or (featurep 'gnus-load)
      (module-installed-p 'gnus-sum)
      ))


;;; @ newsgroup default charset
;;;

(defvar gnus-newsgroup-default-charset-alist nil)

(defun gnus-set-newsgroup-default-charset (newsgroup charset)
  "Set CHARSET for the NEWSGROUP as default MIME charset."
  (let* ((ng-regexp (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)"))
	 (pair (assoc ng-regexp gnus-newsgroup-default-charset-alist))
	 )
    (if pair
	(setcdr pair charset)
      (setq gnus-newsgroup-default-charset-alist
	    (cons (cons ng-regexp charset)
		  gnus-newsgroup-default-charset-alist))
      )))


;;; @ for mule (Multilingual support)
;;;

(cond
 ((featurep 'mule)
  (require 'emu)
  (defvar nntp-open-binary-connection-function
    (if gnus-is-red-gnus-or-later
	;; maybe Red Gnus
	(if (boundp 'nntp-open-connection-function)
	    nntp-open-connection-function
	  'nntp-open-network-stream)
      ;; maybe Gnus 5.[01] or Gnus 5.[23]
      (if (boundp 'nntp-open-server-function)
	  nntp-open-server-function
	'nntp-open-network-stream)
      ))
  (defun nntp-open-network-stream-with-no-code-conversion (&rest args)
    (let ((proc (apply nntp-open-binary-connection-function args)))
      (set-process-input-coding-system proc *noconv*)
      proc))
  (if gnus-is-red-gnus-or-later
      (setq nntp-open-connection-function
	    'nntp-open-network-stream-with-no-code-conversion)
    (setq nntp-open-server-function
	  'nntp-open-network-stream-with-no-code-conversion)
    )
  (call-after-loaded
   'nnheader
   (lambda ()
     (defun nnheader-find-file-noselect (&rest args)
       (as-binary-input-file
        (let ((format-alist nil)
              (auto-mode-alist (nnheader-auto-mode-alist))
              (default-major-mode 'fundamental-mode)
              (after-insert-file-functions ; for jam-code-guess
               (if (memq 'jam-code-guess-after-insert-file-function
                         after-insert-file-functions)
                   '(jam-code-guess-after-insert-file-function))))
          (apply 'find-file-noselect args)))
       )
     ;; Red Gnus 0.67 or later
     (defun nnheader-insert-file-contents
       (filename &optional visit beg end replace)
       (as-binary-input-file
        (let ((format-alist nil)
              (auto-mode-alist (nnheader-auto-mode-alist))
              (default-major-mode 'fundamental-mode)
              (enable-local-variables nil)
              (after-insert-file-functions ; for jam-code-guess
               (if (memq 'jam-code-guess-after-insert-file-function
                         after-insert-file-functions)
                   '(jam-code-guess-after-insert-file-function))))
          (insert-file-contents filename visit beg end replace))
        )
       ;; for gnspool on OS/2
       (while (re-search-forward "\r$" nil t)
	 (replace-match "")
	 )
       )
     ;; imported from Red Gnus 0.66
     (or (fboundp 'nnheader-auto-mode-alist)
         (defun nnheader-auto-mode-alist ()
           (let ((alist auto-mode-alist)
                 out)
             (while alist
               (when (listp (cdar alist))
                 (push (car alist) out))
               (pop alist))
             (nreverse out)))
         )
     ;; alias for Old Gnus
     (defalias 'nnheader-insert-file-contents-literally
       'nnheader-insert-file-contents)
     ))
  (call-after-loaded
   'nnmail
   (lambda ()
     (defun nnmail-find-file (file)
       "Insert FILE in server buffer safely. [gnus-charset.el]"
       (set-buffer nntp-server-buffer)
       (erase-buffer)
       (let ((format-alist nil)
             (after-insert-file-functions   ; for jam-code-guess
              (if (memq 'jam-code-guess-after-insert-file-function
                        after-insert-file-functions)
                  '(jam-code-guess-after-insert-file-function)))
	     )
	 (as-binary-input-file
	  (condition-case ()
	      (progn (insert-file-contents file) t)
	    (file-error nil))
	  )))
     ))
  (defun gnus-prepare-save-mail-function ()
    (setq file-coding-system *noconv*
	  buffer-file-coding-system 'no-conversion)
    )
  (add-hook 'nnmail-prepare-save-mail-hook
	    'gnus-prepare-save-mail-function)
  
  (gnus-set-newsgroup-default-charset "alt.chinese" 'hz-gb-2312)
  (gnus-set-newsgroup-default-charset "alt.chinese.text.big5" 'cn-big5)
  (gnus-set-newsgroup-default-charset "fj"	'iso-2022-jp-2)
  (gnus-set-newsgroup-default-charset "han"    	'euc-kr)
  (gnus-set-newsgroup-default-charset "hk"	'cn-big5)
  (gnus-set-newsgroup-default-charset "hkstar"	'cn-big5)
  (gnus-set-newsgroup-default-charset "relcom"	'koi8-r)
  (gnus-set-newsgroup-default-charset "tw"	'cn-big5)
  ))


;;; @ end
;;;

(provide 'gnus-charset)

;;; gnus-charset.el ends here