*** empty log message ***
[gnus] / lisp / gnus-ems.el
1 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
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)
12 ;; any later version.
13
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.
18
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.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (eval-when-compile (require 'cl))
29
30 ;;; Function aliases later to be redefined for XEmacs usage.
31
32 (defvar gnus-xemacs (string-match "XEmacs\\|Lucid" emacs-version)
33   "Non-nil if running under XEmacs.")
34
35 (defvar gnus-mouse-2 [mouse-2])
36 (defvar gnus-down-mouse-2 [down-mouse-2])
37
38 (eval-and-compile 
39   (autoload 'gnus-xmas-define "gnus-xmas")
40   (autoload 'gnus-xmas-redefine "gnus-xmas")
41   (autoload 'appt-select-lowest-window "appt.el"))
42
43 (or (fboundp 'mail-file-babyl-p)
44     (fset 'mail-file-babyl-p 'rmail-file-p))
45
46 ;;; Mule functions.
47
48 (defun gnus-mule-cite-add-face (number prefix face)
49   ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
50   (when face
51     (let ((inhibit-point-motion-hooks t)
52           from to)
53       (goto-line number)
54       (if (boundp 'MULE)
55           (forward-char (chars-in-string prefix))
56         (forward-char (length prefix)))
57       (skip-chars-forward " \t")
58       (setq from (point))
59       (end-of-line 1)
60       (skip-chars-backward " \t")
61       (setq to (point))
62       (when (< from to)
63         (gnus-overlay-put (gnus-make-overlay from to) 'face face)))))
64
65 (defun gnus-mule-max-width-function (el max-width)
66   (` (let* ((val (eval (, el)))
67             (valstr (if (numberp val)
68                         (int-to-string val) val)))
69        (if (> (length valstr) (, max-width))
70            (truncate-string valstr (, max-width))
71          valstr))))
72
73 (eval-and-compile
74   (if gnus-xemacs
75       nil
76
77     (defvar gnus-mouse-face-prop 'mouse-face
78       "Property used for highlighting mouse regions.")
79
80     (defvar gnus-article-x-face-command
81       "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
82       "String or function to be executed to display an X-Face header.
83 If it is a string, the command will be executed in a sub-shell
84 asynchronously.  The compressed face will be piped to this command."))
85
86   (cond 
87    ((string-match "XEmacs\\|Lucid" emacs-version)
88     (gnus-xmas-define))
89
90    ((or (not (boundp 'emacs-minor-version))
91         (< emacs-minor-version 30))
92     ;; Remove the `intangible' prop.
93     (let ((props (and (boundp 'gnus-hidden-properties)
94                       gnus-hidden-properties)))
95       (while (and props (not (eq (car (cdr props)) 'intangible)))
96         (setq props (cdr props)))
97       (when props
98         (setcdr props (cdr (cdr (cdr props))))))
99     (unless (fboundp 'buffer-substring-no-properties)
100       (defun buffer-substring-no-properties (beg end)
101         (format "%s" (buffer-substring beg end)))))
102    
103    ((boundp 'MULE)
104     (provide 'gnusutil))))
105
106 (eval-and-compile
107   (cond
108    ((not window-system)
109     (defun gnus-dummy-func (&rest args))
110     (let ((funcs '(mouse-set-point set-face-foreground
111                                    set-face-background x-popup-menu)))
112       (while funcs
113         (unless (fboundp (car funcs))
114           (fset (car funcs) 'gnus-dummy-func))
115         (setq funcs (cdr funcs))))))
116   (unless (fboundp 'file-regular-p)
117     (defun file-regular-p (file)
118       (and (not (file-directory-p file))
119            (not (file-symlink-p file))
120            (file-exists-p file))))
121   (unless (fboundp 'face-list)
122     (defun face-list (&rest args))))
123
124 (eval-and-compile
125   (let ((case-fold-search t))
126     (cond
127      ((string-match "windows-nt\\|os/2\\|emx" (format "%s" system-type))
128       (setq nnheader-file-name-translation-alist
129             (append nnheader-file-name-translation-alist
130                     '((?: . ?_)
131                       (?+ . ?-))))))))
132
133 (defvar gnus-tmp-unread)
134 (defvar gnus-tmp-replied)
135 (defvar gnus-tmp-score-char)
136 (defvar gnus-tmp-indentation)
137 (defvar gnus-tmp-opening-bracket)
138 (defvar gnus-tmp-lines)
139 (defvar gnus-tmp-name)
140 (defvar gnus-tmp-closing-bracket)
141 (defvar gnus-tmp-subject-or-nil)
142
143 (defun gnus-ems-redefine ()
144   (cond 
145    ((string-match "XEmacs\\|Lucid" emacs-version)
146     (gnus-xmas-redefine))
147
148    ((boundp 'MULE)
149     ;; Mule definitions
150     (defalias 'gnus-truncate-string 'truncate-string)
151
152     (defvar gnus-summary-display-table nil
153       "Display table used in summary mode buffers.")
154     (fset 'gnus-cite-add-face 'gnus-mule-cite-add-face)
155     (fset 'gnus-max-width-function 'gnus-mule-max-width-function)
156     
157     (when (boundp 'gnus-check-before-posting)
158       (setq gnus-check-before-posting
159             (delq 'long-lines
160                   (delq 'control-chars gnus-check-before-posting))))
161
162     (defun gnus-summary-line-format-spec ()
163       (insert gnus-tmp-unread gnus-tmp-replied 
164               gnus-tmp-score-char gnus-tmp-indentation)
165       (put-text-property
166        (point)
167        (progn
168          (insert 
169           gnus-tmp-opening-bracket 
170           (format "%4d: %-20s" 
171                   gnus-tmp-lines 
172                   (if (> (length gnus-tmp-name) 20)
173                       (truncate-string gnus-tmp-name 20)
174                     gnus-tmp-name))
175           gnus-tmp-closing-bracket)
176          (point))
177        gnus-mouse-face-prop gnus-mouse-face)
178       (insert " " gnus-tmp-subject-or-nil "\n"))
179     )))
180
181
182 (provide 'gnus-ems)
183
184 ;; Local Variables:
185 ;; byte-compile-warnings: '(redefine callargs)
186 ;; End:
187
188 ;;; gnus-ems.el ends here