1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
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)
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.
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.
29 (eval-when-compile (require 'cl))
31 ;;; Function aliases later to be redefined for XEmacs usage.
33 (defvar gnus-xemacs (string-match "XEmacs\\|Lucid" emacs-version)
34 "Non-nil if running under XEmacs.")
36 (defvar gnus-mouse-2 [mouse-2])
37 (defvar gnus-down-mouse-3 [down-mouse-3])
38 (defvar gnus-down-mouse-2 [down-mouse-2])
39 (defvar gnus-widget-button-keymap nil)
40 (defvar gnus-mode-line-modified
42 (< emacs-major-version 20))
47 (autoload 'gnus-xmas-define "gnus-xmas")
48 (autoload 'gnus-xmas-redefine "gnus-xmas")
49 (autoload 'appt-select-lowest-window "appt"))
53 (defun gnus-mule-max-width-function (el max-width)
54 `(let* ((val (eval (, el)))
55 (valstr (if (numberp val)
56 (int-to-string val) val)))
57 (if (> (length valstr) ,max-width)
58 (truncate-string-to-width valstr ,max-width)
62 (if (string-match "XEmacs\\|Lucid" emacs-version)
65 (defvar gnus-mouse-face-prop 'mouse-face
66 "Property used for highlighting mouse regions."))
69 ((string-match "XEmacs\\|Lucid" emacs-version)
73 (provide 'gnusutil))))
78 (defun gnus-dummy-func (&rest args))
79 (let ((funcs '(mouse-set-point set-face-foreground
80 set-face-background x-popup-menu)))
82 (unless (fboundp (car funcs))
83 (fset (car funcs) 'gnus-dummy-func))
84 (setq funcs (cdr funcs)))))))
87 (let ((case-fold-search t))
89 ((string-match "windows-nt\\|os/2\\|emx\\|cygwin32"
90 (symbol-name system-type))
91 (setq nnheader-file-name-translation-alist
92 (append nnheader-file-name-translation-alist
93 (mapcar (lambda (c) (cons c ?_))
94 '(?: ?* ?\" ?< ?> ??))
97 (defvar gnus-tmp-unread)
98 (defvar gnus-tmp-replied)
99 (defvar gnus-tmp-score-char)
100 (defvar gnus-tmp-indentation)
101 (defvar gnus-tmp-opening-bracket)
102 (defvar gnus-tmp-lines)
103 (defvar gnus-tmp-name)
104 (defvar gnus-tmp-closing-bracket)
105 (defvar gnus-tmp-subject-or-nil)
107 (defun gnus-ems-redefine ()
109 ((string-match "XEmacs\\|Lucid" emacs-version)
110 (gnus-xmas-redefine))
113 ;; Mule and new Emacs definitions
115 ;; [Note] Now there are three kinds of mule implementations,
116 ;; original MULE, XEmacs/mule and beta version of Emacs including
117 ;; some mule features. Unfortunately these API are different. In
118 ;; particular, Emacs (including original MULE) and XEmacs are
120 ;; Predicates to check are following:
121 ;; (boundp 'MULE) is t only if MULE (original; anything older than
122 ;; Mule 2.3) is running.
123 ;; (featurep 'mule) is t when every mule variants are running.
125 ;; These implementations may be able to share between original
126 ;; MULE and beta version of new Emacs. In addition, it is able to
127 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
128 ;; `emacs-version'. In this case, implementation for XEmacs/mule
129 ;; may be able to share between XEmacs and XEmacs/mule.
131 (defvar gnus-summary-display-table nil
132 "Display table used in summary mode buffers.")
133 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
134 (fset 'gnus-summary-set-display-table (lambda ()))
136 (when (boundp 'gnus-check-before-posting)
137 (setq gnus-check-before-posting
139 (delq 'control-chars gnus-check-before-posting))))
141 (defun gnus-summary-line-format-spec ()
142 (insert gnus-tmp-unread gnus-tmp-replied
143 gnus-tmp-score-char gnus-tmp-indentation)
148 gnus-tmp-opening-bracket
151 (if (> (length gnus-tmp-name) 20)
152 (truncate-string-to-width gnus-tmp-name 20)
154 gnus-tmp-closing-bracket)
156 gnus-mouse-face-prop gnus-mouse-face)
157 (insert " " gnus-tmp-subject-or-nil "\n")))))
159 (defun gnus-region-active-p ()
160 "Say whether the region is active."
161 (and (boundp 'transient-mark-mode)
163 (boundp 'mark-active)
166 (defun gnus-add-minor-mode (mode name map)
167 (if (fboundp 'add-minor-mode)
168 (add-minor-mode mode name map)
169 (set (make-local-variable mode) t)
170 (unless (assq mode minor-mode-alist)
171 (push `(,mode ,name) minor-mode-alist))
172 (unless (assq mode minor-mode-map-alist)
173 (push (cons mode map)
174 minor-mode-map-alist))))
176 (defun gnus-x-splash ()
177 "Show a splash screen using a pixmap in the current buffer."
178 (let ((dir (nnheader-find-etc-directory "gnus"))
179 pixmap file height beg i)
181 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
182 (let ((buffer-read-only nil))
185 (file-exists-p (setq file (concat dir "x-splash"))))
187 (insert-file-contents file)
188 (goto-char (point-min))
190 (setq pixmap (read (current-buffer))))))
192 (unless (facep 'gnus-splash)
193 (make-face 'gnus-splash))
194 (setq height (/ (car pixmap) (frame-char-height))
195 width (/ (cadr pixmap) (frame-char-width)))
196 (set-face-foreground 'gnus-splash "Brown")
197 (set-face-stipple 'gnus-splash pixmap)
198 (insert-char ?\n (* (/ (window-height) 2 height) height))
201 (insert-char ? (* (/ (window-width) 2 width) width))
203 (insert-char ? width)
204 (set-text-properties beg (point) '(face gnus-splash))
207 (goto-char (point-min))
213 ;; byte-compile-warnings: '(redefine callargs)
216 ;;; gnus-ems.el ends here