+;;;
+
+(defun ew-decode-field-interest-option-order (field-name field-body)
+ (let* ((ew-decode-sticked-encoded-word nil)
+ (ew-decode-quoted-encoded-word nil)
+ (ew-ignore-75bytes-limit nil)
+ (ew-ignore-76bytes-limit nil)
+ (ew-permit-sticked-comment nil)
+ (ew-permit-sticked-special nil)
+ (ew-permit-null-encoded-text nil)
+ (decoded (make-vector (lsh 1 (length ew-option-list)) nil))
+ tmp
+ i j k
+ )
+ (aset decoded 0 (list 0 (ew-decode-field field-name field-body)))
+ (setq i 1)
+ (while (< i (length decoded))
+ (ew-restore-boolean-options i)
+ (setq tmp (ew-decode-field field-name field-body))
+ (setq j 0)
+ (while (<= (lsh 1 j) i)
+ (unless (zerop (logand i (lsh 1 j)))
+ (setq k (logand i (lognot (lsh 1 j))))
+ (when (or (not (aref decoded i))
+ (< (car (aref decoded i))
+ (+ (if (equal (cadr (aref decoded k)) tmp) 0 1)
+ (car (aref decoded k)))))
+ (aset decoded i
+ (ew-cons*
+ (+ (if (equal (cadr (aref decoded k)) tmp) 0 1)
+ (car (aref decoded k)))
+ tmp
+ (nth j ew-option-list)
+ (cddr (aref decoded k))))))
+ (setq j (1+ j)))
+ (setq i (1+ i)))
+ (reverse (cddr (aref decoded (1- (length decoded)))))))
+
+(defun ew-decode-field-test (field-name field-body)
+ (interactive
+ (list
+ (read-string "field-name:" (or (get-text-property (point) 'original-field-name)
+ (save-excursion
+ (end-of-line)
+ (and
+ (re-search-backward "^\\([!-9;-~]+\\):" nil t)
+ (match-string 1)))
+ ""))
+ (read-string "field-body:" (or (get-text-property (point) 'original-field-body)
+ (save-excursion
+ (end-of-line)
+ (and
+ (re-search-backward "^\\([!-9;-~]+\\):" nil t)
+ (progn
+ (goto-char (match-end 0))
+ (looking-at ".*\\(\n[ \t].*\\)*")
+ (ew-lf-crlf-to-crlf (match-string 0)))))
+ ""))))
+ (with-output-to-temp-buffer "*DOODLE*"
+ (save-excursion
+ (set-buffer standard-output)
+ (let ((ew-decode-sticked-encoded-word nil)
+ (ew-decode-quoted-encoded-word nil)
+ (ew-ignore-75bytes-limit nil)
+ (ew-ignore-76bytes-limit nil)
+ (ew-permit-sticked-comment nil)
+ (ew-permit-sticked-special nil)
+ (ew-permit-null-encoded-text nil)
+ (options
+ '(ew-ignore-76bytes-limit
+ ew-ignore-75bytes-limit
+ ew-permit-sticked-special
+ ew-permit-sticked-comment
+ ew-decode-sticked-encoded-word
+ ew-decode-quoted-encoded-word
+ ew-permit-null-encoded-text
+ ))
+ d1 d2)
+ (when (<= 16 (prefix-numeric-value current-prefix-arg))
+ (setq options (ew-decode-field-interest-option-order field-name field-body)))
+ (setq d1 (ew-decode-field-no-cache field-name field-body))
+ (insert field-name ":" field-body "\n"
+ (make-string 76 ?-) "\n"
+ field-name ":" d1 "\n")
+ (while options
+ (set (car options) t)
+ (insert (format "-- %s -> t\n" (car options)))
+ (setq d2 (ew-decode-field-no-cache field-name field-body))
+ (unless (equal d1 d2)
+ (insert field-name ":" d2 "\n")
+ (setq d1 d2))
+ (setq options (cdr options)))
+ (insert (make-string 76 ?-) "\n")
+ (when (<= 4 (prefix-numeric-value current-prefix-arg))
+ (mapcar
+ (lambda (frag)
+ (insert (format "%-15s %S\n"
+ (substring (symbol-name (get frag 'type)) 3)
+ (symbol-name frag)))
+ nil)
+ (ew-frag-list (ew-analyze-field-to-decode field-name field-body)))
+ (insert (make-string 76 ?-) "\n"))))))
+
+;;;
+