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 (eval-when-compile (require 'cl))
30 (defvar gnus-mouse-2 [mouse-2])
33 (autoload 'gnus-xmas-define "gnus-xmas")
34 (autoload 'gnus-xmas-redefine "gnus-xmas")
35 (autoload 'appt-select-lowest-window "appt.el"))
37 (or (fboundp 'mail-file-babyl-p)
38 (fset 'mail-file-babyl-p 'rmail-file-p))
42 (defun gnus-mule-cite-add-face (number prefix face)
43 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
45 (let ((inhibit-point-motion-hooks t)
49 (forward-char (chars-in-string prefix))
50 (forward-char (length prefix)))
51 (skip-chars-forward " \t")
54 (skip-chars-backward " \t")
57 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
59 (defun gnus-mule-max-width-function (el max-width)
60 (` (let* ((val (eval (, el)))
61 (valstr (if (numberp val)
62 (int-to-string val) val)))
63 (if (> (length valstr) (, max-width))
64 (truncate-string valstr (, max-width))
68 (if (string-match "XEmacs\\|Lucid" emacs-version)
71 (defvar gnus-mouse-face-prop 'mouse-face
72 "Property used for highlighting mouse regions.")
74 (defvar gnus-article-x-face-command
75 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
76 "String or function to be executed to display an X-Face header.
77 If it is a string, the command will be executed in a sub-shell
78 asynchronously. The compressed face will be piped to this command.")
80 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
81 (defvar gnus-display-type
83 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
84 (cond (display-resource (intern (downcase display-resource)))
85 ((x-display-color-p) 'color)
86 ((x-display-grayscale-p) 'grayscale)
89 "A symbol indicating the display Emacs is running under.
90 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
91 guesses this display attribute wrongly, either set this variable in
92 your `~/.emacs' or set the resource `Emacs.displayType' in your
93 `~/.Xdefaults'. See also `gnus-background-mode'.
95 This is a meta-variable that will affect what default values other
96 variables get. You would normally not change this variable, but
97 pounce directly on the real variables themselves.")
99 (defvar gnus-background-mode
101 (let ((bg-resource (x-get-resource ".backgroundMode"
103 (params (frame-parameters)))
104 (cond (bg-resource (intern (downcase bg-resource)))
105 ((and (cdr (assq 'background-color params))
106 (< (apply '+ (x-color-values
107 (cdr (assq 'background-color params))))
108 (* (apply '+ (x-color-values "white")) .6)))
112 "A symbol indicating the Emacs background brightness.
113 The symbol should be one of `light' or `dark'.
114 If Emacs guesses this frame attribute wrongly, either set this variable in
115 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
117 See also `gnus-display-type'.
119 This is a meta-variable that will affect what default values other
120 variables get. You would normally not change this variable, but
121 pounce directly on the real variables themselves."))
124 ((string-match "XEmacs\\|Lucid" emacs-version)
127 ((or (not (boundp 'emacs-minor-version))
128 (< emacs-minor-version 30))
129 ;; Remove the `intangible' prop.
130 (let ((props (and (boundp 'gnus-hidden-properties)
131 gnus-hidden-properties)))
132 (while (and props (not (eq (car (cdr props)) 'intangible)))
133 (setq props (cdr props)))
134 (and props (setcdr props (cdr (cdr (cdr props))))))
135 (or (fboundp 'buffer-substring-no-properties)
136 (defun buffer-substring-no-properties (beg end)
137 (format "%s" (buffer-substring beg end)))))
140 (provide 'gnusutil))))
145 (defun gnus-dummy-func (&rest args))
146 (let ((funcs '(mouse-set-point set-face-foreground
147 set-face-background x-popup-menu)))
149 (or (fboundp (car funcs))
150 (fset (car funcs) 'gnus-dummy-func))
151 (setq funcs (cdr funcs))))))
152 (or (fboundp 'file-regular-p)
153 (defun file-regular-p (file)
154 (and (not (file-directory-p file))
155 (not (file-symlink-p file))
156 (file-exists-p file))))
157 (or (fboundp 'face-list)
158 (defun face-list (&rest args))))
161 (let ((case-fold-search t))
163 ((string-match "windows-nt\\|os/2\\|emx" (format "%s" system-type))
164 (setq nnheader-file-name-translation-alist
165 (append nnheader-file-name-translation-alist
169 (defvar gnus-tmp-unread)
170 (defvar gnus-tmp-replied)
171 (defvar gnus-tmp-score-char)
172 (defvar gnus-tmp-indentation)
173 (defvar gnus-tmp-opening-bracket)
174 (defvar gnus-tmp-lines)
175 (defvar gnus-tmp-name)
176 (defvar gnus-tmp-closing-bracket)
177 (defvar gnus-tmp-subject-or-nil)
179 (defun gnus-ems-redefine ()
181 ((string-match "XEmacs\\|Lucid" emacs-version)
182 (gnus-xmas-redefine))
186 (defalias 'gnus-truncate-string 'truncate-string)
188 (fset 'gnus-summary-make-display-table (lambda () nil))
189 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
190 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
192 (if (boundp 'gnus-check-before-posting)
193 (setq gnus-check-before-posting
195 (delq 'control-chars gnus-check-before-posting))))
197 (defun gnus-summary-line-format-spec ()
198 (insert gnus-tmp-unread gnus-tmp-replied
199 gnus-tmp-score-char gnus-tmp-indentation)
204 gnus-tmp-opening-bracket
207 (if (> (length gnus-tmp-name) 20)
208 (truncate-string gnus-tmp-name 20)
210 gnus-tmp-closing-bracket)
212 gnus-mouse-face-prop gnus-mouse-face)
213 (insert " " gnus-tmp-subject-or-nil "\n"))
220 ;; byte-compile-warnings: '(redefine callargs)
223 ;;; gnus-ems.el ends here