1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
30 ;;; Function aliases later to be redefined for XEmacs usage.
32 (defvar gnus-xemacs (string-match "XEmacs\\|Lucid" emacs-version)
33 "Non-nil if running under XEmacs.")
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
41 (< emacs-major-version 20))
46 (autoload 'gnus-xmas-define "gnus-xmas")
47 (autoload 'gnus-xmas-redefine "gnus-xmas")
48 (autoload 'appt-select-lowest-window "appt"))
52 (defun gnus-mule-max-width-function (el max-width)
53 (` (let* ((val (eval (, el)))
54 (valstr (if (numberp val)
55 (int-to-string val) val)))
56 (if (> (length valstr) (, max-width))
57 (truncate-string-to-width valstr (, max-width))
61 (if (string-match "XEmacs\\|Lucid" emacs-version)
64 (defvar gnus-mouse-face-prop 'mouse-face
65 "Property used for highlighting mouse regions."))
68 ((string-match "XEmacs\\|Lucid" emacs-version)
72 (provide 'gnusutil))))
77 (defun gnus-dummy-func (&rest args))
78 (let ((funcs '(mouse-set-point set-face-foreground
79 set-face-background x-popup-menu)))
81 (unless (fboundp (car funcs))
82 (fset (car funcs) 'gnus-dummy-func))
83 (setq funcs (cdr funcs)))))))
86 (let ((case-fold-search t))
88 ((string-match "windows-nt\\|os/2\\|emx" (symbol-name system-type))
89 (setq nnheader-file-name-translation-alist
90 (append nnheader-file-name-translation-alist
94 (defvar gnus-tmp-unread)
95 (defvar gnus-tmp-replied)
96 (defvar gnus-tmp-score-char)
97 (defvar gnus-tmp-indentation)
98 (defvar gnus-tmp-opening-bracket)
99 (defvar gnus-tmp-lines)
100 (defvar gnus-tmp-name)
101 (defvar gnus-tmp-closing-bracket)
102 (defvar gnus-tmp-subject-or-nil)
104 (defun gnus-ems-redefine ()
106 ((string-match "XEmacs\\|Lucid" emacs-version)
107 (gnus-xmas-redefine))
110 ;; Mule and new Emacs definitions
112 ;; [Note] Now there are three kinds of mule implementations,
113 ;; original MULE, XEmacs/mule and beta version of Emacs including
114 ;; some mule features. Unfortunately these API are different. In
115 ;; particular, Emacs (including original MULE) and XEmacs are
117 ;; Predicates to check are following:
118 ;; (boundp 'MULE) is t only if MULE (original; anything older than
119 ;; Mule 2.3) is running.
120 ;; (featurep 'mule) is t when every mule variants are running.
122 ;; These implementations may be able to share between original
123 ;; MULE and beta version of new Emacs. In addition, it is able to
124 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
125 ;; `emacs-version'. In this case, implementation for XEmacs/mule
126 ;; may be able to share between XEmacs and XEmacs/mule.
128 (defvar gnus-summary-display-table nil
129 "Display table used in summary mode buffers.")
130 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
131 (fset 'gnus-summary-set-display-table (lambda ()))
133 (when (boundp 'gnus-check-before-posting)
134 (setq gnus-check-before-posting
136 (delq 'control-chars gnus-check-before-posting))))
138 (defun gnus-summary-line-format-spec ()
139 (insert gnus-tmp-unread gnus-tmp-replied
140 gnus-tmp-score-char gnus-tmp-indentation)
145 gnus-tmp-opening-bracket
148 (if (> (length gnus-tmp-name) 20)
149 (truncate-string-to-width gnus-tmp-name 20)
151 gnus-tmp-closing-bracket)
153 gnus-mouse-face-prop gnus-mouse-face)
154 (insert " " gnus-tmp-subject-or-nil "\n"))
157 (defun gnus-region-active-p ()
158 "Say whether the region is active."
159 (and (boundp 'transient-mark-mode)
161 (boundp 'mark-active)
164 (defun gnus-add-minor-mode (mode name map)
165 (if (fboundp 'add-minor-mode)
166 (add-minor-mode mode name map)
167 (set (make-local-variable mode) t)
168 (unless (assq mode minor-mode-alist)
169 (push `(,mode ,name) minor-mode-alist))
170 (unless (assq mode minor-mode-map-alist)
171 (push (cons mode map)
172 minor-mode-map-alist))))
174 (defun gnus-x-splash ()
175 "Show a splash screen using a pixmap in the current buffer."
176 (let ((dir (nnheader-find-etc-directory "gnus"))
177 pixmap file height beg i)
179 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
180 (let ((buffer-read-only nil))
183 (file-exists-p (setq file (concat dir "x-splash"))))
185 (insert-file-contents file)
186 (goto-char (point-min))
188 (setq pixmap (read (current-buffer))))))
191 (unless (facep 'gnus-splash)
192 (make-face 'gnus-splash))
193 (setq height (/ (car pixmap) (frame-char-height))
194 width (/ (cadr pixmap) (frame-char-width)))
195 (set-face-foreground 'gnus-splash "Brown")
196 (set-face-stipple 'gnus-splash pixmap)
197 (insert-char ?\n (* (/ (window-height) 2 height) height))
200 (insert-char ? (* (+ (/ (window-width) 2 width) 1) width))
202 (insert-char ? width)
203 (set-text-properties beg (point) '(face gnus-splash))
206 (goto-char (point-min))
212 ;; byte-compile-warnings: '(redefine callargs)
215 ;;; gnus-ems.el ends here