X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tm-view.el;h=9afb5dce90a4057b4d7f4386804c09a873835837;hb=8e18eb1fd95180a6ea115a00ce2f045815809b49;hp=c9b2d5ebd61c9611cc8f814ba7d6f5ae9b35edf5;hpb=91d6a91a5a2f50b196ff69c5485295b621a278bb;p=elisp%2Ftm.git diff --git a/tm-view.el b/tm-view.el index c9b2d5e..9afb5dc 100644 --- a/tm-view.el +++ b/tm-view.el @@ -1,39 +1,36 @@ -;;; ;;; tm-view.el --- interactive MIME viewer for GNU Emacs -;;; -;;; Copyright (C) 1995 Free Software Foundation, Inc. -;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko -;;; -;;; Author: MORIOKA Tomohiko -;;; modified by Steven L. Baur -;;; Maintainer: MORIOKA Tomohiko -;;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el) -;;; Version: $Revision: 7.62 $ -;;; Keywords: mail, news, MIME, multimedia -;;; -;;; 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. If not, write to the Free Software -;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -;;; + +;; Copyright (C) 1995,1996 Free Software Foundation, Inc. + +;; Author: MORIOKA Tomohiko +;; Created: 1994/7/13 (1994/8/31 obsolete tm-body.el) +;; Version: $Revision: 7.79 $ +;; Keywords: mail, news, MIME, multimedia + +;; 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 GNU Emacs; 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-list) (require 'tl-atype) (require 'tl-misc) -(require 'tl-822) +(require 'std11) (require 'mel) (require 'tm-ew-d) (require 'tm-def) @@ -45,7 +42,7 @@ ;;; (defconst mime-viewer/RCS-ID - "$Id: tm-view.el,v 7.62 1996/05/17 07:59:40 morioka Exp $") + "$Id: tm-view.el,v 7.79 1996/12/16 15:06:08 morioka Exp $") (defconst mime-viewer/version (get-version-string mime-viewer/RCS-ID)) (defconst mime/viewer-version mime-viewer/version) @@ -56,50 +53,84 @@ (defvar mime/content-decoding-condition '(((type . "text/plain") - (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-plain" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "text/html") (method "tm-html" nil 'file 'type 'encoding 'mode 'name) - (mode . "play")) + (mode . "play") + ) ((type . "text/x-rot13-47") - (method . mime-article/decode-caesar)) - + (method . mime-article/decode-caesar) + (mode . "play") + ) ((type . "audio/basic") - (method "tm-au" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-au" nil 'file 'type 'encoding 'mode 'name) + (mode . "play") + ) ((type . "image/jpeg") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/gif") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/tiff") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/x-tiff") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/x-xbm") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/x-pic") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "image/x-mag") - (method "tm-image" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-image" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "video/mpeg") - (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-mpeg" nil 'file 'type 'encoding 'mode 'name) + (mode . "play") + ) + ((type . "application/postscript") + (method "tm-ps" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ((type . "application/octet-stream") - (method "tm-file" nil 'file 'type 'encoding 'mode 'name)) + (method "tm-file" nil 'file 'type 'encoding 'mode 'name) + (mode "play" "print") + ) ;;((type . "message/external-body") ;; (method "xterm" nil ;; "-e" "showexternal" ;; 'file '"access-type" '"name" '"site" '"directory")) ((type . "message/rfc822") - (method . mime-article/view-message/rfc822)) + (method . mime-article/view-message/rfc822) + (mode . "play") + ) ((type . "message/partial") - (method . mime-article/decode-message/partial)) + (method . mime-article/decode-message/partial) + (mode . "play") + ) - ((method "metamail" t - "-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play")) + ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file) + (mode . "play") + ) ((method "tm-file" nil 'file 'type 'encoding 'mode 'name) - (mode . "extract")) + (mode . "extract") + ) )) (defvar mime-viewer/childrens-header-showing-Content-Type-list @@ -113,10 +144,10 @@ "application/octet-stream" "application/x-selection" "application/x-comment")) -(defvar mime-viewer/content-subject-omitting-Content-Type-list +(defvar mime-viewer/content-button-ignored-ctype-list '("application/x-selection")) -(defvar mime-viewer/content-subject-showing-Content-Type-list +(defvar mime-viewer/content-button-visible-ctype-list '("application/pgp")) (defvar mime-viewer/uuencode-encoding-name-list '("x-uue" "x-uuencode")) @@ -136,7 +167,7 @@ Each elements are regexp of field-name. [tm-view.el]") ":")) (defvar mime-viewer/visible-field-list - '("Dnas.*") + '("Dnas.*" "Message-Id") "All fields that match this list will be displayed in MIME preview buffer. Each elements are regexp of field-name. [tm-view.el]") @@ -193,10 +224,10 @@ Each elements are regexp of field-name. [tm-view.el]") )) -;;; @@ content subject +;;; @@ content button ;;; -(defun mime-preview/insert-content-subject +(defun mime-preview/insert-content-button (rcnum cinfo ctype params subj encoding) (save-restriction (narrow-to-region (point)(point)) @@ -215,8 +246,8 @@ Each elements are regexp of field-name. [tm-view.el]") (let ((server (assoc "server" params))) (setq access-type (cdr access-type)) (if server - (format "[%s %s ([%s] %s)]\n" num subj - access-type (cdr server)) + (insert (format "[%s %s ([%s] %s)]\n" num subj + access-type (cdr server))) (let ((site (assoc-value "site" params)) (dir (assoc-value "directory" params)) ) @@ -244,18 +275,18 @@ Each elements are regexp of field-name. [tm-view.el]") (function mime-viewer/play-content)) )) -(defun mime-preview/default-content-subject-function +(defun mime-preview/default-content-button-function (rcnum cinfo ctype params subj encoding) (if (and (consp rcnum) (not (member ctype - mime-viewer/content-subject-omitting-Content-Type-list))) - (mime-preview/insert-content-subject + mime-viewer/content-button-ignored-ctype-list))) + (mime-preview/insert-content-button rcnum cinfo ctype params subj encoding) )) -(defvar mime-preview/content-subject-function - (function mime-preview/default-content-subject-function)) +(defvar mime-preview/content-button-function + (function mime-preview/default-content-button-function)) ;;; @@ content header filter @@ -349,6 +380,9 @@ Each elements are regexp of field-name. [tm-view.el]") (defvar mime-viewer/following-method-alist nil) +(defvar mime-viewer/following-required-fields-list + '("From")) + ;;; @@ X-Face ;;; @@ -375,7 +409,7 @@ The compressed face will be piped to this command.") (goto-char (point-min)) (if (re-search-forward "^X-Face:[ \t]*" nil t) (let ((beg (match-end 0)) - (end (rfc822/field-end)) + (end (std11-field-end)) ) (call-process-region beg end "sh" nil 0 nil "-c" mime-viewer/x-face-command) @@ -475,17 +509,17 @@ The compressed face will be piped to this command.") (set-buffer obuf) (setq nb (point)) (narrow-to-region nb nb) - (funcall mime-preview/content-subject-function + (funcall mime-preview/content-button-function rcnum cinfo ctype params subj encoding) (if (mime-viewer/header-visible-p rcnum cinfo ctype) (mime-preview/display-header beg he) ) (if (and (null rcnum) (member - ctype mime-viewer/content-subject-showing-Content-Type-list)) + ctype mime-viewer/content-button-visible-ctype-list)) (save-excursion (goto-char (point-max)) - (mime-preview/insert-content-subject + (mime-preview/insert-content-button rcnum cinfo ctype params subj encoding) )) (cond ((mime-viewer/body-visible-p rcnum cinfo ctype) @@ -499,7 +533,7 @@ The compressed face will be piped to this command.") (null (mime::content-info/children cinfo)) ) (goto-char (point-max)) - (mime-preview/insert-content-subject + (mime-preview/insert-content-button rcnum cinfo ctype params subj encoding) )) (mime-preview/default-content-separator rcnum cinfo ctype params subj) @@ -564,8 +598,7 @@ The compressed face will be piped to this command.") )) (defun mime-article/get-subject (param &optional encoding) - (or (rfc822/get-field-body "Content-Description") - (rfc822/get-field-body "Subject") + (or (std11-find-field-body '("Content-Description" "Subject")) (let (ret) (if (or (and (setq ret (mime/Content-Disposition)) (setq ret (assoc "filename" (cdr ret))) @@ -573,7 +606,7 @@ The compressed face will be piped to this command.") (setq ret (assoc "name" param)) (setq ret (assoc "x-name" param)) ) - (rfc822/strip-quoted-string (cdr ret)) + (std11-strip-quoted-string (cdr ret)) )) (mime-article/get-uu-filename param encoding) "")) @@ -608,13 +641,12 @@ The compressed face will be piped to this command.") (or cinfo (setq cinfo mime::article/content-info) ) - (some-element - (function - (lambda (ci) - (equal (mime::content-info/rcnum ci) rcnum) - )) - (mime/flatten-content-info cinfo) - )) + (find-if (function + (lambda (ci) + (equal (mime::content-info/rcnum ci) rcnum) + )) + (mime/flatten-content-info cinfo) + )) (defun mime-article/cnum-to-cinfo (cn &optional cinfo) (or cinfo @@ -680,85 +712,94 @@ The compressed face will be piped to this command.") ) "Menu for MIME Viewer") -(defvar mime/viewer-mode-map nil) -(if (null mime/viewer-mode-map) +(if running-xemacs (progn - (setq mime/viewer-mode-map (make-keymap)) - (suppress-keymap mime/viewer-mode-map) - (define-key mime/viewer-mode-map - "u" (function mime-viewer/up-content)) - (define-key mime/viewer-mode-map - "p" (function mime-viewer/previous-content)) - (define-key mime/viewer-mode-map - "n" (function mime-viewer/next-content)) - (define-key mime/viewer-mode-map - " " (function mime-viewer/scroll-up-content)) - (define-key mime/viewer-mode-map - "\M- " (function mime-viewer/scroll-down-content)) - (define-key mime/viewer-mode-map - "\177" (function mime-viewer/scroll-down-content)) - (define-key mime/viewer-mode-map - "\C-m" (function mime-viewer/next-line-content)) - (define-key mime/viewer-mode-map - "\C-\M-m" (function mime-viewer/previous-line-content)) - (define-key mime/viewer-mode-map - "v" (function mime-viewer/play-content)) - (define-key mime/viewer-mode-map - "e" (function mime-viewer/extract-content)) - (define-key mime/viewer-mode-map - "\C-c\C-p" (function mime-viewer/print-content)) - (define-key mime/viewer-mode-map - "x" (function mime-viewer/display-x-face)) - (define-key mime/viewer-mode-map - "a" (function mime-viewer/follow-content)) - (define-key mime/viewer-mode-map - "q" (function mime-viewer/quit)) - (define-key mime/viewer-mode-map - "h" (function mime-viewer/show-summary)) - (define-key mime/viewer-mode-map - "\C-c\C-x" (function mime-viewer/kill-buffer)) - (define-key mime/viewer-mode-map - "<" (function beginning-of-buffer)) - (define-key mime/viewer-mode-map - ">" (function end-of-buffer)) - (if mouse-button-2 - (define-key mime/viewer-mode-map - mouse-button-2 (function tm:button-dispatcher)) - ) - (cond (running-xemacs - (defvar mime-viewer/xemacs-popup-menu - (cons mime-viewer/menu-title - (mapcar (function - (lambda (item) - (vector (nth 1 item)(nth 2 item) t) - )) - mime-viewer/menu-list))) - (defun mime-viewer/xemacs-popup-menu (event) - "Popup the menu in the MIME Viewer buffer" - (interactive "e") - (select-window (event-window event)) - (set-buffer (event-buffer event)) - (popup-menu 'mime-viewer/xemacs-popup-menu)) - (define-key mime/viewer-mode-map - mouse-button-3 (function mime-viewer/xemacs-popup-menu)) - ) - ((>= emacs-major-version 19) - (define-key mime/viewer-mode-map [menu-bar mime-view] - (cons mime-viewer/menu-title - (make-sparse-keymap mime-viewer/menu-title))) - (mapcar (function - (lambda (item) - (define-key mime/viewer-mode-map - (vector 'menu-bar 'mime-view (car item)) - (cons (nth 1 item)(nth 2 item)) - ) - )) - (reverse mime-viewer/menu-list) - ) - )) + (defvar mime-viewer/xemacs-popup-menu + (cons mime-viewer/menu-title + (mapcar (function + (lambda (item) + (vector (nth 1 item)(nth 2 item) t) + )) + mime-viewer/menu-list))) + (defun mime-viewer/xemacs-popup-menu (event) + "Popup the menu in the MIME Viewer buffer" + (interactive "e") + (select-window (event-window event)) + (set-buffer (event-buffer event)) + (popup-menu 'mime-viewer/xemacs-popup-menu)) )) -(defun mime/viewer-mode (&optional mother ctl encoding ibuf obuf) +(defun mime-viewer/define-keymap (&optional mother) + (let ((mime/viewer-mode-map (if mother + (copy-keymap mother) + (make-keymap)))) + (suppress-keymap mime/viewer-mode-map) + (define-key mime/viewer-mode-map + "u" (function mime-viewer/up-content)) + (define-key mime/viewer-mode-map + "p" (function mime-viewer/previous-content)) + (define-key mime/viewer-mode-map + "n" (function mime-viewer/next-content)) + (define-key mime/viewer-mode-map + " " (function mime-viewer/scroll-up-content)) + (define-key mime/viewer-mode-map + "\M- " (function mime-viewer/scroll-down-content)) + (define-key mime/viewer-mode-map + "\177" (function mime-viewer/scroll-down-content)) + (define-key mime/viewer-mode-map + "\C-m" (function mime-viewer/next-line-content)) + (define-key mime/viewer-mode-map + "\C-\M-m" (function mime-viewer/previous-line-content)) + (define-key mime/viewer-mode-map + "v" (function mime-viewer/play-content)) + (define-key mime/viewer-mode-map + "e" (function mime-viewer/extract-content)) + (define-key mime/viewer-mode-map + "\C-c\C-p" (function mime-viewer/print-content)) + (define-key mime/viewer-mode-map + "x" (function mime-viewer/display-x-face)) + (define-key mime/viewer-mode-map + "a" (function mime-viewer/follow-content)) + (define-key mime/viewer-mode-map + "q" (function mime-viewer/quit)) + (define-key mime/viewer-mode-map + "h" (function mime-viewer/show-summary)) + (define-key mime/viewer-mode-map + "\C-c\C-x" (function mime-viewer/kill-buffer)) + (define-key mime/viewer-mode-map + "<" (function beginning-of-buffer)) + (define-key mime/viewer-mode-map + ">" (function end-of-buffer)) + (define-key mime/viewer-mode-map + "?" (function describe-mode)) + (if mouse-button-2 + (define-key mime/viewer-mode-map + mouse-button-2 (function tm:button-dispatcher)) + ) + (cond (running-xemacs + (define-key mime/viewer-mode-map + mouse-button-3 (function mime-viewer/xemacs-popup-menu)) + ) + ((>= emacs-major-version 19) + (define-key mime/viewer-mode-map [menu-bar mime-view] + (cons mime-viewer/menu-title + (make-sparse-keymap mime-viewer/menu-title))) + (mapcar (function + (lambda (item) + (define-key mime/viewer-mode-map + (vector 'menu-bar 'mime-view (car item)) + (cons (nth 1 item)(nth 2 item)) + ) + )) + (reverse mime-viewer/menu-list) + ) + )) + (use-local-map mime/viewer-mode-map) + (run-hooks 'mime-viewer/define-keymap-hook) + )) + +(defun mime/viewer-mode (&optional mother ctl encoding ibuf obuf + mother-keymap) "Major mode for viewing MIME message. Here is a list of the standard keys for mime/viewer-mode. @@ -777,16 +818,11 @@ M-RET Move to previous line v Decode current content as `play mode' e Decode current content as `extract mode' C-c C-p Decode current content as `print mode' -f Display X-Face +a Followup to current content. +x Display X-Face q Quit button-2 Move to point under the mouse cursor and decode current content as `play mode' - - -Here are all the commands with their current binding, -listed in key order: - -\\{mime/viewer-mode-map} " (interactive) (let ((buf (get-buffer mime/output-buffer-name))) @@ -805,7 +841,7 @@ listed in key order: (progn (setq mime::preview/mother-buffer mother) )) - (use-local-map mime/viewer-mode-map) + (mime-viewer/define-keymap mother-keymap) (setq mime::preview/content-list (nth 1 ret)) (goto-char (let ((ce (mime::preview-content-info/point-max @@ -933,7 +969,7 @@ listed in key order: (mime::content-info/point-min ci) (mime::content-info/point-max ci) ) - (rfc822/get-header-string-except + (std11-header-string-except (concat "^" (apply (function regexp-or) fields) ":") "")))) @@ -944,10 +980,28 @@ listed in key order: (insert str) ) rcnum)) - (setq fields (rfc822/get-field-names) + (setq fields (std11-collect-field-names) rcnum (cdr rcnum)) ) ) + (let ((rest mime-viewer/following-required-fields-list)) + (while rest + (let ((field-name (car rest))) + (or (std11-field-body field-name) + (insert + (format + (concat field-name + ": " + (save-excursion + (set-buffer the-buf) + (set-buffer mime::preview/mother-buffer) + (set-buffer mime::preview/article-buffer) + (std11-field-body field-name) + ) + "\n"))) + )) + (setq rest (cdr rest)) + )) (mime/decode-message-header) ) (funcall (cdr (assq mode mime-viewer/following-method-alist)) @@ -992,7 +1046,7 @@ listed in key order: (i (- (length pcl) 1)) beg) (catch 'tag - (while (>= i 0) + (while (> i 0) (setq beg (mime::preview-content-info/point-min (nth i pcl))) (if (> p beg) (throw 'tag (goto-char beg))