Commit | Line | Data |
---|---|---|
a66894d8 BW |
1 | ;;; mh-gnus.el --- Make MH-E compatible with installed version of Gnus. |
2 | ||
e495eaec | 3 | ;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. |
a66894d8 BW |
4 | |
5 | ;; Author: Satyaki Das <satyaki@theforce.stanford.edu> | |
6 | ;; Maintainer: Bill Wohler <wohler@newt.com> | |
7 | ;; Keywords: mail | |
8 | ;; See: mh-e.el | |
9 | ||
10 | ;; This file is part of GNU Emacs. | |
11 | ||
12 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 | ;; it under the terms of the GNU General Public License as published by | |
14 | ;; the Free Software Foundation; either version 2, or (at your option) | |
15 | ;; any later version. | |
16 | ||
17 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ;; GNU General Public License for more details. | |
21 | ||
22 | ;; You should have received a copy of the GNU General Public License | |
23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
3a35cf56 LK |
24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 | ;; Boston, MA 02110-1301, USA. | |
a66894d8 BW |
26 | |
27 | ;;; Commentary: | |
28 | ||
29 | ;;; Change Log: | |
30 | ||
31 | ;;; Code: | |
32 | ||
33 | (load "mm-decode" t t) ; Non-fatal dependency | |
34 | (load "mm-uu" t t) ; Non-fatal dependency | |
35 | (load "mailcap" t t) ; Non-fatal dependency | |
36 | (load "smiley" t t) ; Non-fatal dependency | |
f0d73c14 | 37 | (load "mailabbrev" t t) |
a66894d8 BW |
38 | |
39 | (defmacro mh-defun-compat (function arg-list &rest body) | |
40 | "This is a macro to define functions which are not defined. | |
41 | It is used for Gnus utility functions which were added recently. If FUNCTION | |
42 | is not defined then it is defined to have argument list, ARG-LIST and body, | |
43 | BODY." | |
44 | (let ((defined-p (fboundp function))) | |
45 | (unless defined-p | |
46 | `(defun ,function ,arg-list ,@body)))) | |
47 | (put 'mh-defun-compat 'lisp-indent-function 'defun) | |
48 | ||
49 | (defmacro mh-defmacro-compat (function arg-list &rest body) | |
50 | "This is a macro to define functions which are not defined. | |
51 | It is used for Gnus utility functions which were added recently. If FUNCTION | |
52 | is not defined then it is defined to have argument list, ARG-LIST and body, | |
53 | BODY." | |
54 | (let ((defined-p (fboundp function))) | |
55 | (unless defined-p | |
56 | `(defmacro ,function ,arg-list ,@body)))) | |
57 | (put 'mh-defmacro-compat 'lisp-indent-function 'defun) | |
58 | ||
59 | ;; Copy of original function from gnus-util.el | |
60 | (mh-defun-compat gnus-local-map-property (map) | |
61 | "Return a list suitable for a text property list specifying keymap MAP." | |
62 | (cond (mh-xemacs-flag (list 'keymap map)) | |
63 | ((>= emacs-major-version 21) (list 'keymap map)) | |
64 | (t (list 'local-map map)))) | |
65 | ||
66 | ;; Copy of original function from mm-decode.el | |
67 | (mh-defun-compat mm-merge-handles (handles1 handles2) | |
68 | (append (if (listp (car handles1)) handles1 (list handles1)) | |
69 | (if (listp (car handles2)) handles2 (list handles2)))) | |
70 | ||
71 | ;; Copy of function from mm-decode.el | |
72 | (mh-defun-compat mm-set-handle-multipart-parameter (handle parameter value) | |
73 | ;; HANDLE could be a CTL. | |
74 | (if handle | |
75 | (put-text-property 0 (length (car handle)) parameter value | |
76 | (car handle)))) | |
77 | ||
f0d73c14 BW |
78 | ;; Copy of function from mm-view.el |
79 | (mh-defun-compat mm-inline-text-vcard (handle) | |
80 | (let (buffer-read-only) | |
81 | (mm-insert-inline | |
82 | handle | |
83 | (concat "\n-- \n" | |
84 | (ignore-errors | |
85 | (if (fboundp 'vcard-pretty-print) | |
86 | (vcard-pretty-print (mm-get-part handle)) | |
87 | (vcard-format-string | |
88 | (vcard-parse-string (mm-get-part handle) | |
89 | 'vcard-standard-filter)))))))) | |
90 | ||
91 | ;; Function from mm-decode.el used in PGP messages. Just define it with older | |
92 | ;; gnus to avoid compiler warning. | |
93 | (mh-defun-compat mm-possibly-verify-or-decrypt (parts ctl) | |
94 | nil) | |
95 | ||
a66894d8 BW |
96 | ;; Copy of original macro is in mm-decode.el |
97 | (mh-defmacro-compat mm-handle-multipart-ctl-parameter (handle parameter) | |
98 | `(get-text-property 0 ,parameter (car ,handle))) | |
99 | ||
a66894d8 BW |
100 | ;; Copy of original function in mm-decode.el |
101 | (mh-defun-compat mm-readable-p (handle) | |
102 | "Say whether the content of HANDLE is readable." | |
103 | (and (< (with-current-buffer (mm-handle-buffer handle) | |
104 | (buffer-size)) 10000) | |
105 | (mm-with-unibyte-buffer | |
106 | (mm-insert-part handle) | |
107 | (and (eq (mm-body-7-or-8) '7bit) | |
108 | (not (mm-long-lines-p 76)))))) | |
109 | ||
110 | ;; Copy of original function in mm-bodies.el | |
111 | (mh-defun-compat mm-long-lines-p (length) | |
112 | "Say whether any of the lines in the buffer is longer than LENGTH." | |
113 | (save-excursion | |
114 | (goto-char (point-min)) | |
115 | (end-of-line) | |
116 | (while (and (not (eobp)) | |
117 | (not (> (current-column) length))) | |
118 | (forward-line 1) | |
119 | (end-of-line)) | |
120 | (and (> (current-column) length) | |
121 | (current-column)))) | |
122 | ||
123 | (mh-defun-compat mm-keep-viewer-alive-p (handle) | |
124 | ;; Released Gnus doesn't keep handles associated with externally displayed | |
125 | ;; MIME parts. So this will always return nil. | |
126 | nil) | |
127 | ||
128 | (mh-defun-compat mm-destroy-parts (list) | |
129 | "Older emacs don't have this function." | |
130 | nil) | |
131 | ||
132 | ;;; This is mm-save-part from gnus 5.10 since that function in emacs21.2 is | |
133 | ;;; buggy (the args to read-file-name are incorrect). When all supported | |
134 | ;;; versions of Emacs come with at least Gnus 5.10, we can delete this | |
135 | ;;; function and rename calls to mh-mm-save-part to mm-save-part. | |
136 | (defun mh-mm-save-part (handle) | |
137 | "Write HANDLE to a file." | |
138 | (let ((name (mail-content-type-get (mm-handle-type handle) 'name)) | |
139 | (filename (mail-content-type-get | |
140 | (mm-handle-disposition handle) 'filename)) | |
141 | file) | |
142 | (when filename | |
143 | (setq filename (file-name-nondirectory filename))) | |
144 | (setq file (read-file-name "Save MIME part to: " | |
145 | (or mm-default-directory | |
146 | default-directory) | |
147 | nil nil (or filename name ""))) | |
148 | (setq mm-default-directory (file-name-directory file)) | |
149 | (and (or (not (file-exists-p file)) | |
150 | (yes-or-no-p (format "File %s already exists; overwrite? " | |
151 | file))) | |
152 | (mm-save-part-to-file handle file)))) | |
153 | ||
f0d73c14 BW |
154 | (defun mh-mm-text-html-renderer () |
155 | "Find the renderer gnus is using to display text/html MIME parts." | |
156 | (or (and (boundp 'mm-inline-text-html-renderer) mm-inline-text-html-renderer) | |
157 | (and (boundp 'mm-text-html-renderer) mm-text-html-renderer))) | |
158 | ||
159 | (defun mh-mail-abbrev-make-syntax-table () | |
160 | "Call `mail-abbrev-make-syntax-table' if available." | |
161 | (when (fboundp 'mail-abbrev-make-syntax-table) | |
162 | (mail-abbrev-make-syntax-table))) | |
163 | ||
a66894d8 | 164 | (provide 'mh-gnus) |
f0d73c14 | 165 | |
a66894d8 BW |
166 | ;;; Local Variables: |
167 | ;;; no-byte-compile: t | |
168 | ;;; no-update-autoloads: t | |
f0d73c14 BW |
169 | ;;; indent-tabs-mode: nil |
170 | ;;; sentence-end-double-space: nil | |
a66894d8 | 171 | ;;; End: |
23b8b180 MB |
172 | |
173 | ;; arch-tag: 1e3638af-cad3-4c69-8427-bc8eb6e5e4fa | |
a66894d8 | 174 | ;;; mh-gnus.el ends here |