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\\|cygwin32"
89 (symbol-name system-type))
90 (setq nnheader-file-name-translation-alist
91 (append nnheader-file-name-translation-alist
95 (defvar gnus-tmp-unread)
96 (defvar gnus-tmp-replied)
97 (defvar gnus-tmp-score-char)
98 (defvar gnus-tmp-indentation)
99 (defvar gnus-tmp-opening-bracket)
100 (defvar gnus-tmp-lines)
101 (defvar gnus-tmp-name)
102 (defvar gnus-tmp-closing-bracket)
103 (defvar gnus-tmp-subject-or-nil)
105 (defun gnus-ems-redefine ()
107 ((string-match "XEmacs\\|Lucid" emacs-version)
108 (gnus-xmas-redefine))
111 ;; Mule and new Emacs definitions
113 ;; [Note] Now there are three kinds of mule implementations,
114 ;; original MULE, XEmacs/mule and beta version of Emacs including
115 ;; some mule features. Unfortunately these API are different. In
116 ;; particular, Emacs (including original MULE) and XEmacs are
118 ;; Predicates to check are following:
119 ;; (boundp 'MULE) is t only if MULE (original; anything older than
120 ;; Mule 2.3) is running.
121 ;; (featurep 'mule) is t when every mule variants are running.
123 ;; These implementations may be able to share between original
124 ;; MULE and beta version of new Emacs. In addition, it is able to
125 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
126 ;; `emacs-version'. In this case, implementation for XEmacs/mule
127 ;; may be able to share between XEmacs and XEmacs/mule.
129 (defvar gnus-summary-display-table nil
130 "Display table used in summary mode buffers.")
131 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
132 (fset 'gnus-summary-set-display-table (lambda ()))
134 (when (boundp 'gnus-check-before-posting)
135 (setq gnus-check-before-posting
137 (delq 'control-chars gnus-check-before-posting))))
139 (defun gnus-summary-line-format-spec ()
140 (insert gnus-tmp-unread gnus-tmp-replied
141 gnus-tmp-score-char gnus-tmp-indentation)
146 gnus-tmp-opening-bracket
149 (if (> (length gnus-tmp-name) 20)
150 (truncate-string-to-width gnus-tmp-name 20)
152 gnus-tmp-closing-bracket)
154 gnus-mouse-face-prop gnus-mouse-face)
155 (insert " " gnus-tmp-subject-or-nil "\n"))
158 (defun gnus-region-active-p ()
159 "Say whether the region is active."
160 (and (boundp 'transient-mark-mode)
162 (boundp 'mark-active)
165 (defun gnus-add-minor-mode (mode name map)
166 (if (fboundp 'add-minor-mode)
167 (add-minor-mode mode name map)
168 (set (make-local-variable mode) t)
169 (unless (assq mode minor-mode-alist)
170 (push `(,mode ,name) minor-mode-alist))
171 (unless (assq mode minor-mode-map-alist)
172 (push (cons mode map)
173 minor-mode-map-alist))))
175 (defun gnus-x-splash ()
176 "Show a splash screen using a pixmap in the current buffer."
177 (let ((dir (nnheader-find-etc-directory "gnus"))
178 pixmap file height beg i)
180 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
181 (let ((buffer-read-only nil))
184 (file-exists-p (setq file (concat dir "x-splash"))))
186 (insert-file-contents file)
187 (goto-char (point-min))
189 (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) 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