2 (require 'eword-decode)
5 (eval-when-compile (require 'cl))
7 (defun ew-gnus-structured-field-decoder (string)
8 (if (fboundp 'ew-decode-field)
9 (let ((ew-ignore-76bytes-limit t)
10 (ew-default-mime-charset default-mime-charset))
12 (ew-cut-cr-lf (ew-decode-field "From" (ew-lf-crlf-to-crlf string)))
14 (message "gnus-structured-field-decoder error: %s" string)
15 (decode-mime-charset-string string 'x-ctext))))
16 (eword-decode-and-unfold-structured-field-body string)))
18 (defun ew-gnus-unstructured-field-decoder (string)
19 (if (fboundp 'ew-decode-field)
20 (let ((ew-ignore-76bytes-limit t)
21 (ew-default-mime-charset default-mime-charset))
23 (ew-cut-cr-lf (ew-decode-field "Subject" (ew-lf-crlf-to-crlf string)))
25 (message "gnus-unstructured-field-decoder error: %s" string)
26 (decode-mime-charset-string string 'x-ctext))))
27 (eword-decode-unstructured-field-body (std11-unfold-string string) 'must-unfold)))
29 (defun ew-mime-update-field-decoder-cache (field mode)
32 (lexical-let ((field-name (symbol-name field)))
33 (lambda (field-body &optional start-column max-column must-unfold)
34 (setq field-body (ew-lf-to-crlf field-body))
35 (let ((res (ew-crlf-to-lf
36 (ew-decode-field field-name field-body))))
39 (list 'original-field-name field-name
40 'original-field-body field-body)
44 (lexical-let ((field-name (symbol-name field)))
45 (lambda (field-body &optional start-column max-column must-unfold)
46 (setq field-body (ew-lf-to-crlf field-body))
47 (let ((res (ew-crlf-to-lf
49 (ew-decode-field field-name field-body)
51 (or max-column fill-column)))))
54 (list 'original-field-name field-name
55 'original-field-body field-body)
59 (lexical-let ((field-name (symbol-name field)))
60 (lambda (field-body &optional start-column max-column must-unfold)
61 (setq field-body (ew-lf-to-crlf field-body))
62 (let ((res (ew-crlf-to-lf
64 (ew-decode-field field-name field-body)))))
67 (list 'original-field-name field-name
68 'original-field-body field-body)
72 (lexical-let ((field-name (symbol-name field)))
73 (lambda (field-body &optional start-column max-column must-unfold)
74 (setq field-body (ew-lf-to-crlf field-body))
76 (let ((ew-ignore-76bytes-limit t))
77 (let ((res (ew-crlf-to-lf
79 (ew-decode-field field-name field-body)))))
82 (list 'original-field-name field-name
83 'original-field-body field-body)
88 (mime-update-field-decoder-cache field mode fun)))
90 (setq mime-update-field-decoder-cache 'ew-mime-update-field-decoder-cache)