X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Frfc2047.el;h=e881256f386ef04b3d23c09927881f6f4f25ae2b;hb=d6d90fbbda04a990e100832c709d6c746d872aa3;hp=8a7153969a51df2cd249305d2994f0da7246973e;hpb=0d95362bbbe4543bd6ec79733eb826f99fa8d931;p=gnus diff --git a/lisp/rfc2047.el b/lisp/rfc2047.el index 8a7153969..e881256f3 100644 --- a/lisp/rfc2047.el +++ b/lisp/rfc2047.el @@ -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 ;; MORIOKA Tomohiko @@ -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 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