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-xemacs (string-match "XEmacs\\|Lucid" emacs-version)
31 "Non-nil if running under XEmacs.")
33 (defvar gnus-mouse-2 [mouse-2])
36 (autoload 'gnus-xmas-define "gnus-xmas")
37 (autoload 'gnus-xmas-redefine "gnus-xmas")
38 (autoload 'appt-select-lowest-window "appt.el"))
40 (or (fboundp 'mail-file-babyl-p)
41 (fset 'mail-file-babyl-p 'rmail-file-p))
45 (defun gnus-mule-cite-add-face (number prefix face)
46 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
48 (let ((inhibit-point-motion-hooks t)
52 (forward-char (chars-in-string prefix))
53 (forward-char (length prefix)))
54 (skip-chars-forward " \t")
57 (skip-chars-backward " \t")
60 (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
62 (defun gnus-mule-max-width-function (el max-width)
63 (` (let* ((val (eval (, el)))
64 (valstr (if (numberp val)
65 (int-to-string val) val)))
66 (if (> (length valstr) (, max-width))
67 (truncate-string valstr (, max-width))
74 (defvar gnus-mouse-face-prop 'mouse-face
75 "Property used for highlighting mouse regions.")
77 (defvar gnus-article-x-face-command
78 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
79 "String or function to be executed to display an X-Face header.
80 If it is a string, the command will be executed in a sub-shell
81 asynchronously. The compressed face will be piped to this command.")
83 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
84 (defvar gnus-display-type
86 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
87 (cond (display-resource (intern (downcase display-resource)))
88 ((x-display-color-p) 'color)
89 ((x-display-grayscale-p) 'grayscale)
92 "A symbol indicating the display Emacs is running under.
93 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
94 guesses this display attribute wrongly, either set this variable in
95 your `~/.emacs' or set the resource `Emacs.displayType' in your
96 `~/.Xdefaults'. See also `gnus-background-mode'.
98 This is a meta-variable that will affect what default values other
99 variables get. You would normally not change this variable, but
100 pounce directly on the real variables themselves.")
102 (defvar gnus-background-mode
104 (let ((bg-resource (x-get-resource ".backgroundMode"
106 (params (frame-parameters)))
107 (cond (bg-resource (intern (downcase bg-resource)))
108 ((and (cdr (assq 'background-color params))
109 (< (apply '+ (x-color-values
110 (cdr (assq 'background-color params))))
111 (* (apply '+ (x-color-values "white")) .6)))
115 "A symbol indicating the Emacs background brightness.
116 The symbol should be one of `light' or `dark'.
117 If Emacs guesses this frame attribute wrongly, either set this variable in
118 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
120 See also `gnus-display-type'.
122 This is a meta-variable that will affect what default values other
123 variables get. You would normally not change this variable, but
124 pounce directly on the real variables themselves."))
127 ((string-match "XEmacs\\|Lucid" emacs-version)
130 ((or (not (boundp 'emacs-minor-version))
131 (< emacs-minor-version 30))
132 ;; Remove the `intangible' prop.
133 (let ((props (and (boundp 'gnus-hidden-properties)
134 gnus-hidden-properties)))
135 (while (and props (not (eq (car (cdr props)) 'intangible)))
136 (setq props (cdr props)))
137 (and props (setcdr props (cdr (cdr (cdr props))))))
138 (or (fboundp 'buffer-substring-no-properties)
139 (defun buffer-substring-no-properties (beg end)
140 (format "%s" (buffer-substring beg end)))))
143 (provide 'gnusutil))))
148 (defun gnus-dummy-func (&rest args))
149 (let ((funcs '(mouse-set-point set-face-foreground
150 set-face-background x-popup-menu)))
152 (or (fboundp (car funcs))
153 (fset (car funcs) 'gnus-dummy-func))
154 (setq funcs (cdr funcs))))))
155 (or (fboundp 'file-regular-p)
156 (defun file-regular-p (file)
157 (and (not (file-directory-p file))
158 (not (file-symlink-p file))
159 (file-exists-p file))))
160 (or (fboundp 'face-list)
161 (defun face-list (&rest args))))
164 (let ((case-fold-search t))
166 ((string-match "windows-nt\\|os/2\\|emx" (format "%s" system-type))
167 (setq nnheader-file-name-translation-alist
168 (append nnheader-file-name-translation-alist
172 (defvar gnus-tmp-unread)
173 (defvar gnus-tmp-replied)
174 (defvar gnus-tmp-score-char)
175 (defvar gnus-tmp-indentation)
176 (defvar gnus-tmp-opening-bracket)
177 (defvar gnus-tmp-lines)
178 (defvar gnus-tmp-name)
179 (defvar gnus-tmp-closing-bracket)
180 (defvar gnus-tmp-subject-or-nil)
182 (defun gnus-ems-redefine ()
184 ((string-match "XEmacs\\|Lucid" emacs-version)
185 (gnus-xmas-redefine))
189 (defalias 'gnus-truncate-string 'truncate-string)
191 (defvar gnus-summary-display-table nil
192 "Display table used in summary mode buffers.")
193 (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
194 (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
196 (if (boundp 'gnus-check-before-posting)
197 (setq gnus-check-before-posting
199 (delq 'control-chars gnus-check-before-posting))))
201 (defun gnus-summary-line-format-spec ()
202 (insert gnus-tmp-unread gnus-tmp-replied
203 gnus-tmp-score-char gnus-tmp-indentation)
208 gnus-tmp-opening-bracket
211 (if (> (length gnus-tmp-name) 20)
212 (truncate-string gnus-tmp-name 20)
214 gnus-tmp-closing-bracket)
216 gnus-mouse-face-prop gnus-mouse-face)
217 (insert " " gnus-tmp-subject-or-nil "\n"))
224 ;; byte-compile-warnings: '(redefine callargs)
227 ;;; gnus-ems.el ends here