This commit was generated by cvs2svn to compensate for changes in r542,
[elisp/tm.git] / gnus / tm-ognus.el
1 ;;;
2 ;;; tm-ognus.el --- tm-gnus module for GNUS 3.* and 4.*
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: tm-ognus.el,v 7.1 1995/10/17 16:56:12 morioka Exp $
10 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
11 ;;;
12 ;;; This file is part of tm (Tools for MIME).
13 ;;;
14
15 (require 'emu)
16 (require 'gnus)
17
18 (autoload 'mime/decode-message-header
19   "tm-ew-d" "Decode MIME encoded-words in message header." t)
20 (autoload 'mime-eword/decode-string
21   "tm-ew-d" "Decode MIME encoded-words in string." t)
22
23
24 (defvar tm-gnus/decoding-mode t "*Decode MIME header if non-nil.")
25
26 (defun tm-gnus/add-decoding-mode-to-mode-line ()
27   (or (assq 'tm-gnus/decoding-mode minor-mode-alist)
28       (setq minor-mode-alist
29             (cons (list 'tm-gnus/decoding-mode " MIME")
30                   minor-mode-alist))
31       ))
32
33
34 ;;; @ change MIME encoded-word decoding mode, decoding or non decoding.
35 ;;;
36
37 (defun tm-gnus/set-decoding-mode (arg)
38   "Set MIME encoded-word processing.
39 With arg, turn MIME encoded-word processing on iff arg is positive."
40   (setq tm-gnus/decoding-mode arg)
41   (setq gnus-have-all-headers (not gnus-have-all-headers))
42   (gnus-summary-select-article (not gnus-have-all-headers) t)
43   )
44
45 (defun tm-gnus/toggle-decoding-mode ()
46   "Toggle MIME encoded-word processing.
47 With arg, turn MIME encoded-word processing on iff arg is positive."
48   (interactive)
49   (tm-gnus/set-decoding-mode (not tm-gnus/decoding-mode))
50   )
51
52
53 ;;; @ to decode subjects in mode-line
54 ;;;
55 ;; This function imported from gnus.el.
56 ;;
57 ;; New implementation in gnus 3.14.3
58 ;;
59
60 (defun tm-gnus/article-set-mode-line ()
61   "Set Article mode line string.
62 If you don't like it, define your own gnus-article-set-mode-line."
63   (let ((maxlen 15)                     ;Maximum subject length
64         (subject
65          (if gnus-current-headers
66              (mime-eword/decode-string
67               (nntp-header-subject gnus-current-headers))
68            "")
69          ))
70     ;; The value must be a string to escape %-constructs because of subject.
71     (setq mode-line-buffer-identification
72           (format "GNUS: %s%s %s%s%s"
73                   gnus-newsgroup-name
74                   (if gnus-current-article
75                       (format "/%d" gnus-current-article) "")
76                   (rightful-boundary-short-string subject
77                                                   (min (string-width subject)
78                                                        maxlen))
79                   (if (> (string-width subject) maxlen) "..." "")
80                   (make-string (max 0 (- 17 (string-width subject))) ? )
81                   )))
82   (set-buffer-modified-p t))
83
84
85 ;;; @ to decode subjects in Summary buffer
86 ;;;
87
88 (defun tm-gnus/decode-summary-subjects ()
89   (mapcar (function
90            (lambda (header)
91              (let ((subj (or (gnus-header-subject header) "")))
92                (nntp-set-header-subject
93                 header (mime-eword/decode-string subj))
94                )))
95           gnus-newsgroup-headers)
96   )
97
98
99 ;;; @ end
100 ;;;
101
102 (provide 'tm-ognus)