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