1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
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-2 [down-mouse-2])
39 (autoload 'gnus-xmas-define "gnus-xmas")
40 (autoload 'gnus-xmas-redefine "gnus-xmas")
41 (autoload 'appt-select-lowest-window "appt"))
43 (or (fboundp 'mail-file-babyl-p)
44 (fset 'mail-file-babyl-p 'rmail-file-p))
48 (defun gnus-mule-cite-add-face (number prefix face)
49 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
51 (let ((inhibit-point-motion-hooks t)
55 (forward-char (chars-in-string prefix))
56 (forward-char (length prefix)))
57 (skip-chars-forward " \t")
60 (skip-chars-backward " \t")
63 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
65 (defun gnus-mule-max-width-function (el max-width)
66 (` (let* ((val (eval (, el)))
67 (valstr (if (numberp val)
68 (int-to-string val) val)))
69 (if (> (length valstr) (, max-width))
70 (truncate-string valstr (, max-width))
74 (if (string-match "XEmacs\\|Lucid" emacs-version)
77 (defvar gnus-mouse-face-prop 'mouse-face
78 "Property used for highlighting mouse regions."))
81 ((string-match "XEmacs\\|Lucid" emacs-version)
84 ((or (not (boundp 'emacs-minor-version))
85 (< emacs-minor-version 30))
86 ;; Remove the `intangible' prop.
87 (let ((props (and (boundp 'gnus-hidden-properties)
88 gnus-hidden-properties)))
89 (while (and props (not (eq (car (cdr props)) 'intangible)))
90 (setq props (cdr props)))
92 (setcdr props (cdr (cdr (cdr props))))))
93 (unless (fboundp 'buffer-substring-no-properties)
94 (defun buffer-substring-no-properties (beg end)
95 (format "%s" (buffer-substring beg end)))))
98 (provide 'gnusutil))))
103 (defun gnus-dummy-func (&rest args))
104 (let ((funcs '(mouse-set-point set-face-foreground
105 set-face-background x-popup-menu)))
107 (unless (fboundp (car funcs))
108 (fset (car funcs) 'gnus-dummy-func))
109 (setq funcs (cdr funcs))))))
110 (unless (fboundp 'file-regular-p)
111 (defun file-regular-p (file)
112 (and (not (file-directory-p file))
113 (not (file-symlink-p file))
114 (file-exists-p file))))
115 (unless (fboundp 'face-list)
116 (defun face-list (&rest args))))
119 (let ((case-fold-search t))
121 ((string-match "windows-nt\\|os/2\\|emx" (format "%s" system-type))
122 (setq nnheader-file-name-translation-alist
123 (append nnheader-file-name-translation-alist
127 (defvar gnus-tmp-unread)
128 (defvar gnus-tmp-replied)
129 (defvar gnus-tmp-score-char)
130 (defvar gnus-tmp-indentation)
131 (defvar gnus-tmp-opening-bracket)
132 (defvar gnus-tmp-lines)
133 (defvar gnus-tmp-name)
134 (defvar gnus-tmp-closing-bracket)
135 (defvar gnus-tmp-subject-or-nil)
137 (defun gnus-ems-redefine ()
139 ((string-match "XEmacs\\|Lucid" emacs-version)
140 (gnus-xmas-redefine))
143 ;; Mule and new Emacs definitions
145 ;; [Note] Now there are three kinds of mule implementations,
146 ;; original MULE, XEmacs/mule and beta version of Emacs including
147 ;; some mule features. Unfortunately these API are different. In
148 ;; particular, Emacs (including original MULE) and XEmacs are
150 ;; Predicates to check are following:
151 ;; (boundp 'MULE) is t only if MULE (original; anything older than
152 ;; Mule 2.3) is running.
153 ;; (featurep 'mule) is t when every mule variants are running.
155 ;; These implementations may be able to share between original
156 ;; MULE and beta version of new Emacs. In addition, it is able to
157 ;; detect XEmacs/mule by (featurep 'mule) and to check variable
158 ;; `emacs-version'. In this case, implementation for XEmacs/mule
159 ;; may be able to share between XEmacs and XEmacs/mule.
161 (defalias 'gnus-truncate-string 'truncate-string)
163 (defvar gnus-summary-display-table nil
164 "Display table used in summary mode buffers.")
165 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
166 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
167 (fset 'gnus-summary-set-display-table 'ignore)
169 (when (boundp 'gnus-check-before-posting)
170 (setq gnus-check-before-posting
172 (delq 'control-chars gnus-check-before-posting))))
174 (defun gnus-summary-line-format-spec ()
175 (insert gnus-tmp-unread gnus-tmp-replied
176 gnus-tmp-score-char gnus-tmp-indentation)
181 gnus-tmp-opening-bracket
184 (if (> (length gnus-tmp-name) 20)
185 (truncate-string gnus-tmp-name 20)
187 gnus-tmp-closing-bracket)
189 gnus-mouse-face-prop gnus-mouse-face)
190 (insert " " gnus-tmp-subject-or-nil "\n"))
193 (defun gnus-region-active-p ()
194 "Say whether the region is active."
195 (and (boundp 'transient-mark-mode)
197 (boundp 'mark-active)
203 ;; byte-compile-warnings: '(redefine callargs)
206 ;;; gnus-ems.el ends here