diff options
| author | Lars Ingebrigtsen | 2016-02-23 14:15:26 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-23 14:15:26 +1100 |
| commit | 96e32bbb736ec6e0a7278ae864098c7c812b05a4 (patch) | |
| tree | c5cc4ac5b4b75b3840b308444dd4c7575d4a1481 | |
| parent | 6b1a86ff624ba69ec404312f145c63d2d59fd38c (diff) | |
| download | emacs-96e32bbb736ec6e0a7278ae864098c7c812b05a4.tar.gz emacs-96e32bbb736ec6e0a7278ae864098c7c812b05a4.zip | |
Move Gnus functions frm rfc1843 to new file gnus-rfc1843
* lisp/gnus/gnus-rfc1843.el: New file for Gnus/rfc1843
interface functions.
* lisp/gnus/rfc1843.el: Move all Gnus-specifig functions to
gnus-rfc1843.
| -rw-r--r-- | lisp/gnus/gnus-rfc1843.el | 77 | ||||
| -rw-r--r-- | lisp/gnus/rfc1843.el | 61 |
2 files changed, 79 insertions, 59 deletions
diff --git a/lisp/gnus/gnus-rfc1843.el b/lisp/gnus/gnus-rfc1843.el new file mode 100644 index 00000000000..4e6fdc6d877 --- /dev/null +++ b/lisp/gnus/gnus-rfc1843.el | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | ;;; gnus-rfc1843.el --- HZ (rfc1843) decoding interface functions for Gnus | ||
| 2 | |||
| 3 | ;; Copyright (C) 1998-2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | ||
| 6 | ;; Keywords: news HZ HZ+ mail i18n | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; Usage: | ||
| 26 | ;; (require 'gnus-rfc1843) | ||
| 27 | ;; (rfc1843-gnus-setup) | ||
| 28 | |||
| 29 | ;;; Code: | ||
| 30 | |||
| 31 | (require 'rfc1843) | ||
| 32 | (require 'gnus-sum) | ||
| 33 | (require 'gnus-art) | ||
| 34 | (require 'message) | ||
| 35 | |||
| 36 | (defun rfc1843-decode-article-body () | ||
| 37 | "Decode HZ encoded text in the article body." | ||
| 38 | (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 39 | (or gnus-newsgroup-name "")) | ||
| 40 | (save-excursion | ||
| 41 | (save-restriction | ||
| 42 | (message-narrow-to-head) | ||
| 43 | (let* ((inhibit-point-motion-hooks t) | ||
| 44 | (case-fold-search t) | ||
| 45 | (ct (message-fetch-field "Content-Type" t)) | ||
| 46 | (ctl (and ct (mail-header-parse-content-type ct)))) | ||
| 47 | (if (and ctl (not (string-match "/" (car ctl)))) | ||
| 48 | (setq ctl nil)) | ||
| 49 | (goto-char (point-max)) | ||
| 50 | (widen) | ||
| 51 | (forward-line 1) | ||
| 52 | (narrow-to-region (point) (point-max)) | ||
| 53 | (when (or (not ctl) | ||
| 54 | (equal (car ctl) "text/plain")) | ||
| 55 | (rfc1843-decode-region (point) (point-max)))))))) | ||
| 56 | |||
| 57 | (defun rfc1843-gnus-setup () | ||
| 58 | "Setup HZ decoding for Gnus." | ||
| 59 | (add-hook 'gnus-article-decode-hook 'rfc1843-decode-article-body t) | ||
| 60 | (setq gnus-decode-encoded-word-function | ||
| 61 | 'gnus-multi-decode-encoded-word-string | ||
| 62 | gnus-decode-header-function | ||
| 63 | 'gnus-multi-decode-header | ||
| 64 | gnus-decode-encoded-word-methods | ||
| 65 | (nconc gnus-decode-encoded-word-methods | ||
| 66 | (list | ||
| 67 | (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 68 | 'rfc1843-decode-string))) | ||
| 69 | gnus-decode-header-methods | ||
| 70 | (nconc gnus-decode-header-methods | ||
| 71 | (list | ||
| 72 | (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 73 | 'rfc1843-decode-region))))) | ||
| 74 | |||
| 75 | (provide 'gnus-rfc1843) | ||
| 76 | |||
| 77 | ;;; gnus-rfc1843.el ends here | ||
diff --git a/lisp/gnus/rfc1843.el b/lisp/gnus/rfc1843.el index ee2af4803f6..508629fb062 100644 --- a/lisp/gnus/rfc1843.el +++ b/lisp/gnus/rfc1843.el | |||
| @@ -22,21 +22,12 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Commentary: | 23 | ;;; Commentary: |
| 24 | 24 | ||
| 25 | ;; Usage: | ||
| 26 | ;; (require 'rfc1843) | ||
| 27 | ;; (rfc1843-gnus-setup) | ||
| 28 | ;; | ||
| 29 | ;; Test: | 25 | ;; Test: |
| 30 | ;; (rfc1843-decode-string "~{<:Ky2;S{#,NpJ)l6HK!#~}") | 26 | ;; (rfc1843-decode-string "~{<:Ky2;S{#,NpJ)l6HK!#~}") |
| 31 | 27 | ||
| 32 | ;;; Code: | 28 | ;;; Code: |
| 33 | 29 | ||
| 34 | (eval-when-compile (require 'cl)) | 30 | (eval-when-compile (require 'cl)) |
| 35 | (require 'mm-util) | ||
| 36 | |||
| 37 | (defvar gnus-decode-encoded-word-function) | ||
| 38 | (defvar gnus-decode-header-function) | ||
| 39 | (defvar gnus-newsgroup-name) | ||
| 40 | 31 | ||
| 41 | (defvar rfc1843-word-regexp | 32 | (defvar rfc1843-word-regexp |
| 42 | "~\\({\\([\041-\167][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") | 33 | "~\\({\\([\041-\167][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") |
| @@ -111,10 +102,10 @@ ftp://ftp.math.psu.edu/pub/simpson/chinese/hzp/hzp.doc" | |||
| 111 | 102 | ||
| 112 | (defun rfc1843-decode-string (string) | 103 | (defun rfc1843-decode-string (string) |
| 113 | "Decode HZ STRING and return the results." | 104 | "Decode HZ STRING and return the results." |
| 114 | (let ((m (mm-multibyte-p))) | 105 | (let ((m enable-multibyte-characters)) |
| 115 | (with-temp-buffer | 106 | (with-temp-buffer |
| 116 | (when m | 107 | (when m |
| 117 | (mm-enable-multibyte)) | 108 | (set-buffer-multibyte 'to)) |
| 118 | (insert string) | 109 | (insert string) |
| 119 | (inline | 110 | (inline |
| 120 | (rfc1843-decode-region (point-min) (point-max))) | 111 | (rfc1843-decode-region (point-min) (point-max))) |
| @@ -135,54 +126,6 @@ ftp://ftp.math.psu.edu/pub/simpson/chinese/hzp/hzp.doc" | |||
| 135 | (aset s (incf i) (+ v (if (< v 63) 64 98)))))) | 126 | (aset s (incf i) (+ v (if (< v 63) 64 98)))))) |
| 136 | s)) | 127 | s)) |
| 137 | 128 | ||
| 138 | (autoload 'mail-header-parse-content-type "mail-parse") | ||
| 139 | (autoload 'message-narrow-to-head "message") | ||
| 140 | (declare-function message-fetch-field "message" (header &optional not-all)) | ||
| 141 | |||
| 142 | (defun rfc1843-decode-article-body () | ||
| 143 | "Decode HZ encoded text in the article body." | ||
| 144 | (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 145 | (or gnus-newsgroup-name "")) | ||
| 146 | (save-excursion | ||
| 147 | (save-restriction | ||
| 148 | (message-narrow-to-head) | ||
| 149 | (let* ((inhibit-point-motion-hooks t) | ||
| 150 | (case-fold-search t) | ||
| 151 | (ct (message-fetch-field "Content-Type" t)) | ||
| 152 | (ctl (and ct (mail-header-parse-content-type ct)))) | ||
| 153 | (if (and ctl (not (string-match "/" (car ctl)))) | ||
| 154 | (setq ctl nil)) | ||
| 155 | (goto-char (point-max)) | ||
| 156 | (widen) | ||
| 157 | (forward-line 1) | ||
| 158 | (narrow-to-region (point) (point-max)) | ||
| 159 | (when (or (not ctl) | ||
| 160 | (equal (car ctl) "text/plain")) | ||
| 161 | (rfc1843-decode-region (point) (point-max)))))))) | ||
| 162 | |||
| 163 | (defvar gnus-decode-header-methods) | ||
| 164 | (defvar gnus-decode-encoded-word-methods) | ||
| 165 | |||
| 166 | (defun rfc1843-gnus-setup () | ||
| 167 | "Setup HZ decoding for Gnus." | ||
| 168 | (require 'gnus-art) | ||
| 169 | (require 'gnus-sum) | ||
| 170 | (add-hook 'gnus-article-decode-hook 'rfc1843-decode-article-body t) | ||
| 171 | (setq gnus-decode-encoded-word-function | ||
| 172 | 'gnus-multi-decode-encoded-word-string | ||
| 173 | gnus-decode-header-function | ||
| 174 | 'gnus-multi-decode-header | ||
| 175 | gnus-decode-encoded-word-methods | ||
| 176 | (nconc gnus-decode-encoded-word-methods | ||
| 177 | (list | ||
| 178 | (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 179 | 'rfc1843-decode-string))) | ||
| 180 | gnus-decode-header-methods | ||
| 181 | (nconc gnus-decode-header-methods | ||
| 182 | (list | ||
| 183 | (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | ||
| 184 | 'rfc1843-decode-region))))) | ||
| 185 | |||
| 186 | (provide 'rfc1843) | 129 | (provide 'rfc1843) |
| 187 | 130 | ||
| 188 | ;;; rfc1843.el ends here | 131 | ;;; rfc1843.el ends here |