tm 4.8.3.
[elisp/tm.git] / tm-misc.el
1 ;;;
2 ;;; $Id: tm-misc.el,v 3.0 1994/08/31 07:15:08 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
15 (defvar mime/header-decoding-mode t "*Decode MIME header if non-nil.")
16
17 (defun mime/add-header-decoding-mode-to-mode-line ()
18   (or (assq 'mime/header-decoding-mode minor-mode-alist)
19       (setq minor-mode-alist
20             (cons (list 'mime/header-decoding-mode " MIME")
21                   minor-mode-alist))
22       ))
23
24
25 ;;; @ about rightful dividing for multi-octet string
26 ;;;
27 ;; by mol. 1993/9/26
28 (defun rightful-boundary-short-string (str width)
29   (substring str 0 
30              (let ((i 0) (w 0) chr (len (length str)))
31                (catch 'label
32                  (while (< i len)
33                    (setq chr (elt str i))
34                    (setq w (+ w (char-width chr)))
35                    (if (> w width)
36                        (throw 'label i))
37                    (setq i (+ i (char-bytes chr)))
38                    )
39                  i))
40              ))
41
42
43 ;;; @ functions to check field
44 ;;;
45 (defun mime/exist-encoded-word-in-subject ()
46   (string-match
47    mime/encoded-word-regexp
48    (save-excursion
49      (save-restriction
50        (goto-char (point-min))
51        (if (re-search-forward "^Subject:.*\\(\n\\( \\|\t\\)+.*\\)*" nil t)
52            (buffer-substring (match-beginning 0) (match-end 0))
53          )
54        ))))