;;; ;;; tm-sgnus.el --- tm-gnus module for September Gnus ;;; ;;; Copyright (C) 1995 Free Software Foundation, Inc. ;;; Copyright (C) 1995 MORIOKA Tomohiko ;;; ;;; Author: MORIOKA Tomohiko ;;; Maintainer: MORIOKA Tomohiko ;;; Created: 1995/09/24 ;;; Version: $Revision: 7.26 $ ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word ;;; ;;; 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. ;;; ;;; Code: (require 'tl-str) (require 'tl-list) (require 'tl-misc) (require 'tm-view) (require 'gnus) (require 'tm-gd5) ;;; @ version ;;; (defconst tm-gnus/RCS-ID "$Id: tm-sgnus.el,v 7.26 1995/12/20 12:49:27 morioka Exp $") (defconst tm-gnus/version (concat (get-version-string tm-gnus/RCS-ID) " for September")) ;;; @ variables ;;; (defvar tm-gnus/automatic-mime-preview t "*If non-nil, show MIME processed article. This variable is set to `gnus-show-mime'.") (setq gnus-show-mime tm-gnus/automatic-mime-preview) ;;; @ command functions ;;; (defun tm-gnus/view-message (arg) "MIME decode and play this message." (interactive "P") (let ((gnus-break-pages nil)) (gnus-summary-select-article t t) ) (pop-to-buffer gnus-original-article-buffer t) (let (buffer-read-only) (if (text-property-any (point-min) (point-max) 'invisible t) (remove-text-properties (point-min) (point-max) gnus-hidden-properties) )) (mime/viewer-mode nil nil nil gnus-original-article-buffer gnus-article-buffer) ) (defun tm-gnus/summary-scroll-down () "Scroll down one line current article." (interactive) (gnus-summary-scroll-up -1) ) (defun tm-gnus/summary-toggle-header (&optional arg) (interactive "P") (if tm-gnus/automatic-mime-preview (save-excursion (set-buffer gnus-article-buffer) (let* ((buffer-read-only nil) (inhibit-point-motion-hooks t) (hidden (text-property-any (goto-char (point-min)) (search-forward "\n\n") 'invisible t)) e) (goto-char (point-min)) (when (search-forward "\n\n" nil t) (delete-region (point-min) (1- (point)))) (goto-char (point-min)) (save-excursion (set-buffer gnus-original-article-buffer) (goto-char (point-min)) (setq e (1- (or (search-forward "\n\n" nil t) (point-max))))) (insert-buffer-substring gnus-original-article-buffer 1 e) (if (or (not hidden) (and (numberp arg) (< arg 0))) (tm-gnus/content-header-filter) (mime/decode-message-header)) (let ((gnus-inhibit-hiding t)) (run-hooks 'gnus-article-display-hook)) )) (gnus-summary-toggle-header arg)) ) (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message)) (define-key gnus-summary-mode-map "\e\r" (function tm-gnus/summary-scroll-down)) (define-key gnus-summary-mode-map "t" (function tm-gnus/summary-toggle-header)) ;;; @ for tm-view ;;; (defun mime-viewer/quitting-method-for-sgnus () (if (not gnus-show-mime) (mime-viewer/kill-buffer)) (delete-other-windows) (gnus-article-show-summary) (if (or (not gnus-show-mime) (null gnus-have-all-headers)) (gnus-summary-select-article nil t) )) (call-after-loaded 'tm-view (lambda () (set-alist 'mime-viewer/quitting-method-alist 'gnus-original-article-mode (function mime-viewer/quitting-method-for-sgnus)) (set-alist 'mime-viewer/show-summary-method 'gnus-original-article-mode (function mime-viewer/quitting-method-for-sgnus)) )) ;;; @ for tm-partial ;;; (defun tm-gnus/partial-preview-function () (tm-gnus/view-message (gnus-summary-article-number)) ) (call-after-loaded 'tm-partial (lambda () (set-atype 'mime/content-decoding-condition '((type . "message/partial") (method . mime-article/grab-message/partials) (major-mode . gnus-original-article-mode) (summary-buffer-exp . gnus-summary-buffer) )) (set-alist 'tm-partial/preview-article-method-alist 'gnus-original-article-mode 'tm-gnus/partial-preview-function) )) ;;; @ article filter ;;; (defun tm-gnus/article-reset-variable () (setq tm-gnus/automatic-mime-preview nil) ) (add-hook 'gnus-article-prepare-hook 'tm-gnus/article-reset-variable) (defun tm-gnus/preview-article () (make-local-variable 'tm:mother-button-dispatcher) (setq tm:mother-button-dispatcher (function gnus-article-push-button)) (mime/viewer-mode nil nil nil gnus-original-article-buffer gnus-article-buffer) (setq tm-gnus/automatic-mime-preview t) (run-hooks 'tm-gnus/article-prepare-hook) ) (setq gnus-show-mime-method (function tm-gnus/preview-article)) (defun tm-gnus/article-decode-encoded-word () (mime/decode-message-header) (run-hooks 'tm-gnus/article-prepare-hook) ) (setq gnus-decode-encoded-word-method (function tm-gnus/article-decode-encoded-word)) (or (fboundp 'tm::gnus-article-hide-headers-if-wanted) (fset 'tm::gnus-article-hide-headers-if-wanted (symbol-function 'gnus-article-hide-headers-if-wanted)) ) (defun gnus-article-hide-headers-if-wanted () (or tm-gnus/automatic-mime-preview (tm::gnus-article-hide-headers-if-wanted) )) (defun tm-gnus/preview-cut-header () (save-restriction (let ((ignored mime-viewer/ignored-field-regexp) (visible mime-viewer/visible-field-regexp) want-list beg) (goto-char (point-min)) (narrow-to-region (point) (progn (search-forward "\n\n" nil t) (forward-line -1) (point))) (goto-char (point-min)) (while (re-search-forward "^[^ \t]*:" nil t) (beginning-of-line) ;; We add the headers we want to keep to a list and delete ;; them from the buffer. (if (or (and visible (looking-at visible)) (and ignored (not (looking-at ignored)))) (progn (push (buffer-substring (setq beg (point)) (progn (forward-line 1) ;; Be sure to get multi-line headers... (re-search-forward "^[^ \t]*:" nil t) (beginning-of-line) (point))) want-list) (delete-region beg (point))) (forward-line 1))) ;; Sort the headers that we want to display. (setq want-list (sort want-list 'gnus-article-header-less)) (goto-char (point-min)) (while want-list (insert (pop want-list))) (add-text-properties (point) (point-max) gnus-hidden-properties) ))) (defun tm-gnus/content-header-filter () (tm-gnus/preview-cut-header) (mime/decode-message-header) ) ;;; @ set up ;;; (set-alist 'mime-viewer/content-header-filter-alist 'gnus-original-article-mode (function tm-gnus/content-header-filter)) ;;; @ for BBDB ;;; (defun tm-gnus/bbdb-setup () (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook) (progn (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record) (add-hook 'tm-gnus/article-prepare-hook 'bbdb/gnus-update-record) ))) (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t) (tm-gnus/bbdb-setup) ;;; @ end ;;; (provide 'tm-sgnus)