annotate lisp/gnus/qp.el @ 90104:a01e7a9f1659

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14 Update unicode-branch version numbers and ChangeLog file names 2005-02-12 Miles Bader <miles@gnu.org> * etc/TODO, etc/PROBLEMS, etc/NEWS: Replace references to Emacs version "22" with "23". 2005-02-12 Miles Bader <miles@gnu.org> * lisp/version.el (emacs-version): Change to "23.0.0". * lisp/descr-text.el (describe-char-unidata-list): Replace references to Emacs version "22" with "23". * lisp/emacs-lisp/bytecomp.el (byte-compile-fix-header) (byte-compile-insert-header): Likewise. * lisp/international/mule.el (charset-list, set-coding-priority) (ignore-relative-composition): Likewise. * lisp/international/mule-util.el (detect-coding-with-priority): Likewise. * lisp/international/mule-diag.el: Likewise. * lisp/international/mule-cmds.el (language-info-custom-alist): Likewise. * lisp/international/codepage.el (codepage-setup): Likewise. 2005-02-13 Miles Bader <miles@gnu.org> Rename unicode-branch-specific ChangeLog files to "ChangeLog.unicode" from "ChangeLog.22"
author Miles Bader <miles@gnu.org>
date Mon, 14 Feb 2005 03:40:07 +0000
parents cce1c0ee76ee
children 146c086df160
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
90104
a01e7a9f1659 Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents: 89971
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
31717
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
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
35 ;;;###autoload
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
36 (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
37 "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
38 If CODING-SYSTEM is non-nil, decode bytes into characters with that
43737
4f7c660e6029 * qp.el (quoted-printable-decode-region): Doc addition.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38103
diff changeset
39 coding-system.
4f7c660e6029 * qp.el (quoted-printable-decode-region): Doc addition.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38103
diff changeset
40
4f7c660e6029 * qp.el (quoted-printable-decode-region): Doc addition.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38103
diff changeset
41 Interactively, you can supply the CODING-SYSTEM argument
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
42 with \\[universal-coding-system-argument].
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
43
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
44 The CODING-SYSTEM argument is a historical hangover and is deprecated.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
45 QP encodes raw bytes and should be decoded into raw bytes. Decoding
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
46 them into characters should be done separately."
38103
282970d20daa (quoted-printable-decode-region): If called interactively,
Eli Zaretskii <eliz@gnu.org>
parents: 35931
diff changeset
47 (interactive
282970d20daa (quoted-printable-decode-region): If called interactively,
Eli Zaretskii <eliz@gnu.org>
parents: 35931
diff changeset
48 ;; Let the user determine the coding system with "C-x RET c".
282970d20daa (quoted-printable-decode-region): If called interactively,
Eli Zaretskii <eliz@gnu.org>
parents: 35931
diff changeset
49 (list (region-beginning) (region-end) coding-system-for-read))
32462
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
50 (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
51 (setq coding-system nil))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (save-restriction
32462
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
54 ;; 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
55 ;; 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
56 ;; formally illegal. A robust implementation might choose to
7a39fdec7aac (quoted-printable-decode-region): Avoid invalid
Dave Love <fx@gnu.org>
parents: 32211
diff changeset
57 ;; 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
58 (let ((case-fold-search t))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 (narrow-to-region from to)
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
60 ;; 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
61 ;; 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
62 ;; then get doubly-decoded below.
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
63 (if coding-system
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
64 (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
65 (goto-char (point-min))
35619
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
66 (while (and (skip-chars-forward "^=")
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
67 (not (eobp)))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
68 (cond ((eq (char-after (1+ (point))) ?\n)
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
69 (delete-char 2))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
70 ((looking-at "=[0-9A-F][0-9A-F]")
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
71 (let ((byte (string-to-int (buffer-substring (1+ (point))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
72 (+ 3 (point)))
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
73 16)))
47944
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
74 (mm-insert-byte byte 1)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
75 (delete-char 3)))
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
76 (t
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
77 (message "Malformed quoted-printable text")
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
78 (forward-char)))))
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
79 (if coding-system
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
80 (mm-decode-coding-region (point-min) (point-max) coding-system)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
82 (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
83 "Decode the quoted-printable encoded STRING and return the result.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
84 If CODING-SYSTEM is non-nil, decode the region with coding-system.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
85 Use of CODING-SYSTEM is deprecated; this function should deal with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
86 raw bytes, and coding conversion should be done separately."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 52401
diff changeset
87 (mm-with-unibyte-buffer
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (insert string)
32211
5b42e5f7e809 (mm-decode-coding-region, mm-encode-coding-region):
Dave Love <fx@gnu.org>
parents: 32107
diff changeset
89 (quoted-printable-decode-region (point-min) (point-max) coding-system)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (buffer-string)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (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
93 "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
94
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
95 If FOLD, fold long lines at 76 characters (as required by the RFC).
35619
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
96 If CLASS is non-nil, translate the characters not matched by that
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
97 regexp class, which is in the form expected by `skip-chars-forward'.
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
98 You should probably avoid non-ASCII characters in this arg.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
100 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
101 encode lines starting with \"From\"."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 (interactive "r")
47944
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
103 (save-excursion
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
104 (goto-char from)
90104
a01e7a9f1659 Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents: 89971
diff changeset
105 (if (fboundp 'string-to-multibyte) ; Emacs 23
47944
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
106 (if (re-search-forward (string-to-multibyte "[^\x0-\x7f\x80-\xff]")
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
107 to t)
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
108 ;; Fixme: This is somewhat misleading.
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
109 (error "Multibyte character in QP encoding region"))
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
110 (if (re-search-forward (mm-string-as-multibyte "[^\0-\377]") to t)
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
111 (error "Multibyte character in QP encoding region"))))
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
112 (unless class
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
113 ;; 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
114 ;; 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
115 (setq class "\010-\012\014\040-\074\076-\177"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (narrow-to-region from to)
35619
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
119 ;; Encode all the non-ascii and control characters.
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
120 (goto-char (point-min))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
121 (while (and (skip-chars-forward class)
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
122 (not (eobp)))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
123 (insert
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
124 (prog1
90104
a01e7a9f1659 Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents: 89971
diff changeset
125 ;; To unibyte in case of Emacs 23 eight-bit.
47944
03cfc305a0fa (quoted-printable-encode-region): Use mm-insert-byte.
Dave Love <fx@gnu.org>
parents: 43737
diff changeset
126 (format "=%02X" (mm-multibyte-char-to-unibyte (char-after)))
35619
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
127 (delete-char 1))))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
128 ;; Encode white space at the end of lines.
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
129 (goto-char (point-min))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
130 (while (re-search-forward "[ \t]+$" nil t)
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
131 (goto-char (match-beginning 0))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
132 (while (not (eolp))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 (insert
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (prog1
34752
f04f551e94ce * message.el (message-narrow-to-head-1): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34025
diff changeset
135 (format "=%02X" (char-after))
35931
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
136 (delete-char 1)))))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
137 (let ((mm-use-ultra-safe-encoding
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
138 (and (boundp 'mm-use-ultra-safe-encoding)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
139 mm-use-ultra-safe-encoding)))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
140 (when (or fold mm-use-ultra-safe-encoding)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
141 (let ((tab-width 1)) ; HTAB is one character.
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
142 (goto-char (point-min))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
143 (while (not (eobp))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
144 ;; In ultra-safe mode, encode "From " at the beginning
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
145 ;; of a line.
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
146 (when mm-use-ultra-safe-encoding
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
147 (if (looking-at "From ")
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
148 (replace-match "From=20" nil t)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
149 (if (looking-at "-")
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
150 (replace-match "=2D" nil t))))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
151 (end-of-line)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
152 ;; Fold long lines.
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
153 (while (> (current-column) 76) ; tab-width must be 1.
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
154 (beginning-of-line)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
155 (forward-char 75) ; 75 chars plus an "="
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
156 (search-backward "=" (- (point) 2) t)
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
157 (insert "=\n")
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
158 (end-of-line))
ccc41398da84 (quoted-printable-encode-region): Remove redundant code
Dave Love <fx@gnu.org>
parents: 35619
diff changeset
159 (forward-line))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (defun quoted-printable-encode-string (string)
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
162 "Encode the STRING as quoted-printable and return the result."
35619
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
163 (let ((default-enable-multibyte-characters (mm-multibyte-string-p string)))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
164 (with-temp-buffer
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
165 (insert string)
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
166 (quoted-printable-encode-region (point-min) (point-max))
a670d2680870 Remove un-logged bogus changes from 2000-12-20.
Dave Love <fx@gnu.org>
parents: 34752
diff changeset
167 (buffer-string))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (provide 'qp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 47944
diff changeset
171 ;;; arch-tag: db89e52a-e4a1-4b69-926f-f434f04216ba
32103
a48838267750 Don't require mm-util.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
172 ;;; qp.el ends here