gmm-utils.el (gmm-called-interactively-p): Restore as a macro.
[gnus] / lisp / rfc2047.el
index 8a71539..e881256 100644 (file)
@@ -1,7 +1,6 @@
 ;;; rfc2047.el --- functions for encoding and decoding rfc2047 messages
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1998-2012  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;     MORIOKA Tomohiko <morioka@jaist.ac.jp>
@@ -286,11 +285,11 @@ Should be called narrowed to the head of the message."
                       mail-parse-charset)
                  (mm-encode-coding-region (point) (point-max)
                                           mail-parse-charset)))
-            ;; We get this when CC'ing messsages to newsgroups with
+            ;; We get this when CC'ing messages to newsgroups with
             ;; 8-bit names.  The group name mail copy just got
             ;; unconditionally encoded.  Previously, it would ask
             ;; whether to encode, which was quite confusing for the
-            ;; user.  If the new behavior is wrong, tell me. I have
+            ;; user.  If the new behavior is wrong, tell me.  I have
             ;; left the old code commented out below.
             ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-07.
             ;; Modified by Dave Love, with the commented-out code changed
@@ -346,13 +345,9 @@ The buffer may be narrowed."
     ;; it appears to be the cleanest way.
     ;; Play safe and don't assume the form of the word syntax entry --
     ;; copy it from ?a.
-    (if (fboundp 'set-char-table-range)        ; Emacs
-       (funcall (intern "set-char-table-range")
-                table t (aref (standard-syntax-table) ?a))
-      (if (fboundp 'put-char-table)
-         (if (fboundp 'get-char-table) ; warning avoidance
-             (put-char-table t (get-char-table ?a (standard-syntax-table))
-                             table))))
+    (if (featurep 'xemacs)
+       (put-char-table t (get-char-table ?a (standard-syntax-table)) table)
+      (set-char-table-range table t (aref (standard-syntax-table) ?a)))
     (modify-syntax-entry ?\\ "\\" table)
     (modify-syntax-entry ?\" "\"" table)
     (modify-syntax-entry ?\( "(" table)
@@ -367,7 +362,7 @@ The buffer may be narrowed."
     (modify-syntax-entry ?@ "." table)
     table))
 
-(defun rfc2047-encode-region (b e)
+(defun rfc2047-encode-region (b e &optional dont-fold)
   "Encode words in region B to E that need encoding.
 By default, the region is treated as containing RFC2822 addresses.
 Dynamically bind `rfc2047-encoding-type' to change that."
@@ -551,16 +546,17 @@ Dynamically bind `rfc2047-encoding-type' to change that."
                 (signal (car err) (cdr err))
               (error "Invalid data for rfc2047 encoding: %s"
                      (mm-replace-in-string orig-text "[ \t\n]+" " "))))))))
-    (rfc2047-fold-region b (point))
+    (unless dont-fold
+      (rfc2047-fold-region b (point)))
     (goto-char (point-max))))
 
-(defun rfc2047-encode-string (string)
+(defun rfc2047-encode-string (string &optional dont-fold)
   "Encode words in STRING.
 By default, the string is treated as containing addresses (see
 `rfc2047-encoding-type')."
   (mm-with-multibyte-buffer
     (insert string)
-    (rfc2047-encode-region (point-min) (point-max))
+    (rfc2047-encode-region (point-min) (point-max) dont-fold)
     (buffer-string)))
 
 ;; From RFC 2047:
@@ -591,7 +587,7 @@ should not change this value.")
        ((>= column rfc2047-encode-max-chars)
         (when eword
           (cond ((string-match "\n[ \t]+\\'" eword)
-                 ;; Reomove a superfluous empty line.
+                 ;; Remove a superfluous empty line.
                  (setq eword (substring eword 0 (match-beginning 0))))
                 ((string-match "(+\\'" eword)
                  ;; Break the line before the open parenthesis.
@@ -644,7 +640,7 @@ should not change this value.")
               (setq crest " "
                     eword (concat eword next)))
             (when (string-match "\n[ \t]+\\'" eword)
-              ;; Reomove a superfluous empty line.
+              ;; Remove a superfluous empty line.
               (setq eword (substring eword 0 (match-beginning 0))))
             (rfc2047-encode-1 (length crest) (substring string index)
                               cs encoder start " " tail
@@ -855,7 +851,7 @@ This is a substitution for the `rfc2231-encode-string' function, that
 is the standard but many mailers don't support it."
   (let ((rfc2047-encoding-type 'mime)
        (rfc2047-encode-max-chars nil))
-    (rfc2045-encode-string param (rfc2047-encode-string value))))
+    (rfc2045-encode-string param (rfc2047-encode-string value t))))
 
 ;;;
 ;;; Functions for decoding RFC2047 messages