* DOODLE-TIPS: Add a notice about EVALARGS.
[elisp/flim.git] / ew-var.el
1 (provide 'ew-var)
2
3 ;;; user customizable variables.
4
5 (defvar ew-decode-sticked-encoded-word nil)
6 (defvar ew-decode-quoted-encoded-word nil)
7 (defvar ew-ignore-75bytes-limit nil)
8 (defvar ew-ignore-76bytes-limit nil)
9 (defvar ew-permit-sticked-comment nil)
10 (defvar ew-permit-sticked-special nil)
11 (defvar ew-permit-null-encoded-text nil) ; affect when loading time.
12
13 (defvar ew-remove-bare-crlf nil)
14 (defvar ew-default-mime-charset 'x-ctext)
15
16 ;;;
17 (defvar ew-decode-field-syntax-alist
18 '((from                 ew-scan-unibyte-std11 . ew:tag-mailbox+)
19   (sender               ew-scan-unibyte-std11 . ew:tag-mailbox)
20   (to                   ew-scan-unibyte-std11 . ew:tag-address+)
21   (resent-to            ew-scan-unibyte-std11 . ew:tag-address+)
22   (cc                   ew-scan-unibyte-std11 . ew:tag-address+)
23   (resent-cc            ew-scan-unibyte-std11 . ew:tag-address+)
24   (bcc                  ew-scan-unibyte-std11 . ew:tag-address*)
25   (resent-bcc           ew-scan-unibyte-std11 . ew:tag-address*)
26   (message-id           ew-scan-unibyte-std11)
27   (resent-message-id    ew-scan-unibyte-std11)
28   (in-reply-to          ew-scan-unibyte-std11 . ew:tag-phrase-msg-id*)
29   (references           ew-scan-unibyte-std11 . ew:tag-phrase-msg-id*)
30   (keywords             ew-scan-unibyte-std11 . ew:tag-phrase*)
31   (subject              ew-scan-unibyte-unstructured)
32   (comments             ew-scan-unibyte-unstructured)
33   (encrypted            ew-scan-unibyte-std11)
34   (date                 ew-scan-unibyte-std11)
35   (reply-to             ew-scan-unibyte-std11 . ew:tag-address+)
36   (received             ew-scan-unibyte-std11)
37   (resent-reply-to      ew-scan-unibyte-std11 . ew:tag-address+)
38   (resent-from          ew-scan-unibyte-std11 . ew:tag-mailbox+)
39   (resent-sender        ew-scan-unibyte-std11 . ew:tag-mailbox)
40   (resent-date          ew-scan-unibyte-std11)
41   (return-path          ew-scan-unibyte-std11)
42   (mime-version         ew-scan-unibyte-std11)
43   (content-type         ew-scan-unibyte-mime)
44   (content-transfer-encoding    ew-scan-unibyte-mime)
45   (content-id           ew-scan-unibyte-std11)
46   (content-description  ew-scan-unibyte-unstructured)
47   (content-disposition  ew-scan-unibyte-mime)
48   (approved             ew-scan-unibyte-std11 . ew:tag-address+)
49   (newsgroups           ew-scan-unibyte-none)
50   (path                 ew-scan-unibyte-none)
51   (lines                ew-scan-unibyte-none)
52   (xref                 ew-scan-unibyte-none)
53   (followup-to          ew-scan-unibyte-none)
54 ))
55
56 (defvar ew-decode-field-default-syntax '(ew-scan-unibyte-unstructured))
57
58 (defvar ew-parse-error-sit-for-seconds 0)
59
60 ;;; constants.
61
62 (defconst ew-token-regexp "[-!#-'*+0-9A-Z^-~]+")
63 (defconst ew-encoded-text-regexp
64   (if ew-permit-null-encoded-text
65       "[!->@-~]*"
66     "[!->@-~]+"))
67
68 (defconst ew-encoded-word-regexp
69   (concat (regexp-quote "=?")
70           "\\(" ew-token-regexp "\\)"
71           (regexp-quote "?")
72           "\\(" ew-token-regexp "\\)"
73           (regexp-quote "?")
74           "\\(" ew-encoded-text-regexp "\\)"
75           (regexp-quote "?=")))
76
77 (defconst ew-anchored-encoded-word-regexp
78   (concat "\\`" ew-encoded-word-regexp "\\'"))
79
80 (defconst ew-b-regexp
81   (eval-when-compile
82     (concat "\\`\\("
83             "[A-Za-z0-9+/]"
84             "[A-Za-z0-9+/]"
85             "[A-Za-z0-9+/]"
86             "[A-Za-z0-9+/]"
87             "\\)*"
88             "\\("
89             "[A-Za-z0-9+/]"
90             "[A-Za-z0-9+/]"
91             "\\(==\\|[A-Za-z0-9+/]=\\)"
92             "\\)?"
93             "\\'")))
94
95 (defconst ew-q-regexp
96   "\\`\\([^=?]\\|=[0-9A-Fa-f][0-9A-Fa-f]\\)*\\'")
97
98 (defconst ew-quoting-char ?+)
99 (defconst ew-quoting-chars-regexp
100   (concat (regexp-quote (char-to-string ew-quoting-char)) "*"))
101
102 (defconst ew-type2-regexp
103   (concat (regexp-quote "=?")
104           "\\(" ew-token-regexp "\\)"
105           (regexp-quote "?")
106           "\\(" ew-token-regexp "\\)"
107           (regexp-quote "?")
108           "\\(" ew-encoded-text-regexp "\\)"
109           (regexp-quote "?")
110           "\\'"))
111
112 (defconst ew-byte-decoder-alist
113   '(("B" . ew-decode-b)
114     ("Q" . ew-decode-q)))
115
116 (defconst ew-byte-checker-alist
117   '(("B" . ew-b-check)
118     ("Q" . ew-q-check)))
119
120 ;;; utilities for variables.
121
122 (defun ew-dynamic-options ()
123   (cons
124    ew-default-mime-charset
125    (logior
126     (if ew-decode-sticked-encoded-word 1 0)
127     (if ew-decode-quoted-encoded-word 2 0)
128     (if ew-ignore-75bytes-limit 4 0)
129     (if ew-ignore-76bytes-limit 8 0)
130     (if ew-permit-sticked-comment 16 0)
131     (if ew-permit-sticked-special 32 0)
132     (if ew-remove-bare-crlf 64 0)
133     (if ew-permit-null-encoded-text 128 0)
134     )))