X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=ew-quote.el;h=e95bfb07fd561a53a69fe314c15340334b0d345c;hb=96940805912c6e81f08decf8ef4ff742bbc2e00c;hp=ad7c0344da3b9dfaeae4849fa5f32904e27b3750;hpb=309cbd9e0cff0d8ae89efac3ac7c8e485927a4d5;p=elisp%2Fflim.git diff --git a/ew-quote.el b/ew-quote.el index ad7c034..e95bfb0 100644 --- a/ew-quote.el +++ b/ew-quote.el @@ -18,20 +18,6 @@ ;; B : token. ;; C : encoded-text. -(defconst ew-quoting-char ?+) -(defconst ew-quoting-chars-regexp - (concat (regexp-quote (char-to-string ew-quoting-char)) "*")) - -(defconst ew-type2-regexp - (concat (regexp-quote "=?") - "\\(" ew-token-regexp "\\)" - (regexp-quote "?") - "\\(" ew-token-regexp "\\)" - (regexp-quote "?") - "\\(" ew-encoded-text-regexp "\\)" - (regexp-quote "?") - "\\'")) - ;;; (defun ew-quoting-char-seq (num) @@ -150,30 +136,31 @@ "?=")) (defun ew-encode-crlf (str) - (let ((sstart 0) - (mstart 0) - (end (length str)) result ms me) - (while (string-match "\\(\r\n\\)+" str mstart) - (setq ms (match-beginning 0) - me (match-end 0)) - (setq mstart me) - (when (and (< me end) - (member (aref str me) '(?\t ?\ ))) - (setq me (- me 2))) - (when (< ms me) + (if ew-remove-bare-crlf + (ew-crlf-line-convert str nil nil (lambda (nl) "")) + (let ((sstart 0) + (mstart 0) + (end (length str)) result ms me) + (while (string-match "\\(\r\n\\)+" str mstart) + (setq ms (match-beginning 0) + me (match-end 0)) + (setq mstart me) + (when (and (< me end) + (member (aref str me) '(?\t ?\ ))) + (setq me (- me 2))) + (when (< ms me) + (setq result (ew-rcons* result + (substring str sstart ms) + "=?+US-ASCII?Q?") + sstart me) + (while (< ms me) + (setq result (ew-rcons* result "=0D=0A") + ms (+ ms 2))) + (setq result (ew-rcons* result "?=")))) + (when (< sstart end) (setq result (ew-rcons* result - (substring str sstart ms) - "=?+US-ASCII?Q?") - sstart me) - (while (< ms me) - (setq result (ew-rcons* result "=0D=0A") - ms (+ ms 2))) - (setq result (ew-rcons* result "?=")))) - (when (< sstart end) - (setq result (ew-rcons* result - (substring str sstart)))) - (apply 'concat (nreverse result)))) - + (substring str sstart)))) + (apply 'concat (nreverse result))))) '( (ew-quote-concat "aaa=?A?B?C?=ccc") ;"aaa=?A?B?C?=ccc"