- ;; There might be a bug in Emacs Mule.
- ;; A space must be inserted before encoding.
- (goto-char beg)
- (insert " ")
- (rfc2047-encode (1+ beg) (1+ end) current))
- (rfc2047-encode beg end current)))
- (setq current (nth 2 word)
- beg (nth 0 word)
- end (nth 1 word))))
- (when current
- (rfc2047-encode beg end current))))
-
-(defun rfc2047-encode-string (string)
+ (setq word (cons (concat
+ (car (nth 1 words)) (caar words)
+ (car word))
+ (cdr word)))
+ (pop words)
+ (pop words))
+ (push (cons (concat (caar words) (car word)) (cdr word))
+ result)
+ (pop words)
+ (setq word (pop words)))
+ (push word result)
+ (setq word (pop words))))
+ result))
+
+(defun rfc2047-encode-region (b e &optional word-chars)
+ "Encode all encodable words in region B to E."
+ (let ((words (rfc2047-dissect-region b e word-chars)) word)
+ (save-restriction
+ (narrow-to-region b e)
+ (delete-region (point-min) (point-max))
+ (while (setq word (pop words))
+ (if (not (cdr word))
+ (insert (car word))
+ (rfc2047-fold-region (gnus-point-at-bol) (point))
+ (goto-char (point-max))
+ (if (> (- (point) (save-restriction
+ (widen)
+ (gnus-point-at-bol))) 76)
+ (insert "\n "))
+ ;; Insert blank between encoded words
+ (if (eq (char-before) ?=) (insert " "))
+ (rfc2047-encode (point)
+ (progn (insert (car word)) (point))
+ (cdr word))))
+ (rfc2047-fold-region (point-min) (point-max)))))
+
+(defun rfc2047-encode-string (string &optional word-chars)