1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995 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)
34 (autoload 'gnus-xmas-define "gnus-xmas")
35 (autoload 'gnus-xmas-redefine "gnus-xmas"))
37 (or (fboundp 'mail-file-babyl-p)
38 (fset 'mail-file-babyl-p 'rmail-file-p))
42 (defun gnus-mule-truncate-string (str width)
43 (let ((w (string-width str))
44 (col 0) (idx 0) (p-idx 0) chr)
48 (setq chr (aref str idx)
49 col (+ col (char-width chr))
51 idx (+ idx (char-bytes chr))
53 (substring str 0 (if (= col width)
57 (defun gnus-mule-cite-add-face (number prefix face)
58 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
60 (let ((inhibit-point-motion-hooks t)
64 (forward-char (chars-in-string prefix))
65 (forward-char (length prefix)))
66 (skip-chars-forward " \t")
69 (skip-chars-backward " \t")
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))
85 (if (string-match "XEmacs\\|Lucid" emacs-version)
87 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
88 (defvar gnus-display-type
90 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
91 (cond (display-resource (intern (downcase display-resource)))
92 ((x-display-color-p) 'color)
93 ((x-display-grayscale-p) 'grayscale)
96 "A symbol indicating the display Emacs is running under.
97 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
98 guesses this display attribute wrongly, either set this variable in
99 your `~/.emacs' or set the resource `Emacs.displayType' in your
100 `~/.Xdefaults'. See also `gnus-background-mode'.
102 This is a meta-variable that will affect what default values other
103 variables get. You would normally not change this variable, but
104 pounce directly on the real variables themselves.")
106 (defvar gnus-background-mode
108 (let ((bg-resource (x-get-resource ".backgroundMode"
110 (params (frame-parameters)))
111 (cond (bg-resource (intern (downcase bg-resource)))
112 ((and (cdr (assq 'background-color params))
113 (< (apply '+ (x-color-values
114 (cdr (assq 'background-color params))))
115 (/ (apply '+ (x-color-values "white")) 3)))
119 "A symbol indicating the Emacs background brightness.
120 The symbol should be one of `light' or `dark'.
121 If Emacs guesses this frame attribute wrongly, either set this variable in
122 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
124 See also `gnus-display-type'.
126 This is a meta-variable that will affect what default values other
127 variables get. You would normally not change this variable, but
128 pounce directly on the real variables themselves."))
131 ((string-match "XEmacs\\|Lucid" emacs-version)
134 ((and (not (string-match "28.9" emacs-version))
135 (not (string-match "29" emacs-version)))
136 ;; Remove the `intangible' prop.
137 (let ((props (and (boundp 'gnus-hidden-properties)
138 gnus-hidden-properties)))
139 (while (and props (not (eq (car (cdr props)) 'intangible)))
140 (setq props (cdr props)))
141 (and props (setcdr props (cdr (cdr (cdr props))))))
142 (or (fboundp 'buffer-substring-no-properties)
143 (defun buffer-substring-no-properties (beg end)
144 (format "%s" (buffer-substring beg end)))))
153 (defun gnus-dummy-func (&rest args))
154 (let ((funcs '(mouse-set-point set-face-foreground
155 set-face-background x-popup-menu)))
157 (or (fboundp (car funcs))
158 (fset (car funcs) 'gnus-dummy-func))
159 (setq funcs (cdr funcs))))))
160 (or (fboundp 'file-regular-p)
161 (defun file-regular-p (file)
162 (and (not (file-directory-p file))
163 (not (file-symlink-p file))
164 (file-exists-p file))))
165 (or (fboundp 'face-list)
166 (defun face-list (&rest args)))
169 (defun gnus-ems-redefine ()
171 ((string-match "XEmacs\\|Lucid" emacs-version)
172 (gnus-xmas-redefine))
176 (or (fboundp 'truncate-string)
177 (fset 'truncate-string 'gnus-mule-truncate-string))
178 (defalias 'gnus-truncate-string 'truncate-string)
180 (fset 'gnus-summary-make-display-table (lambda () nil))
181 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
182 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
184 (if (boundp 'gnus-check-before-posting)
185 (setq gnus-check-before-posting
187 (delq 'control-chars gnus-check-before-posting))))
194 ;; byte-compile-warnings: '(redefine callargs)
197 ;;; gnus-ems.el ends here