-;;;
-;;; A MIME extender for mh-e
-;;;
-;;; by Morioka Tomohiko, 1993/11/21
-;;;
+;;; tm-mh-e.el --- MIME extension for mh-e
+;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
-;;; @ require modules
-;;;
+;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
+;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Created: 1993/11/21 (obsolete mh-e-mime.el)
+;; Version: $Revision: 7.68 $
+;; Keywords: mail, MH, MIME, multimedia, encoded-word, multilingual
+
+;; This file is part of tm (Tools for MIME).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with This program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
(require 'tl-str)
(require 'tl-misc)
(require 'mh-e)
-(if (not (boundp 'mh-e-version))
+(or (featurep 'mh-utils)
(require 'tm-mh-e3)
- )
+ )
(require 'tm-view)
+(or (fboundp 'mh-get-header-field)
+ (defalias 'mh-get-header-field 'mh-get-field)
+ )
+(or (boundp 'mh-temp-buffer)
+ (defconst mh-temp-buffer " *mh-temp*")
+ )
+
;;; @ version
;;;
(defconst tm-mh-e/RCS-ID
- "$Id: tm-mh-e.el,v 6.27 1995/09/20 12:34:39 morioka Exp $")
+ "$Id: tm-mh-e.el,v 7.68 1996/08/31 15:15:12 morioka Exp $")
(defconst tm-mh-e/version (get-version-string tm-mh-e/RCS-ID))
;;; @ variable
;;;
-(defvar tm-mh-e/decode-all t
- "*If t, decode all of the message. Otherwise decode header only.")
+(defvar tm-mh-e/automatic-mime-preview t
+ "*If non-nil, show MIME processed message.")
+
+(defvar tm-mh-e/decode-encoded-word t
+ "*If non-nil, decode encoded-word when it is not MIME preview mode.")
;;; @ functions
;;;
-(defun tm-mh-e/display-msg (msg-num folder &optional show-buffer mode)
+;; (if (not (fboundp 'tm-mh-e/original-mh-display-msg))
+;; (fset 'tm-mh-e/original-mh-display-msg
+;; (symbol-function 'mh-display-msg))
+;; )
+
+(defun mh-display-msg (msg-num folder &optional show-buffer mode)
(or mode
- (setq mode tm-mh-e/decode-all)
+ (setq mode tm-mh-e/automatic-mime-preview)
)
;; Display message NUMBER of FOLDER.
;; Sets the current buffer to the show buffer.
(setq buffer-read-only nil)
(erase-buffer)
(if mode
- (progn
+ (let* ((aname (concat "article-" folder))
+ (abuf (get-buffer aname))
+ )
+ (if abuf
+ (progn
+ (set-buffer abuf)
+ (setq buffer-read-only nil)
+ (erase-buffer)
+ )
+ (setq abuf (get-buffer-create aname))
+ (set-buffer abuf)
+ )
(let ((file-coding-system-for-read
(if (boundp 'MULE) *noconv*))
kanji-fileio-code)
)
(set-buffer-modified-p nil)
(setq buffer-read-only t)
+ (setq buffer-file-name msg-filename)
(mh-show-mode)
- (mime/viewer-mode)
+ (mime/viewer-mode nil nil nil
+ aname (concat "show-" folder))
(goto-char (point-min))
)
(let ((clean-message-header mh-clean-message-header)
(invisible-headers mh-invisible-headers)
(visible-headers mh-visible-headers)
)
- (insert-file-contents msg-filename)
+ ;; 1995/9/21
+ ;; modified by ARIURA <ariura@cc.tuat.ac.jp>
+ ;; to support mhl.
+ (if mhl-formfile
+ (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
+ (if (stringp mhl-formfile)
+ (list "-form" mhl-formfile))
+ msg-filename)
+ (insert-file-contents msg-filename))
+ ;; end
(goto-char (point-min))
(cond (clean-message-header
(mh-clean-msg-header (point-min)
(goto-char (point-min)))
(t
(mh-start-of-uncleaned-message)))
- (mime/decode-message-header)
+ (if tm-mh-e/decode-encoded-word
+ (mime/decode-message-header)
+ )
(set-buffer-modified-p nil)
(setq buffer-read-only t)
+ (setq buffer-file-name msg-filename)
(mh-show-mode)
))
(or (eq buffer-undo-list t) ;don't save undo info for prev msgs
(setq buffer-undo-list nil))
+;;; Added by itokon (02/19/96)
(setq buffer-file-name msg-filename)
+;;;
(set-mark nil)
(setq mode-line-buffer-identification
(list (format mh-show-buffer-mode-line-buffer-id
(set-buffer folder)
(setq mh-showing-with-headers nil)))))
-(fset 'mh-display-msg (symbol-function 'tm-mh-e/display-msg))
-
(defun tm-mh-e/view-message (&optional msg)
"MIME decode and play this message."
(interactive)
- (mh-invalidate-show-buffer)
- (let ((tm-mh-e/decode-all t))
- (mh-show-msg msg)
- )
- (pop-to-buffer (save-window-excursion
- (switch-to-buffer mh-show-buffer)
- mime::article/preview-buffer))
+ (if (or (null tm-mh-e/automatic-mime-preview)
+ (null (get-buffer mh-show-buffer))
+ (save-excursion
+ (set-buffer mh-show-buffer)
+ (not (eq major-mode 'mime/viewer-mode))
+ ))
+ (let ((tm-mh-e/automatic-mime-preview t))
+ (mh-invalidate-show-buffer)
+ (mh-show-msg msg)
+ ))
+ (pop-to-buffer mh-show-buffer)
)
(defun tm-mh-e/toggle-decoding-mode (arg)
"Toggle MIME processing mode.
With arg, turn MIME processing on if arg is positive."
(interactive "P")
- (setq tm-mh-e/decode-all
+ (setq tm-mh-e/automatic-mime-preview
(if (null arg)
- (not tm-mh-e/decode-all)
+ (not tm-mh-e/automatic-mime-preview)
arg))
- (save-window-excursion
- (switch-to-buffer mh-show-buffer)
- (if (null tm-mh-e/decode-all)
- (if (and mime::article/preview-buffer
- (get-buffer mime::article/preview-buffer))
- (kill-buffer mime::article/preview-buffer)
+ (save-excursion
+ (set-buffer mh-show-buffer)
+ (if (null tm-mh-e/automatic-mime-preview)
+ (if (and mime::preview/article-buffer
+ (get-buffer mime::preview/article-buffer))
+ (kill-buffer mime::preview/article-buffer)
)))
+ (mh-invalidate-show-buffer)
(mh-show (mh-get-msg-num t))
- (if tm-mh-e/decode-all
- (let ((the-buf (current-buffer)))
- (if mime::article/preview-buffer
- (pop-to-buffer (save-excursion
- (switch-to-buffer mh-show-buffer)
- mime::article/preview-buffer))
- (tm-mh-e/view-message (mh-get-msg-num t)))
- (pop-to-buffer the-buf)
- )))
-
-(defun tm-mh-e/page-msg ()
+ )
+
+(defun tm-mh-e/show (&optional message)
(interactive)
- (if tm-mh-e/decode-all
- (scroll-other-window)
- (mh-page-msg)
- ))
+ (mh-invalidate-show-buffer)
+ (mh-show message)
+ )
-(defun tm-mh-e/previous-page ()
+(defun tm-mh-e/header-display ()
(interactive)
- (if tm-mh-e/decode-all
- (scroll-other-window (- (save-window-excursion
- (other-window 1)
- (window-height))))
- (mh-previous-page)
+ (mh-invalidate-show-buffer)
+ (let ((mime-viewer/ignored-field-regexp "^:$")
+ tm-mh-e/decode-encoded-word)
+ (mh-header-display)
))
-(defun tm-mh-e/cite ()
+(defun tm-mh-e/raw-display ()
(interactive)
- (if tm-mh-e/decode-all
- (save-excursion
- (save-restriction
- (insert-buffer
- (save-window-excursion
- (switch-to-buffer (concat "show-" mh-sent-from-folder))
- mime::article/preview-buffer))
- (if (looking-at "^\\[.+\\(\n[ \t].+\\)*\\]\n")
- (replace-match ""))
- (narrow-to-region (point)(point-max))
- (mh-insert-prefix-string mh-ins-buf-prefix)
- ))
- (mh-yank-cur-msg)
+ (mh-invalidate-show-buffer)
+ (let (tm-mh-e/automatic-mime-preview
+ tm-mh-e/decode-encoded-word)
+ (mh-header-display)
))
-(defun tm-mh-e/toggle-showing ()
- "Toggle the scanning mode/showing mode of displaying messages."
+(defun tm-mh-e/scroll-up-msg (&optional arg)
(interactive)
- (if mh-showing
- (if tm-mh-e/decode-all
- (let ((pbuf
- (save-window-excursion
- (set-buffer mh-show-buffer)
- mime::article/preview-buffer)))
- (if (get-buffer pbuf)
- (delete-windows-on pbuf)
- )
- (setq mh-showing nil)
- (set-buffer-modified-p (buffer-modified-p)) ;force mode line update
- (if mh-recenter-summary-p
- (mh-recenter nil)
- ))
- (mh-set-scan-mode)
- )
- (mh-show)
+ (mh-page-msg (or arg 1))
+ )
+
+(defun tm-mh-e/scroll-down-msg (&optional arg)
+ (interactive)
+ (mh-page-msg (- (or arg 1)))
+ )
+
+(defun tm-mh-e/burst-multipart/digest ()
+ "Burst apart the current message, which should be a multipart/digest.
+The message is replaced by its table of contents and the letters from the
+digest are inserted into the folder after that message."
+ (interactive)
+ (let ((digest (mh-get-msg-num t)))
+ (mh-process-or-undo-commands mh-current-folder)
+ (mh-set-folder-modified-p t) ; lock folder while bursting
+ (message "Bursting digest...")
+ (mh-exec-cmd "mhn" "-store" mh-current-folder digest)
+ (mh-scan-folder mh-current-folder (format "%d-last" mh-first-msg-num))
+ (message "Bursting digest...done")
))
;;; @ for tm-view
;;;
-(fset 'tm-mh-e/code-convert-region-to-emacs
- (symbol-function 'mime/code-convert-region-to-emacs))
+(fset 'tm-mh-e/decode-charset-buffer
+ (symbol-function 'mime-charset/decode-buffer))
+
+(set-alist 'mime-viewer/code-converter-alist
+ 'mh-show-mode
+ (function tm-mh-e/decode-charset-buffer))
(defun tm-mh-e/content-header-filter ()
- (mime-viewer/x-face-function)
(goto-char (point-min))
- (while (and (re-search-forward
- (concat "^" mime-viewer/ignored-field-regexp ":")
- nil t)
- (progn
- (delete-region
- (match-beginning 0)
- (save-excursion
- (and
- (re-search-forward "^\\([^ \t]\\|$\\)" nil t)
- (match-beginning 0)
- )))
- t)))
- (tm-mh-e/code-convert-region-to-emacs (point-min)(point-max)
- mime/default-coding-system)
+ (mime-preview/cut-header)
+ (tm-mh-e/decode-charset-buffer default-mime-charset)
(mime/decode-message-header)
- (if (featurep 'hilit19)
- (hilit-rehighlight-buffer-quietly)
- )
)
+(set-alist 'mime-viewer/content-header-filter-alist
+ 'mh-show-mode
+ (function tm-mh-e/content-header-filter))
+
(defun tm-mh-e/quitting-method ()
(let ((win (get-buffer-window
mime/output-buffer-name))
- (buf mime::preview/article-buffer)
+ (buf (current-buffer))
)
(if win
(delete-window win)
(let ((name (buffer-name buf)))
(substring name 5)
))
- (if (not tm-mh-e/decode-all)
- (mh-show (mh-get-msg-num t))
- )))
-
-
-;;; @ for tm-comp
-;;;
+ (if (not tm-mh-e/automatic-mime-preview)
+ (mh-invalidate-show-buffer)
+ )
+ (mh-show (mh-get-msg-num t))
+ ))
-(defun tm-mh-e::make-message (folder number)
- (vector folder number)
- )
+(set-alist 'mime-viewer/quitting-method-alist
+ 'mh-show-mode
+ (function tm-mh-e/quitting-method))
+(set-alist 'mime-viewer/show-summary-method
+ 'mh-show-mode
+ (function tm-mh-e/quitting-method))
-(defun tm-mh-e::message/folder (message)
- (elt message 0)
- )
+(defun tm-mh-e/following-method (buf)
+ (save-excursion
+ (set-buffer buf)
+ (goto-char (point-max))
+ (setq mh-show-buffer buf)
+ (apply (function mh-send)
+ (std11-field-bodies '("To" "cc" "Subject") ""))
+ (setq mh-sent-from-folder buf)
+ (setq mh-sent-from-msg 1)
+ (let ((last (point)))
+ (mh-yank-cur-msg)
+ (goto-char last)
+ )))
-(defun tm-mh-e::message/number (message)
- (elt message 1)
- )
+(set-alist 'mime-viewer/following-method-alist
+ 'mh-show-mode
+ (function tm-mh-e/following-method))
-(defun tm-mh-e::message/file-name (message)
- (expand-file-name
- (tm-mh-e::message/number message)
- (mh-expand-file-name (tm-mh-e::message/folder message))
- ))
-
-(defun tm-mh-e::prompt-for-message (prompt folder &optional default)
- (let ((files
- (directory-files (mh-expand-file-name folder) nil "^[0-9]+$")
- ))
- (completing-read prompt
- (let ((i 0))
- (mapcar (function
- (lambda (file)
- (setq i (+ i 1))
- (list file i)
- ))
- files)
- ))
- ))
-
-(defun tm-mh-e::query-message ()
- (let* ((folder (mh-prompt-for-folder "Visit" "+inbox" nil))
- (number (tm-mh-e::prompt-for-message "Number?" folder))
- )
- (tm-mh-e::make-message folder number)
- ))
-(defun tm-mh-e::insert-message (&optional message)
- (if (null message)
- (setq message (tm-mh-e::query-message))
- )
- (insert-file (tm-mh-e::message/file-name message))
- )
+;;; @@ for tm-partial
+;;;
(call-after-loaded
- 'tm-comp
+ 'tm-partial
(function
(lambda ()
- (set-alist
- 'tm-comp/message-inserter-alist
- 'mh-letter-mode (function tm-mh-e::insert-message))
+ (set-atype 'mime/content-decoding-condition
+ '((type . "message/partial")
+ (method . mime-article/grab-message/partials)
+ (major-mode . mh-show-mode)
+ (summary-buffer-exp
+ . (and (or (string-match "^article-\\(.+\\)$" article-buffer)
+ (string-match "^show-\\(.+\\)$" article-buffer))
+ (substring article-buffer
+ (match-beginning 1) (match-end 1))
+ ))
+ ))
+ (set-alist 'tm-partial/preview-article-method-alist
+ 'mh-show-mode
+ (function
+ (lambda ()
+ (let ((tm-mh-e/automatic-mime-preview t))
+ (tm-mh-e/show)
+ ))))
)))
;;; @ set up
;;;
-;;(add-hook 'mh-show-mode-hook (function mime/viewer-mode))
-
(define-key mh-folder-mode-map "v" (function tm-mh-e/view-message))
(define-key mh-folder-mode-map "\et" (function tm-mh-e/toggle-decoding-mode))
-(define-key mh-folder-mode-map "t" (function tm-mh-e/toggle-showing))
-(define-key mh-folder-mode-map "\r"
- (function (lambda ()
- (interactive)
- (scroll-other-window 1)
- )))
-(define-key mh-folder-mode-map "\e\r"
- (function (lambda ()
- (interactive)
- (scroll-other-window -1)
- )))
-(define-key mh-folder-mode-map " " (function tm-mh-e/page-msg))
-(define-key mh-folder-mode-map "\177" (function tm-mh-e/previous-page))
-
-(add-hook 'mh-letter-mode-hook
- (function
- (lambda ()
- (define-key mh-letter-mode-map "\C-c\C-y" (function tm-mh-e/cite))
- )))
+(define-key mh-folder-mode-map "." (function tm-mh-e/show))
+(define-key mh-folder-mode-map "," (function tm-mh-e/header-display))
+(define-key mh-folder-mode-map "\e," (function tm-mh-e/raw-display))
+(define-key mh-folder-mode-map "\r" (function tm-mh-e/scroll-up-msg))
+(define-key mh-folder-mode-map "\e\r" (function tm-mh-e/scroll-down-msg))
+(define-key mh-folder-mode-map "\C-c\C-b"
+ (function tm-mh-e/burst-multipart/digest))
(defun tm-mh-e/summary-before-quit ()
(let ((buf (get-buffer mh-show-buffer)))
(add-hook 'mh-before-quit-hook (function tm-mh-e/summary-before-quit))
-(set-alist 'mime-viewer/quitting-method-alist
- 'mh-show-mode
- (function tm-mh-e/quitting-method))
-(set-alist 'mime-viewer/content-header-filter-alist
- 'mh-show-mode
- (function tm-mh-e/content-header-filter))
+;;; @@ for tmh-comp.el
+;;;
+
+(autoload 'tm-mh-e/edit-again "tmh-comp"
+ "Clean-up a draft or a message previously sent and make it resendable." t)
+(autoload 'tm-mh-e/extract-rejected-mail "tmh-comp"
+ "Extract a letter returned by the mail system and make it re-editable." t)
+(autoload 'tm-mh-e/forward "tmh-comp"
+ "Forward a message or message sequence by MIME style." t)
+
+(call-after-loaded
+ 'mime-setup
+ (function
+ (lambda ()
+ (substitute-key-definition
+ 'mh-edit-again 'tm-mh-e/edit-again mh-folder-mode-map)
+ (substitute-key-definition
+ 'mh-extract-rejected-mail 'tm-mh-e/extract-rejected-mail
+ mh-folder-mode-map)
+ (substitute-key-definition
+ 'mh-forward 'tm-mh-e/forward mh-folder-mode-map)
+
+ (call-after-loaded
+ 'mh-comp
+ (function
+ (lambda ()
+ (require 'tmh-comp)
+ ))
+ 'mh-letter-mode-hook)
+ )))
-(set-alist 'mime-viewer/code-converter-alist
- 'mh-show-mode
- (function tm-mh-e/code-convert-region-to-emacs))
+
+;;; @ for BBDB
+;;;
+
+(call-after-loaded
+ 'bbdb
+ (function
+ (lambda ()
+ (require 'tm-bbdb)
+ )))
;;; @ end
(provide 'tm-mh-e)
(run-hooks 'tm-mh-e-load-hook)
+
+;;; tm-mh-e.el ends here