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 the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (defvar gnus-mouse-2 [mouse-2])
30 (defalias 'gnus-make-overlay 'make-overlay)
31 (defalias 'gnus-overlay-put 'overlay-put)
32 (defalias 'gnus-move-overlay 'move-overlay)
33 (defalias 'gnus-overlay-end 'overlay-end)
34 (defalias 'gnus-extent-detached-p 'ignore)
35 (defalias 'gnus-group-remove-excess-properties 'ignore)
36 (defalias 'gnus-topic-remove-excess-properties 'ignore)
37 (defalias 'gnus-extent-start-open 'ignore)
41 (autoload 'gnus-xmas-define "gnus-xmas")
42 (autoload 'gnus-xmas-redefine "gnus-xmas"))
44 (or (fboundp 'mail-file-babyl-p)
45 (fset 'mail-file-babyl-p 'rmail-file-p))
49 (defun gnus-mule-truncate-string (str width)
50 (let ((w (string-width str))
51 (col 0) (idx 0) (p-idx 0) chr)
55 (setq chr (aref str idx)
56 col (+ col (char-width chr))
58 idx (+ idx (char-bytes chr))
60 (substring str 0 (if (= col width)
64 (defun gnus-mule-cite-add-face (number prefix face)
65 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
67 (let ((inhibit-point-motion-hooks t)
71 (forward-char (chars-in-string prefix))
72 (forward-char (length prefix)))
73 (skip-chars-forward " \t")
76 (skip-chars-backward " \t")
79 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
81 (defun gnus-mule-max-width-function (el max-width)
82 (` (let* ((val (eval (, el)))
83 (valstr (if (numberp val)
84 (int-to-string val) val)))
85 (if (> (length valstr) (, max-width))
86 (truncate-string valstr (, max-width))
91 (if (string-match "XEmacs\\|Lucid" emacs-version)
94 (defvar gnus-mouse-face-prop 'mouse-face
95 "Property used for highlighting mouse regions.")
97 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
98 (defvar gnus-display-type
100 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
101 (cond (display-resource (intern (downcase display-resource)))
102 ((x-display-color-p) 'color)
103 ((x-display-grayscale-p) 'grayscale)
106 "A symbol indicating the display Emacs is running under.
107 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
108 guesses this display attribute wrongly, either set this variable in
109 your `~/.emacs' or set the resource `Emacs.displayType' in your
110 `~/.Xdefaults'. See also `gnus-background-mode'.
112 This is a meta-variable that will affect what default values other
113 variables get. You would normally not change this variable, but
114 pounce directly on the real variables themselves.")
116 (defvar gnus-background-mode
118 (let ((bg-resource (x-get-resource ".backgroundMode"
120 (params (frame-parameters)))
121 (cond (bg-resource (intern (downcase bg-resource)))
122 ((and (cdr (assq 'background-color params))
123 (< (apply '+ (x-color-values
124 (cdr (assq 'background-color params))))
125 (/ (apply '+ (x-color-values "white")) 3)))
129 "A symbol indicating the Emacs background brightness.
130 The symbol should be one of `light' or `dark'.
131 If Emacs guesses this frame attribute wrongly, either set this variable in
132 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
134 See also `gnus-display-type'.
136 This is a meta-variable that will affect what default values other
137 variables get. You would normally not change this variable, but
138 pounce directly on the real variables themselves."))
141 ((string-match "XEmacs\\|Lucid" emacs-version)
144 ((or (not (boundp 'emacs-minor-version))
145 (< emacs-minor-version 30))
146 ;; Remove the `intangible' prop.
147 (let ((props (and (boundp 'gnus-hidden-properties)
148 gnus-hidden-properties)))
149 (while (and props (not (eq (car (cdr props)) 'intangible)))
150 (setq props (cdr props)))
151 (and props (setcdr props (cdr (cdr (cdr props))))))
152 (or (fboundp 'buffer-substring-no-properties)
153 (defun buffer-substring-no-properties (beg end)
154 (format "%s" (buffer-substring beg end)))))
157 (provide 'gnusutil))))
162 (defun gnus-dummy-func (&rest args))
163 (let ((funcs '(mouse-set-point set-face-foreground
164 set-face-background x-popup-menu)))
166 (or (fboundp (car funcs))
167 (fset (car funcs) 'gnus-dummy-func))
168 (setq funcs (cdr funcs))))))
169 (or (fboundp 'file-regular-p)
170 (defun file-regular-p (file)
171 (and (not (file-directory-p file))
172 (not (file-symlink-p file))
173 (file-exists-p file))))
174 (or (fboundp 'face-list)
175 (defun face-list (&rest args))))
178 (let ((case-fold-search t))
180 ((string-match "windows-nt\\|os/2" (format "%s" system-type))
181 (setq nnheader-file-name-translation-alist
182 (append nnheader-file-name-translation-alist
186 (defvar gnus-tmp-unread)
187 (defvar gnus-tmp-replied)
188 (defvar gnus-tmp-score-char)
189 (defvar gnus-tmp-indentation)
190 (defvar gnus-tmp-opening-bracket)
191 (defvar gnus-tmp-lines)
192 (defvar gnus-tmp-name)
193 (defvar gnus-tmp-closing-bracket)
194 (defvar gnus-tmp-subject-or-nil)
196 (defun gnus-ems-redefine ()
198 ((string-match "XEmacs\\|Lucid" emacs-version)
199 (gnus-xmas-redefine))
203 (or (fboundp 'truncate-string)
204 (fset 'truncate-string 'gnus-mule-truncate-string))
205 (defalias 'gnus-truncate-string 'truncate-string)
207 (fset 'gnus-summary-make-display-table (lambda () nil))
208 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
209 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
211 (if (boundp 'gnus-check-before-posting)
212 (setq gnus-check-before-posting
214 (delq 'control-chars gnus-check-before-posting))))
216 (defun gnus-summary-line-format-spec ()
217 (insert gnus-tmp-unread gnus-tmp-replied
218 gnus-tmp-score-char gnus-tmp-indentation)
223 gnus-tmp-opening-bracket
226 (if (> (length gnus-tmp-name) 20)
227 (gnus-truncate-string gnus-tmp-name 20)
229 gnus-tmp-closing-bracket)
231 gnus-mouse-face-prop gnus-mouse-face)
232 (insert " " gnus-tmp-subject-or-nil "\n"))
239 ;; byte-compile-warnings: '(redefine callargs)
242 ;;; gnus-ems.el ends here