* rfc2047.el (rfc2047-qp-or-base64): New function to reduce
authorJesper Harder <harder@ifa.au.dk>
Mon, 9 Feb 2004 02:53:36 +0000 (02:53 +0000)
committerJesper Harder <harder@ifa.au.dk>
Mon, 9 Feb 2004 02:53:36 +0000 (02:53 +0000)
dependencies.
(rfc2047-encode): Use it.

* gnus-art.el (gnus-button-marker-list): Move before first
reference.

lisp/ChangeLog
lisp/gnus-art.el
lisp/rfc2047.el

index f225979..9bababb 100644 (file)
@@ -1,5 +1,12 @@
 2004-02-09  Jesper Harder  <harder@ifa.au.dk>
 
+       * rfc2047.el (rfc2047-qp-or-base64): New function to reduce
+       dependencies.
+       (rfc2047-encode): Use it.
+
+       * gnus-art.el (gnus-button-marker-list): Move before first
+       reference.
+
        * imap.el (imap-parse-flag-list, imap-parse-body-extension)
        (imap-parse-body): Fix format string mismatch.
 
index c4725c1..d979ec7 100644 (file)
@@ -1374,6 +1374,13 @@ This requires GNU Libidn, and by default only enabled if it is found."
   '("January" "February" "March" "April" "May" "June" "July" "August"
     "September" "October" "November" "December"))
 
+(defvar gnus-button-regexp nil)
+(defvar gnus-button-marker-list nil)
+;; Regexp matching any of the regexps from `gnus-button-alist'.
+
+(defvar gnus-button-last nil)
+;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
+
 (defvar article-goto-body-goes-to-point-min-p nil)
 (defvar gnus-article-wash-types nil)
 (defvar gnus-article-emphasis-alist nil)
@@ -6207,13 +6214,6 @@ HEADER is a regexp to match a header.  For a fuller explanation, see
                               :inline t
                               (integer :tag "Regexp group")))))
 
-(defvar gnus-button-regexp nil)
-(defvar gnus-button-marker-list nil)
-;; Regexp matching any of the regexps from `gnus-button-alist'.
-
-(defvar gnus-button-last nil)
-;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
-
 ;;; Commands:
 
 (defun gnus-article-push-button (event)
index 1ba47df..9832fd5 100644 (file)
@@ -97,6 +97,25 @@ quoted-printable and base64 respectively.")
 ;;; Functions for encoding RFC2047 messages
 ;;;
 
+(defun rfc2047-qp-or-base64 ()
+  "Return the type with which to encode the buffer.
+This is either `base64' or `quoted-printable'."
+  (save-excursion
+    (let ((limit (min (point-max) (+ 2000 (point-min))))
+         (n8bit 0))
+      (goto-char (point-min))
+      (skip-chars-forward "\x20-\x7f\r\n\t" limit)
+      (while (< (point) limit)
+       (incf n8bit)
+       (forward-char 1)
+       (skip-chars-forward "\x20-\x7f\r\n\t" limit))
+      (if (or (< (* 6 n8bit) (- limit (point-min)))
+             ;; Don't base64, say, a short line with a single
+             ;; non-ASCII char when splitting parts by charset.
+             (= n8bit 1))
+         'quoted-printable
+       'base64))))
+
 (defun rfc2047-narrow-to-field ()
   "Narrow the buffer to the header on the current line."
   (beginning-of-line)
@@ -382,7 +401,7 @@ By default, the region is treated as containing addresses (see
                       ;; encoding, choose the one that's shorter.
                       (save-restriction
                         (narrow-to-region b e)
-                        (if (eq (mm-qp-or-base64) 'base64)
+                        (if (eq (rfc2047-qp-or-base64) 'base64)
                             'B
                           'Q))))
         (start (concat