1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995,96 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
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 (defvar gnus-mouse-2 [mouse-2])
29 (defalias 'gnus-make-overlay 'make-overlay)
30 (defalias 'gnus-overlay-put 'overlay-put)
31 (defalias 'gnus-move-overlay 'move-overlay)
32 (defalias 'gnus-overlay-end 'overlay-end)
33 (defalias 'gnus-extent-detached-p 'ignore)
34 (defalias 'gnus-group-remove-excess-properties 'ignore)
35 (defalias 'gnus-topic-remove-excess-properties 'ignore)
36 (defalias 'gnus-extent-start-open 'ignore)
40 (autoload 'gnus-xmas-define "gnus-xmas")
41 (autoload 'gnus-xmas-redefine "gnus-xmas"))
43 (or (fboundp 'mail-file-babyl-p)
44 (fset 'mail-file-babyl-p 'rmail-file-p))
48 (defun gnus-mule-truncate-string (str width)
49 (let ((w (string-width str))
50 (col 0) (idx 0) (p-idx 0) chr)
54 (setq chr (aref str idx)
55 col (+ col (char-width chr))
57 idx (+ idx (char-bytes chr))
59 (substring str 0 (if (= col width)
63 (defun gnus-mule-cite-add-face (number prefix face)
64 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
66 (let ((inhibit-point-motion-hooks t)
70 (forward-char (chars-in-string prefix))
71 (forward-char (length prefix)))
72 (skip-chars-forward " \t")
75 (skip-chars-backward " \t")
78 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
80 (defun gnus-mule-max-width-function (el max-width)
81 (` (let* ((val (eval (, el)))
82 (valstr (if (numberp val)
83 (int-to-string val) val)))
84 (if (> (length valstr) (, max-width))
85 (truncate-string valstr (, max-width))
90 (if (string-match "XEmacs\\|Lucid" emacs-version)
93 (defvar gnus-mouse-face-prop 'mouse-face
94 "Property used for highlighting mouse regions.")
96 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
97 (defvar gnus-display-type
99 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
100 (cond (display-resource (intern (downcase display-resource)))
101 ((x-display-color-p) 'color)
102 ((x-display-grayscale-p) 'grayscale)
105 "A symbol indicating the display Emacs is running under.
106 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
107 guesses this display attribute wrongly, either set this variable in
108 your `~/.emacs' or set the resource `Emacs.displayType' in your
109 `~/.Xdefaults'. See also `gnus-background-mode'.
111 This is a meta-variable that will affect what default values other
112 variables get. You would normally not change this variable, but
113 pounce directly on the real variables themselves.")
115 (defvar gnus-background-mode
117 (let ((bg-resource (x-get-resource ".backgroundMode"
119 (params (frame-parameters)))
120 (cond (bg-resource (intern (downcase bg-resource)))
121 ((and (cdr (assq 'background-color params))
122 (< (apply '+ (x-color-values
123 (cdr (assq 'background-color params))))
124 (/ (apply '+ (x-color-values "white")) 3)))
128 "A symbol indicating the Emacs background brightness.
129 The symbol should be one of `light' or `dark'.
130 If Emacs guesses this frame attribute wrongly, either set this variable in
131 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
133 See also `gnus-display-type'.
135 This is a meta-variable that will affect what default values other
136 variables get. You would normally not change this variable, but
137 pounce directly on the real variables themselves."))
140 ((string-match "XEmacs\\|Lucid" emacs-version)
143 ((or (not (boundp 'emacs-minor-version))
144 (< emacs-minor-version 30))
145 ;; Remove the `intangible' prop.
146 (let ((props (and (boundp 'gnus-hidden-properties)
147 gnus-hidden-properties)))
148 (while (and props (not (eq (car (cdr props)) 'intangible)))
149 (setq props (cdr props)))
150 (and props (setcdr props (cdr (cdr (cdr props))))))
151 (or (fboundp 'buffer-substring-no-properties)
152 (defun buffer-substring-no-properties (beg end)
153 (format "%s" (buffer-substring beg end)))))
156 (provide 'gnusutil))))
161 (defun gnus-dummy-func (&rest args))
162 (let ((funcs '(mouse-set-point set-face-foreground
163 set-face-background x-popup-menu)))
165 (or (fboundp (car funcs))
166 (fset (car funcs) 'gnus-dummy-func))
167 (setq funcs (cdr funcs))))))
168 (or (fboundp 'file-regular-p)
169 (defun file-regular-p (file)
170 (and (not (file-directory-p file))
171 (not (file-symlink-p file))
172 (file-exists-p file))))
173 (or (fboundp 'face-list)
174 (defun face-list (&rest args))))
177 (let ((case-fold-search t))
179 ((string-match "windows-nt\\|os/2" (format "%s" system-type))
180 (setq nnheader-file-name-translation-alist
181 (append nnheader-file-name-translation-alist
185 (defvar gnus-tmp-unread)
186 (defvar gnus-tmp-replied)
187 (defvar gnus-tmp-score-char)
188 (defvar gnus-tmp-indentation)
189 (defvar gnus-tmp-opening-bracket)
190 (defvar gnus-tmp-lines)
191 (defvar gnus-tmp-name)
192 (defvar gnus-tmp-closing-bracket)
193 (defvar gnus-tmp-subject-or-nil)
195 (defun gnus-ems-redefine ()
197 ((string-match "XEmacs\\|Lucid" emacs-version)
198 (gnus-xmas-redefine))
202 (or (fboundp 'truncate-string)
203 (fset 'truncate-string 'gnus-mule-truncate-string))
204 (defalias 'gnus-truncate-string 'truncate-string)
206 (fset 'gnus-summary-make-display-table (lambda () nil))
207 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
208 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
210 (if (boundp 'gnus-check-before-posting)
211 (setq gnus-check-before-posting
213 (delq 'control-chars gnus-check-before-posting))))
215 (defun gnus-summary-line-format-spec ()
216 (insert gnus-tmp-unread gnus-tmp-replied
217 gnus-tmp-score-char gnus-tmp-indentation)
222 gnus-tmp-opening-bracket
225 (if (> (length gnus-tmp-name) 20)
226 (gnus-truncate-string gnus-tmp-name 20)
228 gnus-tmp-closing-bracket)
230 gnus-mouse-face-prop gnus-mouse-face)
231 (insert " " gnus-tmp-subject-or-nil "\n"))
238 ;; byte-compile-warnings: '(redefine callargs)
241 ;;; gnus-ems.el ends here