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-cite-add-face (number prefix face)
53 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
55 (let ((inhibit-point-motion-hooks t)
58 (unless (eobp) ; Sometimes things become confused (broken).
60 (forward-char (chars-in-string prefix))
61 (forward-char (length prefix)))
62 (skip-chars-forward " \t")
65 (skip-chars-backward " \t")
68 (push (setq overlay (gnus-make-overlay from to))
69 gnus-cite-overlay-list)
70 (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
72 (defun gnus-mule-max-width-function (el max-width)
73 (` (let* ((val (eval (, el)))
74 (valstr (if (numberp val)
75 (int-to-string val) val)))
76 (if (> (length valstr) (, max-width))
77 (truncate-string-to-width valstr (, max-width))
81 (if (string-match "XEmacs\\|Lucid" emacs-version)
84 (defvar gnus-mouse-face-prop 'mouse-face
85 "Property used for highlighting mouse regions."))
88 ((string-match "XEmacs\\|Lucid" emacs-version)
92 (provide 'gnusutil))))
97 (defun gnus-dummy-func (&rest args))
98 (let ((funcs '(mouse-set-point set-face-foreground
99 set-face-background x-popup-menu)))
101 (unless (fboundp (car funcs))
102 (fset (car funcs) 'gnus-dummy-func))
103 (setq funcs (cdr funcs)))))))
106 (let ((case-fold-search t))
108 ((string-match "windows-nt\\|os/2\\|emx" (symbol-name system-type))
109 (setq nnheader-file-name-translation-alist
110 (append nnheader-file-name-translation-alist
114 (defvar gnus-tmp-unread)
115 (defvar gnus-tmp-replied)
116 (defvar gnus-tmp-score-char)
117 (defvar gnus-tmp-indentation)
118 (defvar gnus-tmp-opening-bracket)
119 (defvar gnus-tmp-lines)
120 (defvar gnus-tmp-name)
121 (defvar gnus-tmp-closing-bracket)
122 (defvar gnus-tmp-subject-or-nil)
124 (defun gnus-ems-redefine ()
126 ((string-match "XEmacs\\|Lucid" emacs-version)
127 (gnus-xmas-redefine))
130 ;; Mule and new Emacs definitions
132 ;; [Note] Now there are three kinds of mule implementations,
133 ;; original MULE, XEmacs/mule and beta version of Emacs including
134 ;; some mule features. Unfortunately these API are different. In
135 ;; particular, Emacs (including original MULE) and XEmacs are
137 ;; Predicates to check are following:
138 ;; (boundp 'MULE) is t only if MULE (original; anything older than
139 ;; Mule 2.3) is running.
140 ;; (featurep 'mule) is t when every mule variants are running.
142 ;; These implementations may be able to share between original
143 ;; MULE and beta version of new Emacs. In addition, it is able to
144 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
145 ;; `emacs-version'. In this case, implementation for XEmacs/mule
146 ;; may be able to share between XEmacs and XEmacs/mule.
148 (defvar gnus-summary-display-table nil
149 "Display table used in summary mode buffers.")
150 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
151 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
152 (fset 'gnus-summary-set-display-table (lambda ()))
154 (when (boundp 'gnus-check-before-posting)
155 (setq gnus-check-before-posting
157 (delq 'control-chars gnus-check-before-posting))))
159 (defun gnus-summary-line-format-spec ()
160 (insert gnus-tmp-unread gnus-tmp-replied
161 gnus-tmp-score-char gnus-tmp-indentation)
166 gnus-tmp-opening-bracket
169 (if (> (length gnus-tmp-name) 20)
170 (truncate-string-to-width gnus-tmp-name 20)
172 gnus-tmp-closing-bracket)
174 gnus-mouse-face-prop gnus-mouse-face)
175 (insert " " gnus-tmp-subject-or-nil "\n"))
178 (defun gnus-region-active-p ()
179 "Say whether the region is active."
180 (and (boundp 'transient-mark-mode)
182 (boundp 'mark-active)
185 (defun gnus-add-minor-mode (mode name map)
186 (if (fboundp 'add-minor-mode)
187 (add-minor-mode mode name map)
188 (set (make-local-variable mode) t)
189 (unless (assq mode minor-mode-alist)
190 (push `(,mode ,name) minor-mode-alist))
191 (unless (assq mode minor-mode-map-alist)
192 (push (cons mode map)
193 minor-mode-map-alist))))
195 (defun gnus-x-splash ()
196 "Show a splash screen using a pixmap in the current buffer."
197 (let ((dir (nnheader-find-etc-directory "gnus"))
198 pixmap file height beg i)
200 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
201 (let ((buffer-read-only nil))
204 (file-exists-p (setq file (concat dir "x-splash"))))
206 (insert-file-contents file)
207 (goto-char (point-min))
209 (setq pixmap (read (current-buffer))))))
212 (unless (facep 'gnus-splash)
213 (make-face 'gnus-splash))
214 (setq height (/ (car pixmap) (frame-char-height))
215 width (/ (cadr pixmap) (frame-char-width)))
216 (set-face-foreground 'gnus-splash "Brown")
217 (set-face-stipple 'gnus-splash pixmap)
218 (insert-char ?\n (* (/ (window-height) 2 height) height))
221 (insert-char ? (* (+ (/ (window-width) 2 width) 1) width))
223 (insert-char ? width)
224 (set-text-properties beg (point) '(face gnus-splash))
227 (goto-char (point-min))
233 ;; byte-compile-warnings: '(redefine callargs)
236 ;;; gnus-ems.el ends here