(gnus-group-make-rss-group): Exclude `/'s.
[gnus] / lisp / gnus-ems.el
1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;;        Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval-when-compile
30   (require 'cl)
31   (require 'ring))
32
33 ;;; Function aliases later to be redefined for XEmacs usage.
34
35 (defvar gnus-mouse-2 [mouse-2])
36 (defvar gnus-down-mouse-3 [down-mouse-3])
37 (defvar gnus-down-mouse-2 [down-mouse-2])
38 (defvar gnus-widget-button-keymap nil)
39 (defvar gnus-mode-line-modified
40   (if (featurep 'xemacs)
41       '("--**-" . "-----")
42     '("**" "--")))
43
44 (eval-and-compile
45   (autoload 'gnus-xmas-define "gnus-xmas")
46   (autoload 'gnus-xmas-redefine "gnus-xmas")
47   (autoload 'gnus-get-buffer-create "gnus")
48   (autoload 'nnheader-find-etc-directory "nnheader"))
49
50 (autoload 'smiley-region "smiley")
51
52 (defun gnus-kill-all-overlays ()
53   "Delete all overlays in the current buffer."
54   (let* ((overlayss (overlay-lists))
55          (buffer-read-only nil)
56          (overlays (delq nil (nconc (car overlayss) (cdr overlayss)))))
57     (while overlays
58       (delete-overlay (pop overlays)))))
59
60 ;;; Mule functions.
61
62 (defun gnus-mule-max-width-function (el max-width)
63   `(let* ((val (eval (, el)))
64           (valstr (if (numberp val)
65                       (int-to-string val) val)))
66      (if (> (length valstr) ,max-width)
67          (truncate-string-to-width valstr ,max-width)
68        valstr)))
69
70 (eval-and-compile
71   (if (featurep 'xemacs)
72       (gnus-xmas-define)
73     (defvar gnus-mouse-face-prop 'mouse-face
74       "Property used for highlighting mouse regions.")))
75
76 (eval-when-compile
77   (defvar gnus-tmp-unread)
78   (defvar gnus-tmp-replied)
79   (defvar gnus-tmp-score-char)
80   (defvar gnus-tmp-indentation)
81   (defvar gnus-tmp-opening-bracket)
82   (defvar gnus-tmp-lines)
83   (defvar gnus-tmp-name)
84   (defvar gnus-tmp-closing-bracket)
85   (defvar gnus-tmp-subject-or-nil)
86   (defvar gnus-check-before-posting)
87   (defvar gnus-mouse-face)
88   (defvar gnus-group-buffer))
89
90 (defun gnus-ems-redefine ()
91   (cond
92    ((featurep 'xemacs)
93     (gnus-xmas-redefine))
94
95    ((featurep 'mule)
96     ;; Mule and new Emacs definitions
97
98     ;; [Note] Now there are three kinds of mule implementations,
99     ;; original MULE, XEmacs/mule and Emacs 20+ including
100     ;; MULE features.  Unfortunately these APIs are different.  In
101     ;; particular, Emacs (including original Mule) and XEmacs are
102     ;; quite different.  However, this version of Gnus doesn't support
103     ;; anything other than XEmacs 20+ and Emacs 20.3+.
104
105     ;; Predicates to check are following:
106     ;; (boundp 'MULE) is t only if Mule (original; anything older than
107     ;;                     Mule 2.3) is running.
108     ;; (featurep 'mule) is t when other mule variants are running.
109
110     ;; It is possible to detect XEmacs/mule by (featurep 'mule) and
111     ;; (featurep 'xemacs).  In this case, the implementation for
112     ;; XEmacs/mule may be shareable between XEmacs and XEmacs/mule.
113
114     (defvar gnus-summary-display-table nil
115       "Display table used in summary mode buffers.")
116     (defalias 'gnus-max-width-function 'gnus-mule-max-width-function)
117
118     (when (boundp 'gnus-check-before-posting)
119       (setq gnus-check-before-posting
120             (delq 'long-lines
121                   (delq 'control-chars gnus-check-before-posting))))
122