Revert last change.
[emacs.git] / lisp / gnus / gnus-mule.el
blobf8100ee6402d2b4fce68997aa1e9fc2de64a35dc
1 ;;; gnus-mule.el --- Provide backward compatibility function to GNUS
3 ;; Copyright (C) 1995,1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 2000 Electrotechnical Laboratory, JAPAN.
6 ;; Maintainer: FSF
7 ;; Keywords: news, i18n
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;; This file provides the function `gnus-mule-add-group' for backward
29 ;; compatibility with old version of Gnus included in Emacs 20.
31 (require 'gnus-sum)
33 ;;;###autoload
34 (defun gnus-mule-add-group (name coding-system)
35 "Specify that articles of news group NAME are encoded in CODING-SYSTEM.
36 All news groups deeper than NAME are also the target.
37 If CODING-SYSTEM is a cons, the car part is used and the cdr
38 part is ignored.
40 This function exists for backward comaptibility with Emacs 20. It is
41 recommended to customize the variable `gnus-group-charset-alist'
42 rather than using this function."
43 (if (consp coding-system)
44 ;; Ignore the cdr part because now Gnus can't use different
45 ;; coding systems for encoding and decoding.
46 (setq coding-system (car coding-system)))
47 (let ((tail gnus-group-charset-alist)
48 (prev nil)
49 (pattern (concat "^" (regexp-quote name))))
50 ;; Check entries of `gnus-group-charset-alist' if they match NAME.
51 (while (not (string-match (car (car tail)) name))
52 (setq prev tail tail (cdr tail)))
53 (if tail
54 ;; A matching entry was found.
55 (if (string= pattern (car (car tail)))
56 ;; We can modify this entry.
57 (setcar (cdr (car tail)) coding-system)
58 ;; We must add a new entry before this.
59 (if prev
60 (setcdr prev (cons (list pattern coding-system)
61 (cdr prev)))
62 (setq gnus-group-charset-alist
63 (cons (list pattern coding-system)
64 gnus-group-charset-alist))))
65 ;; We must prepend a new entry.
66 (setq gnus-group-charset-alist
67 (cons (list pattern coding-system)
68 gnus-group-charset-alist)))))
70 (provide 'gnus-mule)
72 ;; gnus-mule.el ends here