Mercurial > emacs
comparison lisp/gnus/rfc2047.el @ 35985:b9c371244b90
(rfc2047-fold-region): Don't forward-char at EOB.
(message-posting-charset): Defvar when compiling again.
(rfc2047-encodable-p): Require message.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 08 Feb 2001 19:26:36 +0000 |
parents | 53eebdb81828 |
children | a26d9b55abb6 |
comparison
equal
deleted
inserted
replaced
35984:0080b799e901 | 35985:b9c371244b90 |
---|---|
87 "Alist of RFC2047 encodings to encoding functions.") | 87 "Alist of RFC2047 encodings to encoding functions.") |
88 | 88 |
89 (defvar rfc2047-q-encoding-alist | 89 (defvar rfc2047-q-encoding-alist |
90 '(("\\(From\\|Cc\\|To\\|Bcc\||Reply-To\\):" . "-A-Za-z0-9!*+/") | 90 '(("\\(From\\|Cc\\|To\\|Bcc\||Reply-To\\):" . "-A-Za-z0-9!*+/") |
91 ;; = (\075), _ (\137), ? (\077) are used in the encoded word. | 91 ;; = (\075), _ (\137), ? (\077) are used in the encoded word. |
92 ;; Avoid using 8bit characters. Some versions of Emacs has bug! | 92 ;; Avoid using 8bit characters. |
93 ;; Equivalent to "^\000-\007\011\013\015-\037\200-\377=_?" | 93 ;; Equivalent to "^\000-\007\011\013\015-\037\200-\377=_?" |
94 ("." . "\010\012\014\040-\074\076\100-\136\140-\177")) | 94 ("." . "\010\012\014\040-\074\076\100-\136\140-\177")) |
95 "Alist of header regexps and valid Q characters.") | 95 "Alist of header regexps and valid Q characters.") |
96 | 96 |
97 ;;; | 97 ;;; |
158 (mm-encode-coding-region (point-min) (point-max) method))) | 158 (mm-encode-coding-region (point-min) (point-max) method))) |
159 ;; Hm. | 159 ;; Hm. |
160 (t))) | 160 (t))) |
161 (goto-char (point-max))))))) | 161 (goto-char (point-max))))))) |
162 | 162 |
163 ;; Fixme: This, and the require below may not be the Right Thing, but | |
164 ;; should be safe just before release. -- fx 2001-02-08 | |
165 (eval-when-compile (defvar message-posting-charset)) | |
166 | |
163 (defun rfc2047-encodable-p () | 167 (defun rfc2047-encodable-p () |
164 "Return non-nil if any characters in current buffer need encoding in headers. | 168 "Return non-nil if any characters in current buffer need encoding in headers. |
165 The buffer may be narrowed." | 169 The buffer may be narrowed." |
170 (require 'message) ; for message-posting-charset | |
166 (let ((charsets | 171 (let ((charsets |
167 (mapcar | 172 (mapcar |
168 'mm-mime-charset | 173 'mm-mime-charset |
169 (mm-find-charset-region (point-min) (point-max)))) | 174 (mm-find-charset-region (point-min) (point-max)))) |
170 (cs (list 'us-ascii (car message-posting-charset))) | 175 (cs (list 'us-ascii (car message-posting-charset))) |
227 (push word result) | 232 (push word result) |
228 (setq word (pop words)))) | 233 (setq word (pop words)))) |
229 result)) | 234 result)) |
230 | 235 |
231 (defun rfc2047-encode-region (b e) | 236 (defun rfc2047-encode-region (b e) |
232 "Encode all encodable words in region." | 237 "Encode all encodable words in region B to E." |
233 (let ((words (rfc2047-dissect-region b e)) word) | 238 (let ((words (rfc2047-dissect-region b e)) word) |
234 (save-restriction | 239 (save-restriction |
235 (narrow-to-region b e) | 240 (narrow-to-region b e) |
236 (delete-region (point-min) (point-max)) | 241 (delete-region (point-min) (point-max)) |
237 (while (setq word (pop words)) | 242 (while (setq word (pop words)) |
291 (end-of-line) | 296 (end-of-line) |
292 (insert "?=") | 297 (insert "?=") |
293 (forward-line 1))))) | 298 (forward-line 1))))) |
294 | 299 |
295 (defun rfc2047-fold-region (b e) | 300 (defun rfc2047-fold-region (b e) |
296 "Fold long lines in the region." | 301 "Fold long lines in region B to E." |
297 (save-restriction | 302 (save-restriction |
298 (narrow-to-region b e) | 303 (narrow-to-region b e) |
299 (goto-char (point-min)) | 304 (goto-char (point-min)) |
300 (let ((break nil) | 305 (let ((break nil) |
301 (qword-break nil) | 306 (qword-break nil) |
311 (insert "\n") | 316 (insert "\n") |
312 (insert "\n ")) | 317 (insert "\n ")) |
313 (setq bol (1- (point))) | 318 (setq bol (1- (point))) |
314 ;; Don't break before the first non-LWSP characters. | 319 ;; Don't break before the first non-LWSP characters. |
315 (skip-chars-forward " \t") | 320 (skip-chars-forward " \t") |
316 (forward-char 1)) | 321 (unless (eobp) (forward-char 1))) |
317 (cond | 322 (cond |
318 ((eq (char-after) ?\n) | 323 ((eq (char-after) ?\n) |
319 (forward-char 1) | 324 (forward-char 1) |
320 (setq bol (point) | 325 (setq bol (point) |
321 break nil | 326 break nil |
345 (insert "\n") | 350 (insert "\n") |
346 (insert "\n ")) | 351 (insert "\n ")) |
347 (setq bol (1- (point))) | 352 (setq bol (1- (point))) |
348 ;; Don't break before the first non-LWSP characters. | 353 ;; Don't break before the first non-LWSP characters. |
349 (skip-chars-forward " \t") | 354 (skip-chars-forward " \t") |
350 (forward-char 1))))) | 355 (unless (eobp) (forward-char 1)))))) |
351 | 356 |
352 (defun rfc2047-unfold-region (b e) | 357 (defun rfc2047-unfold-region (b e) |
353 "Unfold lines in the region." | 358 "Unfold lines in region B to E." |
354 (save-restriction | 359 (save-restriction |
355 (narrow-to-region b e) | 360 (narrow-to-region b e) |
356 (goto-char (point-min)) | 361 (goto-char (point-min)) |
357 (let ((bol (save-restriction | 362 (let ((bol (save-restriction |
358 (widen) | 363 (widen) |