annotate lisp/gnus/qp.el @ 35556:8fcff22c51b7

(reset-language-environment): Reset coding-category-utf-8 to mule-utf-8.
author Kenichi Handa <handa@m17n.org>
date Thu, 25 Jan 2001 13:07:32 +0000
parents f04f551e94ce
children a670d2680870
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; qp.el --- Quoted-Printable functions
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
2
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
6 ;; Keywords: mail, extensions
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
7
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
27 ;; Functions for encoding and decoding quoted-printable text as
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
28 ;; defined in RFC 2045.
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
29
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31
32504
651afe016895 Require mm-util.
Dave Love <fx@gnu.org>
parents: 32462
diff changeset
32 (require 'mm-util)
651afe016895 Require mm-util.
Dave Love <fx@gnu.org>
parents: 32462
diff changeset
33 (eval-when-compile (defvar mm-use-ultra-safe-encoding))
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
34
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
35 (defun quoted-printable-decode-region (from to &optional coding-system)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
36 "Decode quoted-printable in the region between FROM and TO, per RFC 2045.
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
37 If CODING-SYSTEM is non-nil, decode bytes into characters with that
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
38 coding-system."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 (interactive "r")
32462
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
40 (unless (mm-coding-system-p coding-system) ; e.g. `ascii' from Gnus
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
41 (setq coding-system nil))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 (save-restriction
32462
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
44 ;; RFC 2045: ``An "=" followed by two hexadecimal digits, one
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
45 ;; or both of which are lowercase letters in "abcdef", is
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
46 ;; formally illegal. A robust implementation might choose to
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
47 ;; recognize them as the corresponding uppercase letters.''
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
48 (let ((case-fold-search t))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (narrow-to-region from to)
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
50 ;; Do this in case we're called from Gnus, say, in a buffer
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
51 ;; which already contains non-ASCII characters which would
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
52 ;; then get doubly-decoded below.
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
53 (if coding-system
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
54 (mm-encode-coding-region (point-min) (point-max) coding-system))
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
55 (goto-char (point-min))
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
56 (while (and (skip-chars-forward "^=" to)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
57 (not (eobp)))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
58 (cond ((eq (char-after (1+ (point))) ?\n)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
59 (delete-char 2))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
60 ((looking-at "=[0-9A-F][0-9A-F]")
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
61 (let ((byte (string-to-int (buffer-substring (1+ (point))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
62 (+ 3 (point)))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
63 16)))
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
64 (insert byte)
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
65 (delete-char 3)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
66 (unless (eq byte ?=)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
67 (backward-char))))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
68 (t
34025
07dcbc7e702f (quoted-printable-decode-region): Use error, not message
Dave Love <fx@gnu.org>
parents: 32504
diff changeset
69 (error "Malformed quoted-printable text")
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
70 (forward-char)))))
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
71 (if coding-system
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
72 (mm-decode-coding-region (point-min) (point-max) coding-system)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
74 (defun quoted-printable-decode-string (string &optional coding-system)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
75 "Decode the quoted-printable encoded STRING and return the result.
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
76 If CODING-SYSTEM is non-nil, decode the region with coding-system."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (insert string)
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
79 (quoted-printable-decode-region (point-min) (point-max) coding-system)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (buffer-string)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (defun quoted-printable-encode-region (from to &optional fold class)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
83 "Quoted-printable encode the region between FROM and TO per RFC 2045.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
85 If FOLD, fold long lines at 76 characters (as required by the RFC).
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
86 If CLASS is non-nil, translate the characters matched by that class in
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
87 the form expected by `skip-chars-forward'.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
89 If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 encode lines starting with \"From\"."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (interactive "r")
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
92 (unless class
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
93 ;; Avoid using 8bit characters. = is \075.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
94 ;; Equivalent to "^\000-\007\013\015-\037\200-\377="
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
95 (setq class "\010-\012\014\040-\074\076-\177"))
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
96 (if (fboundp 'string-as-multibyte)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
97 (setq class (string-as-multibyte class)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (narrow-to-region from to)
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
101 (mm-with-unibyte-current-buffer-mule4
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
102 ;; Fixme: what should this do in XEmacs/Mule?
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
103 (if (fboundp 'find-charset-region) ; else XEmacs, non-Mule
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
104 (if (delq 'unknown ; Emacs 20 unibyte
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
105 (delq 'eight-bit-graphic ; Emacs 21
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
106 (delq 'eight-bit-control
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
107 (delq 'ascii
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
108 (find-charset-region from to)))))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
109 (error "Multibyte character in QP encoding region")))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
110 ;; Encode all the non-ascii and control characters.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
111 (goto-char (point-min))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
112 (while (and (skip-chars-forward class)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
113 (not (eobp)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (insert
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (prog1
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
116 (format "=%02X" (char-after))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
117 (delete-char 1))))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
118 ;; Encode white space at the end of lines.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
119 (goto-char (point-min))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
120 (while (re-search-forward "[ \t]+$" nil t)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
121 (goto-char (match-beginning 0))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
122 (while (not (eolp))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
123 (insert
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
124 (prog1
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
125 (format "=%02X" (char-after))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
126 (delete-char 1)))))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
127 (let ((mm-use-ultra-safe-encoding
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
128 (and (boundp 'mm-use-ultra-safe-encoding)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
129 mm-use-ultra-safe-encoding)))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
130 (when (or fold mm-use-ultra-safe-encoding)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
131 ;; Fold long lines.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
132 (let ((tab-width 1)) ; HTAB is one character.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
133 (goto-char (point-min))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
134 (while (not (eobp))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
135 ;; In ultra-safe mode, encode "From " at the beginning
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
136 ;; of a line.
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
137 (when mm-use-ultra-safe-encoding
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
138 (beginning-of-line)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
139 (if (looking-at "From ")
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
140 (replace-match "From=20" nil t)
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
141 (if (looking-at "-")
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
142 (replace-match "=2D" nil t))))
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
143 (end-of-line)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
144 (while (> (current-column) 76) ; tab-width must be 1.
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
145 (beginning-of-line)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
146 (forward-char 75) ; 75 chars plus an "="
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
147 (search-backward "=" (- (point) 2) t)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
148 (insert "=\n")
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
149 (end-of-line))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
150 (unless (eobp)
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
151 (forward-line))))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (defun quoted-printable-encode-string (string)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
154 "Encode the STRING as quoted-printable and return the result."
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
155 (with-temp-buffer
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (insert string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (quoted-printable-encode-region (point-min) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (buffer-string)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (provide 'qp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
162 ;;; qp.el ends here