Commit | Line | Data |
---|---|---|
dda00b2c | 1 | ;;; mh-gnus.el --- make MH-E compatible with various versions of Gnus |
a66894d8 | 2 | |
549afb31 | 3 | ;; Copyright (C) 2003, 2004, 2006 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 | ||
dda00b2c | 33 | (require 'mh-e) |
549afb31 | 34 | |
dda00b2c BW |
35 | (require 'gnus-util nil t) |
36 | (require 'mm-bodies nil t) | |
37 | (require 'mm-decode nil t) | |
38 | (require 'mm-view nil t) | |
39 | (require 'mml nil t) | |
a66894d8 | 40 | |
549afb31 | 41 | ;; Copy of function from gnus-util.el. |
a66894d8 BW |
42 | (mh-defun-compat gnus-local-map-property (map) |
43 | "Return a list suitable for a text property list specifying keymap MAP." | |
44 | (cond (mh-xemacs-flag (list 'keymap map)) | |
45 | ((>= emacs-major-version 21) (list 'keymap map)) | |
46 | (t (list 'local-map map)))) | |
47 | ||
549afb31 | 48 | ;; Copy of function from mm-decode.el. |
a66894d8 BW |
49 | (mh-defun-compat mm-merge-handles (handles1 handles2) |
50 | (append (if (listp (car handles1)) handles1 (list handles1)) | |
51 | (if (listp (car handles2)) handles2 (list handles2)))) | |
52 | ||
0c47b17c | 53 | ;; Copy of function from mm-decode.el. |
a66894d8 BW |
54 | (mh-defun-compat mm-set-handle-multipart-parameter (handle parameter value) |
55 | ;; HANDLE could be a CTL. | |
56 | (if handle | |
57 | (put-text-property 0 (length (car handle)) parameter value | |
58 | (car handle)))) | |
59 | ||
0c47b17c | 60 | ;; Copy of function from mm-view.el. |
f0d73c14 BW |
61 | (mh-defun-compat mm-inline-text-vcard (handle) |
62 | (let (buffer-read-only) | |
63 | (mm-insert-inline | |
64 | handle | |
65 | (concat "\n-- \n" | |
dda00b2c BW |
66 | (ignore-errors |
67 | (if (fboundp 'vcard-pretty-print) | |
68 | (vcard-pretty-print (mm-get-part handle)) | |
69 | (vcard-format-string | |
70 | (vcard-parse-string (mm-get-part handle) | |
71 | 'vcard-standard-filter)))))))) | |
f0d73c14 BW |
72 | |
73 | ;; Function from mm-decode.el used in PGP messages. Just define it with older | |
0c47b17c | 74 | ;; Gnus to avoid compiler warning. |
f0d73c14 BW |
75 | (mh-defun-compat mm-possibly-verify-or-decrypt (parts ctl) |
76 | nil) | |
77 | ||
549afb31 | 78 | ;; Copy of macro in mm-decode.el. |
a66894d8 BW |
79 | (mh-defmacro-compat mm-handle-multipart-ctl-parameter (handle parameter) |
80 | `(get-text-property 0 ,parameter (car ,handle))) | |
81 | ||
549afb31 | 82 | ;; Copy of function in mm-decode.el. |
a66894d8 BW |
83 | (mh-defun-compat mm-readable-p (handle) |
84 | "Say whether the content of HANDLE is readable." | |
85 | (and (< (with-current-buffer (mm-handle-buffer handle) | |
86 | (buffer-size)) 10000) | |
87 | (mm-with-unibyte-buffer | |
88 | (mm-insert-part handle) | |
89 | (and (eq (mm-body-7-or-8) '7bit) | |
90 | (not (mm-long-lines-p 76)))))) | |
91 | ||
549afb31 | 92 | ;; Copy of function in mm-bodies.el. |
a66894d8 BW |
93 | (mh-defun-compat mm-long-lines-p (length) |
94 | "Say whether any of the lines in the buffer is longer than LENGTH." | |
95 | (save-excursion | |
96 | (goto-char (point-min)) | |
97 | (end-of-line) | |
98 | (while (and (not (eobp)) | |
99 | (not (> (current-column) length))) | |
100 | (forward-line 1) | |
101 | (end-of-line)) | |
102 | (and (> (current-column) length) | |
103 | (current-column)))) | |
104 | ||
105 | (mh-defun-compat mm-keep-viewer-alive-p (handle) | |
106 | ;; Released Gnus doesn't keep handles associated with externally displayed | |
107 | ;; MIME parts. So this will always return nil. | |
108 | nil) | |
109 | ||
110 | (mh-defun-compat mm-destroy-parts (list) | |
0c47b17c | 111 | "Older versions of Emacs don't have this function." |
a66894d8 BW |
112 | nil) |
113 | ||
dda00b2c BW |
114 | (mh-defun-compat mm-uu-dissect-text-parts (handles) |
115 | "Emacs 21 and XEmacs don't have this function." | |
116 | nil) | |
117 | ||
549afb31 | 118 | ;; Copy of function in mml.el. |
0c47b17c BW |
119 | (mh-defun-compat mml-minibuffer-read-disposition (type &optional default) |
120 | (unless default (setq default | |
121 | (if (and (string-match "\\`text/" type) | |
122 | (not (string-match "\\`text/rtf\\'" type))) | |
123 | "inline" | |
124 | "attachment"))) | |
125 | (let ((disposition (completing-read | |
126 | (format "Disposition (default %s): " default) | |
127 | '(("attachment") ("inline") ("")) | |
128 | nil t nil nil default))) | |
129 | (if (not (equal disposition "")) | |
dda00b2c | 130 | disposition |
0c47b17c BW |
131 | default))) |
132 | ||
cee9f5c6 BW |
133 | ;; This is mm-save-part from Gnus 5.10 since that function in emacs21.2 is |
134 | ;; buggy (the args to read-file-name are incorrect). When all supported | |
135 | ;; versions of Emacs come with at least Gnus 5.10, we can delete this | |
136 | ;; function and rename calls to mh-mm-save-part to mm-save-part. | |
a66894d8 BW |
137 | (defun mh-mm-save-part (handle) |
138 | "Write HANDLE to a file." | |
139 | (let ((name (mail-content-type-get (mm-handle-type handle) 'name)) | |
140 | (filename (mail-content-type-get | |
141 | (mm-handle-disposition handle) 'filename)) | |
142 | file) | |
143 | (when filename | |
144 | (setq filename (file-name-nondirectory filename))) | |
145 | (setq file (read-file-name "Save MIME part to: " | |
146 | (or mm-default-directory | |
147 | default-directory) | |
148 | nil nil (or filename name ""))) | |
149 | (setq mm-default-directory (file-name-directory file)) | |
150 | (and (or (not (file-exists-p file)) | |
151 | (yes-or-no-p (format "File %s already exists; overwrite? " | |
152 | file))) | |
153 | (mm-save-part-to-file handle file)))) | |
154 | ||
f0d73c14 | 155 | (defun mh-mm-text-html-renderer () |
0c47b17c | 156 | "Find the renderer Gnus is using to display text/html MIME parts." |
f0d73c14 BW |
157 | (or (and (boundp 'mm-inline-text-html-renderer) mm-inline-text-html-renderer) |
158 | (and (boundp 'mm-text-html-renderer) mm-text-html-renderer))) | |
159 | ||
a66894d8 | 160 | (provide 'mh-gnus) |
f0d73c14 | 161 | |
cee9f5c6 BW |
162 | ;; Local Variables: |
163 | ;; no-byte-compile: t | |
164 | ;; no-update-autoloads: t | |
165 | ;; indent-tabs-mode: nil | |
166 | ;; sentence-end-double-space: nil | |
167 | ;; End: | |
23b8b180 MB |
168 | |
169 | ;; arch-tag: 1e3638af-cad3-4c69-8427-bc8eb6e5e4fa | |
a66894d8 | 170 | ;;; mh-gnus.el ends here |