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