summaryrefslogtreecommitdiff
path: root/lisp/mail/mail-utils.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2009-01-10 23:18:08 +0000
committerRichard M. Stallman <rms@gnu.org>2009-01-10 23:18:08 +0000
commit367aa646a557914c550956fe0e736a5a5244d4b1 (patch)
tree819e15840d4be5a09c95ff21778e929648945002 /lisp/mail/mail-utils.el
parent841a91fe0d1a6367b42b99ff3dc6246f08fe40e3 (diff)
downloademacs-367aa646a557914c550956fe0e736a5a5244d4b1.tar.gz
emacs-367aa646a557914c550956fe0e736a5a5244d4b1.tar.bz2
emacs-367aa646a557914c550956fe0e736a5a5244d4b1.zip
(mail-quote-printable-region): New function.
Diffstat (limited to 'lisp/mail/mail-utils.el')
-rw-r--r--lisp/mail/mail-utils.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index 9d7bea7807b..f939f19d06c 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -77,6 +77,26 @@ we add the wrapper characters =?ISO-8859-1?Q?....?=."
"?=")
(concat result (substring string i))))))
+;;;###autoload
+(defun mail-quote-printable-region (beg end &optional wrapper)
+ "Convert the region to the \"quoted printable\" Q encoding.
+If the optional argument WRAPPER is non-nil,
+we add the wrapper characters =?ISO-8859-1?Q?....?=."
+ (interactive "r\nP")
+ (save-match-data
+ (save-excursion
+ (goto-char beg)
+ (save-restriction
+ (narrow-to-region beg end)
+ (while (re-search-forward "[?=\"\200-\377]" nil t)
+ (replace-match (upcase (format "=%02x" (preceding-char)))
+ t t))
+ (when wrapper
+ (goto-char beg)
+ (insert "=?ISO-8859-1?Q?")
+ (goto-char end)
+ (insert "?="))))))
+
(defun mail-unquote-printable-hexdigit (char)
(setq char (upcase char))
(if (>= char ?A)