1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995,96,97,98 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-mouse-3 [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 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))))))
104 (unless (fboundp 'file-regular-p)
105 (defun file-regular-p (file)
106 (and (not (file-directory-p file))
107 (not (file-symlink-p file))
108 (file-exists-p file))))
109 (unless (fboundp 'face-list)
110 (defun face-list (&rest args))))
113 (let ((case-fold-search t))
115 ((string-match "windows-nt\\|os/2\\|emx" (symbol-name system-type))
116 (setq nnheader-file-name-translation-alist
117 (append nnheader-file-name-translation-alist
121 (defvar gnus-tmp-unread)
122 (defvar gnus-tmp-replied)
123 (defvar gnus-tmp-score-char)
124 (defvar gnus-tmp-indentation)
125 (defvar gnus-tmp-opening-bracket)
126 (defvar gnus-tmp-lines)
127 (defvar gnus-tmp-name)
128 (defvar gnus-tmp-closing-bracket)
129 (defvar gnus-tmp-subject-or-nil)
131 (defun gnus-ems-redefine ()
133 ((string-match "XEmacs\\|Lucid" emacs-version)
134 (gnus-xmas-redefine))
137 ;; Mule and new Emacs definitions
139 ;; [Note] Now there are three kinds of mule implementations,
140 ;; original MULE, XEmacs/mule and beta version of Emacs including
141 ;; some mule features. Unfortunately these API are different. In
142 ;; particular, Emacs (including original MULE) and XEmacs are
144 ;; Predicates to check are following:
145 ;; (boundp 'MULE) is t only if MULE (original; anything older than
146 ;; Mule 2.3) is running.
147 ;; (featurep 'mule) is t when every mule variants are running.
149 ;; These implementations may be able to share between original
150 ;; MULE and beta version of new Emacs. In addition, it is able to
151 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
152 ;; `emacs-version'. In this case, implementation for XEmacs/mule
153 ;; may be able to share between XEmacs and XEmacs/mule.
155 (defvar gnus-summary-display-table nil
156 "Display table used in summary mode buffers.")
157 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
158 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
159 (fset 'gnus-summary-set-display-table (lambda ()))
161 (when (boundp 'gnus-check-before-posting)
162 (setq gnus-check-before-posting
164 (delq 'control-chars gnus-check-before-posting))))
166 (defun gnus-summary-line-format-spec ()
167 (insert gnus-tmp-unread gnus-tmp-replied
168 gnus-tmp-score-char gnus-tmp-indentation)
173 gnus-tmp-opening-bracket
176 (if (> (length gnus-tmp-name) 20)
177 (truncate-string gnus-tmp-name 20)
179 gnus-tmp-closing-bracket)
181 gnus-mouse-face-prop gnus-mouse-face)
182 (insert " " gnus-tmp-subject-or-nil "\n"))
185 (defun gnus-region-active-p ()
186 "Say whether the region is active."
187 (and (boundp 'transient-mark-mode)
189 (boundp 'mark-active)
192 (defun gnus-add-minor-mode (mode name map)
193 (if (fboundp 'add-minor-mode)
194 (add-minor-mode mode name map)
195 (set (make-local-variable mode) t)
196 (unless (assq mode minor-mode-alist)
197 (push `(,mode ,name) minor-mode-alist))
198 (unless (assq mode minor-mode-map-alist)
199 (push (cons mode map)
200 minor-mode-map-alist))))
202 (defun gnus-x-splash ()
203 "Show a splash screen using a pixmap in the current buffer."
204 (let ((dir (nnheader-find-etc-directory "gnus"))
205 pixmap file height beg i)
207 (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
208 (let ((buffer-read-only nil))
211 (file-exists-p (setq file (concat dir "x-splash"))))
213 (insert-file-contents file)
214 (goto-char (point-min))
216 (setq pixmap (read (current-buffer))))))
219 (unless (facep 'gnus-splash)
220 (make-face 'gnus-splash))
221 (setq height (/ (car pixmap) (frame-char-height))
222 width (/ (cadr pixmap) (frame-char-width)))
223 (set-face-foreground 'gnus-splash "Brown")
224 (set-face-stipple 'gnus-splash pixmap)
225 (insert-char ?\n (* (/ (window-height) 2 height) height))
228 (insert-char ? (* (+ (/ (window-width) 2 width) 1) width))
230 (insert-char ? width)
231 (set-text-properties beg (point) '(face gnus-splash))
234 (goto-char (point-min))
240 ;; byte-compile-warnings: '(redefine callargs)
243 ;;; gnus-ems.el ends here