1 ;;; mh-gnus.el --- Make MH-E compatible with installed version of Gnus.
3 ;; Copyright (C) 2003 Free Software Foundation, Inc.
5 ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
10 ;; This file is part of GNU Emacs.
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)
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.
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., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
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
38 (defmacro mh-defun-compat (function arg-list &rest body)
39 "This is a macro to define functions which are not defined.
40 It is used for Gnus utility functions which were added recently. If FUNCTION
41 is not defined then it is defined to have argument list, ARG-LIST and body,
43 (let ((defined-p (fboundp function)))
45 `(defun ,function ,arg-list ,@body))))
46 (put 'mh-defun-compat 'lisp-indent-function 'defun)
48 (defmacro mh-defmacro-compat (function arg-list &rest body)
49 "This is a macro to define functions which are not defined.
50 It is used for Gnus utility functions which were added recently. If FUNCTION
51 is not defined then it is defined to have argument list, ARG-LIST and body,
53 (let ((defined-p (fboundp function)))
55 `(defmacro ,function ,arg-list ,@body))))
56 (put 'mh-defmacro-compat 'lisp-indent-function 'defun)
58 ;; Copy of original function from gnus-util.el
59 (mh-defun-compat gnus-local-map-property (map)
60 "Return a list suitable for a text property list specifying keymap MAP."
61 (cond (mh-xemacs-flag (list 'keymap map))
62 ((>= emacs-major-version 21) (list 'keymap map))
63 (t (list 'local-map map))))
65 ;; Copy of original function from mm-decode.el
66 (mh-defun-compat mm-merge-handles (handles1 handles2)
67 (append (if (listp (car handles1)) handles1 (list handles1))
68 (if (listp (car handles2)) handles2 (list handles2))))
70 ;; Copy of function from mm-decode.el
71 (mh-defun-compat mm-set-handle-multipart-parameter (handle parameter value)
72 ;; HANDLE could be a CTL.
74 (put-text-property 0 (length (car handle)) parameter value
77 ;; Copy of original macro is in mm-decode.el
78 (mh-defmacro-compat mm-handle-multipart-ctl-parameter (handle parameter)
79 `(get-text-property 0 ,parameter (car ,handle)))
81 (mh-do-in-xemacs (defvar default-enable-multibyte-characters))
83 ;; Copy of original function in mm-decode.el
84 (mh-defun-compat mm-readable-p (handle)
85 "Say whether the content of HANDLE is readable."
86 (and (< (with-current-buffer (mm-handle-buffer handle)
88 (mm-with-unibyte-buffer
89 (mm-insert-part handle)
90 (and (eq (mm-body-7-or-8) '7bit)
91 (not (mm-long-lines-p 76))))))
93 ;; Copy of original function in mm-bodies.el
94 (mh-defun-compat mm-long-lines-p (length)
95 "Say whether any of the lines in the buffer is longer than LENGTH."
97 (goto-char (point-min))
99 (while (and (not (eobp))
100 (not (> (current-column) length)))
103 (and (> (current-column) length)
106 (mh-defun-compat mm-keep-viewer-alive-p (handle)
107 ;; Released Gnus doesn't keep handles associated with externally displayed
108 ;; MIME parts. So this will always return nil.
111 (mh-defun-compat mm-destroy-parts (list)
112 "Older emacs don't have this function."
115 ;;; This is mm-save-part from gnus 5.10 since that function in emacs21.2 is
116 ;;; buggy (the args to read-file-name are incorrect). When all supported
117 ;;; versions of Emacs come with at least Gnus 5.10, we can delete this
118 ;;; function and rename calls to mh-mm-save-part to mm-save-part.
119 (defun mh-mm-save-part (handle)
120 "Write HANDLE to a file."
121 (let ((name (mail-content-type-get (mm-handle-type handle) 'name))
122 (filename (mail-content-type-get
123 (mm-handle-disposition handle) 'filename))
126 (setq filename (file-name-nondirectory filename)))
127 (setq file (read-file-name "Save MIME part to: "
128 (or mm-default-directory
130 nil nil (or filename name "")))
131 (setq mm-default-directory (file-name-directory file))
132 (and (or (not (file-exists-p file))
133 (yes-or-no-p (format "File %s already exists; overwrite? "
135 (mm-save-part-to-file handle file))))
139 ;;; no-byte-compile: t
140 ;;; no-update-autoloads: t
142 ;;; mh-gnus.el ends here