tm4.7.0.
[elisp/tm.git] / tm-misc.el
1 ;;;
2 ;;; $Id: tm-misc.el,v 2.1 1994/08/01 05:24:09 morioka Exp $
3 ;;;
4 ;;;   MIME utility for tm-*.el MIME user agent packages
5 ;;;
6 ;;; by Morioka Tomohiko, 1993/11/21
7
8 (provide 'tm-misc)
9
10 (if (< (string-to-int emacs-version) 19)
11     (require 'tl-18)
12   )
13 (require 'tiny-mime)
14 (require 'tm-body)
15
16 (defvar mime/header-decoding-mode t "*Decode MIME header if non-nil.")
17
18 (defun mime/add-header-decoding-mode-to-mode-line ()
19   (or (assq 'mime/header-decoding-mode minor-mode-alist)
20       (setq minor-mode-alist
21             (cons (list 'mime/header-decoding-mode " MIME")
22                   minor-mode-alist))
23       ))
24
25 (defvar mime/body-decoding-mode nil "MIME body decoding mode")
26 (defvar mime/body-decoding-method (function mime/decode-body)
27   "MIME body decoding method to play")
28
29
30 ;;; @ about rightful dividing for multi-octet string
31 ;;;
32 ;; by mol. 1993/9/26
33 (defun rightful-boundary-short-string (str width)
34   (substring str 0 
35              (let ((i 0) (w 0) chr (len (length str)))
36                (catch 'label
37                  (while (< i len)
38                    (setq chr (elt str i))
39                    (setq w (+ w (char-width chr)))
40                    (if (> w width)
41                        (throw 'label i))
42                    (setq i (+ i (char-bytes chr)))
43                    )
44                  i))
45              ))
46
47 ;;; @ functions to check field
48 ;;;
49 (defun mime/exist-encoded-word-in-subject ()
50   (string-match
51    mime/encoded-word-regexp
52    (save-excursion
53      (save-restriction
54        (goto-char (point-min))
55        (if (re-search-forward "^Subject:.*\\(\n\\( \\|\t\\)+.*\\)*" nil t)
56            (buffer-substring (match-beginning 0) (match-end 0))
57          )
58        ))))