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)
35 (autoload 'gnus-xmas-define "gnus-xmas")
36 (autoload 'gnus-xmas-redefine "gnus-xmas"))
38 (or (fboundp 'mail-file-babyl-p)
39 (fset 'mail-file-babyl-p 'rmail-file-p))
43 (defun gnus-mule-truncate-string (str width)
44 (let ((w (string-width str))
45 (col 0) (idx 0) (p-idx 0) chr)
49 (setq chr (aref str idx)
50 col (+ col (char-width chr))
52 idx (+ idx (char-bytes chr))
54 (substring str 0 (if (= col width)
58 (defun gnus-mule-cite-add-face (number prefix face)
59 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
61 (let ((inhibit-point-motion-hooks t)
65 (forward-char (chars-in-string prefix))
66 (forward-char (length prefix)))
67 (skip-chars-forward " \t")
70 (skip-chars-backward " \t")
73 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
75 (defun gnus-mule-max-width-function (el max-width)
76 (` (let* ((val (eval (, el)))
77 (valstr (if (numberp val)
78 (int-to-string val) val)))
79 (if (> (length valstr) (, max-width))
80 (truncate-string valstr (, max-width))
85 (if (string-match "XEmacs\\|Lucid" emacs-version)
88 (defvar gnus-mouse-face-prop 'mouse-face
89 "Property used for highlighting mouse regions.")
91 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
92 (defvar gnus-display-type
94 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
95 (cond (display-resource (intern (downcase display-resource)))
96 ((x-display-color-p) 'color)
97 ((x-display-grayscale-p) 'grayscale)
100 "A symbol indicating the display Emacs is running under.
101 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
102 guesses this display attribute wrongly, either set this variable in
103 your `~/.emacs' or set the resource `Emacs.displayType' in your
104 `~/.Xdefaults'. See also `gnus-background-mode'.
106 This is a meta-variable that will affect what default values other
107 variables get. You would normally not change this variable, but
108 pounce directly on the real variables themselves.")
110 (defvar gnus-background-mode
112 (let ((bg-resource (x-get-resource ".backgroundMode"
114 (params (frame-parameters)))
115 (cond (bg-resource (intern (downcase bg-resource)))
116 ((and (cdr (assq 'background-color params))
117 (< (apply '+ (x-color-values
118 (cdr (assq 'background-color params))))
119 (/ (apply '+ (x-color-values "white")) 3)))
123 "A symbol indicating the Emacs background brightness.
124 The symbol should be one of `light' or `dark'.
125 If Emacs guesses this frame attribute wrongly, either set this variable in
126 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
128 See also `gnus-display-type'.
130 This is a meta-variable that will affect what default values other
131 variables get. You would normally not change this variable, but
132 pounce directly on the real variables themselves."))
135 ((string-match "XEmacs\\|Lucid" emacs-version)
138 ((or (not (boundp 'emacs-minor-version))
139 (< emacs-minor-version 30))
140 ;; Remove the `intangible' prop.
141 (let ((props (and (boundp 'gnus-hidden-properties)
142 gnus-hidden-properties)))
143 (while (and props (not (eq (car (cdr props)) 'intangible)))
144 (setq props (cdr props)))
145 (and props (setcdr props (cdr (cdr (cdr props))))))
146 (or (fboundp 'buffer-substring-no-properties)
147 (defun buffer-substring-no-properties (beg end)
148 (format "%s" (buffer-substring beg end)))))
151 (provide 'gnusutil))))
156 (defun gnus-dummy-func (&rest args))
157 (let ((funcs '(mouse-set-point set-face-foreground
158 set-face-background x-popup-menu)))
160 (or (fboundp (car funcs))
161 (fset (car funcs) 'gnus-dummy-func))
162 (setq funcs (cdr funcs))))))
163 (or (fboundp 'file-regular-p)
164 (defun file-regular-p (file)
165 (and (not (file-directory-p file))
166 (not (file-symlink-p file))
167 (file-exists-p file))))
168 (or (fboundp 'face-list)
169 (defun face-list (&rest args))))
172 (let ((case-fold-search t))
174 ((string-match "windows-nt\\|os/2" (format "%s" system-type))
175 (setq nnheader-file-name-translation-alist
176 (append nnheader-file-name-translation-alist
180 (defvar gnus-tmp-unread)
181 (defvar gnus-tmp-replied)
182 (defvar gnus-tmp-score-char)
183 (defvar gnus-tmp-indentation)
184 (defvar gnus-tmp-opening-bracket)
185 (defvar gnus-tmp-lines)
186 (defvar gnus-tmp-name)
187 (defvar gnus-tmp-closing-bracket)
188 (defvar gnus-tmp-subject-or-nil)
190 (defun gnus-ems-redefine ()
192 ((string-match "XEmacs\\|Lucid" emacs-version)
193 (gnus-xmas-redefine))
197 (or (fboundp 'truncate-string)
198 (fset 'truncate-string 'gnus-mule-truncate-string))
199 (defalias 'gnus-truncate-string 'truncate-string)
201 (fset 'gnus-summary-make-display-table (lambda () nil))
202 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
203 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
205 (if (boundp 'gnus-check-before-posting)
206 (setq gnus-check-before-posting
208 (delq 'control-chars gnus-check-before-posting))))
210 (defun gnus-summary-line-format-spec ()
211 (insert gnus-tmp-unread gnus-tmp-replied
212 gnus-tmp-score-char gnus-tmp-indentation)
217 gnus-tmp-opening-bracket
220 (if (> (length gnus-tmp-name) 20)
221 (gnus-truncate-string gnus-tmp-name 20)
223 gnus-tmp-closing-bracket)
225 gnus-mouse-face-prop gnus-mouse-face)
226 (insert " " gnus-tmp-subject-or-nil "\n"))
233 ;; byte-compile-warnings: '(redefine callargs)
236 ;;; gnus-ems.el ends here