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@ifi.uio.no>
5 ;; Tatsuya Ichikawa <t-ichi@niagara.shiojiri.ne.jp>
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-2 [down-mouse-2])
38 (defvar gnus-mode-line-modified
40 (< emacs-major-version 20))
45 (autoload 'gnus-xmas-define "gnus-xmas")
46 (autoload 'gnus-xmas-redefine "gnus-xmas")
47 (autoload 'appt-select-lowest-window "appt"))
49 (or (fboundp 'mail-file-babyl-p)
50 (fset 'mail-file-babyl-p 'rmail-file-p))
54 (defun gnus-mule-cite-add-face (number prefix face)
55 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
57 (let ((inhibit-point-motion-hooks t)
60 (unless (eobp) ; Sometimes things become confused (broken).
62 (forward-char (chars-in-string prefix))
63 (forward-char (length prefix)))
64 (skip-chars-forward " \t")
67 (skip-chars-backward " \t")
70 (push (setq overlay (gnus-make-overlay from to))
71 gnus-cite-overlay-list)
72 (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
74 (defun gnus-mule-max-width-function (el max-width)
75 (` (let* ((val (eval (, el)))
76 (valstr (if (numberp val)
77 (int-to-string val) val)))
78 (if (> (length valstr) (, max-width))
79 (truncate-string valstr (, max-width))
82 (defvar gnus-bdf-image-file nil)
83 (defun gnus-mule-group-startup-message (&optional x y)
84 "Insert startup message in current buffer."
85 ;; Insert the message.
88 (if (featurep 'bitmap)
92 "" (if (and (stringp gnus-bdf-image-file)
93 (file-exists-p gnus-bdf-image-file))
94 (insert-file gnus-image-file)))
117 (gnus-indent-rigidly (point-min) (point-max)
118 (/ (max (- (window-width) (or x 46)) 0) 2))
119 (goto-char (point-min))
121 (let* ((pheight (count-lines (point-min) (point-max)))
122 (wheight (window-height))
123 (rest (- wheight pheight)))
124 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
126 (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)
127 (goto-char (point-min))
128 (setq mode-line-buffer-identification (concat " " gnus-version))
129 (setq gnus-simple-splash t)
130 (set-buffer-modified-p t))
132 (defun gnus-encode-coding-string (string system)
135 (defun gnus-decode-coding-string (string system)
139 (if (string-match "XEmacs\\|Lucid" emacs-version)
142 (defvar gnus-mouse-face-prop 'mouse-face
143 "Property used for highlighting mouse regions."))
146 ((string-match "XEmacs\\|Lucid" emacs-version)
149 ((or (not (boundp 'emacs-minor-version))
150 (and (< emacs-major-version 20)
151 (< emacs-minor-version 30)))
152 ;; Remove the `intangible' prop.
153 (let ((props (and (boundp 'gnus-hidden-properties)
154 gnus-hidden-properties)))
155 (while (and props (not (eq (car (cdr props)) 'intangible)))
156 (setq props (cdr props)))
158 (setcdr props (cdr (cdr (cdr props))))))
159 (unless (fboundp 'buffer-substring-no-properties)
160 (defun buffer-substring-no-properties (beg end)
161 (format "%s" (buffer-substring beg end)))))
164 (provide 'gnusutil))))
169 (defun gnus-dummy-func (&rest args))
170 (let ((funcs '(mouse-set-point set-face-foreground
171 set-face-background x-popup-menu)))
173 (unless (fboundp (car funcs))
174 (fset (car funcs) 'gnus-dummy-func))
175 (setq funcs (cdr funcs))))))
176 (unless (fboundp 'file-regular-p)
177 (defun file-regular-p (file)
178 (and (not (file-directory-p file))
179 (not (file-symlink-p file))
180 (file-exists-p file))))
181 (unless (fboundp 'face-list)
182 (defun face-list (&rest args))))
185 (let ((case-fold-search t))
187 ((string-match "windows-nt\\|os/2\\|emx" (format "%s" system-type))
188 (setq nnheader-file-name-translation-alist
189 (append nnheader-file-name-translation-alist
193 (defvar gnus-tmp-unread)
194 (defvar gnus-tmp-replied)
195 (defvar gnus-tmp-score-char)
196 (defvar gnus-tmp-indentation)
197 (defvar gnus-tmp-opening-bracket)
198 (defvar gnus-tmp-lines)
199 (defvar gnus-tmp-name)
200 (defvar gnus-tmp-closing-bracket)
201 (defvar gnus-tmp-subject-or-nil)
203 (defun gnus-ems-redefine ()
205 ((string-match "XEmacs\\|Lucid" emacs-version)
206 (gnus-xmas-redefine))
209 ;; Mule and new Emacs definitions
211 ;; [Note] Now there are three kinds of mule implementations,
212 ;; original MULE, XEmacs/mule and beta version of Emacs including
213 ;; some mule features. Unfortunately these API are different. In
214 ;; particular, Emacs (including original MULE) and XEmacs are
216 ;; Predicates to check are following:
217 ;; (boundp 'MULE) is t only if MULE (original; anything older than
218 ;; Mule 2.3) is running.
219 ;; (featurep 'mule) is t when every mule variants are running.
221 ;; These implementations may be able to share between original
222 ;; MULE and beta version of new Emacs. In addition, it is able to
223 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
224 ;; `emacs-version'. In this case, implementation for XEmacs/mule
225 ;; may be able to share between XEmacs and XEmacs/mule.
227 (defalias 'gnus-truncate-string 'truncate-string)
229 (defvar gnus-summary-display-table nil
230 "Display table used in summary mode buffers.")
231 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
232 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
233 (fset 'gnus-summary-set-display-table (lambda ()))
234 (fset 'gnus-encode-coding-string 'encode-coding-string)
235 (fset 'gnus-decode-coding-string 'decode-coding-string)
238 (module-installed-p 'bitmap)
239 (fset 'gnus-group-startup-message 'gnus-mule-group-startup-message))
241 (when (boundp 'gnus-check-before-posting)
242 (setq gnus-check-before-posting
244 (delq 'control-chars gnus-check-before-posting))))
246 (defun gnus-summary-line-format-spec ()
247 (insert gnus-tmp-unread gnus-tmp-replied
248 gnus-tmp-score-char gnus-tmp-indentation)
253 gnus-tmp-opening-bracket
256 (if (> (length gnus-tmp-name) 20)
257 (truncate-string gnus-tmp-name 20)
259 gnus-tmp-closing-bracket)
261 gnus-mouse-face-prop gnus-mouse-face)
262 (insert " " gnus-tmp-subject-or-nil "\n"))
265 (defun gnus-region-active-p ()
266 "Say whether the region is active."
267 (and (boundp 'transient-mark-mode)
269 (boundp 'mark-active)
272 (defun gnus-add-minor-mode (mode name map)
273 (if (fboundp 'add-minor-mode)
274 (add-minor-mode mode name map)
275 (unless (assq mode minor-mode-alist)
276 (push `(,mode ,name) minor-mode-alist))
277 (unless (assq mode minor-mode-map-alist)
278 (push (cons mode map)
279 minor-mode-map-alist))))
281 (defun gnus-x-splash ()
282 "Show a splash screen using a pixmap in the current buffer."
283 (let ((dir (nnheader-find-etc-directory "gnus"))
284 pixmap file height beg i)
286 (switch-to-buffer (get-buffer-create gnus-group-buffer))
287 (let ((buffer-read-only nil))
290 (file-exists-p (setq file (concat dir "x-splash"))))
291 (nnheader-temp-write nil
292 (insert-file-contents file)
293 (goto-char (point-min))
295 (setq pixmap (read (current-buffer))))))
298 (unless (facep 'gnus-splash)
299 (make-face 'gnus-splash))
300 (setq height (/ (car pixmap) (frame-char-height))
301 width (/ (cadr pixmap) (frame-char-width)))
302 (set-face-foreground 'gnus-splash "ForestGreen")
303 (set-face-stipple 'gnus-splash pixmap)
304 (insert-char ?\n (* (/ (window-height) 2 height) height))
307 (insert-char ? (* (+ (/ (window-width) 2 width) 1) width))
309 (insert-char ? width)
310 (set-text-properties beg (point) '(face gnus-splash))
313 (goto-char (point-min))
319 ;; byte-compile-warnings: '(redefine callargs)
322 ;;; gnus-ems.el ends here