From: yamaoka Date: Wed, 26 Feb 2003 22:17:51 +0000 (+0000) Subject: Synch to Oort Gnus. X-Git-Tag: t-gnus-6_15_17-00-quimby~38 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87e28aa084d1815a1582e5e11aad8cd7cd7090a6;p=elisp%2Fgnus.git- Synch to Oort Gnus. --- diff --git a/contrib/gnus-idna.el b/contrib/gnus-idna.el new file mode 100644 index 0000000..e11d3a0 --- /dev/null +++ b/contrib/gnus-idna.el @@ -0,0 +1,113 @@ +;;; gnus-idna.el --- Internationalized domain names support for Gnus. + +;; Copyright (C) 2003 Free Software Foundation, Inc. + +;; Author: Simon Josefsson +;; Keywords: news, mail + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; This package implement crude support for internationalized +;; (non-ASCII) domain names in Gnus. It is meant as a proof of +;; concept. + +;; Theory of Operation: + +;; RFC 2822 RHS's inside the From:, To:, and CC: headers are encoded +;; using IDNA ToASCII() when you send mail using Message. The hook +;; used is message-send-hook. +;; +;; For incoming articles, when QP in headers are decoded, it searches +;; for "xn--" prefixes and decode them using IDNA ToUnicode(). The +;; hook used is gnus-article-decode-hook. + +;; Usage: + +;; Simply put (require 'gnus-idna) in your ~/.gnus or ~/.emacs and it +;; should work. You need to install GNU Libidn (0.1.11 or later) and +;; make sure the idna.el installed by it is found by emacs. + +;;; Code: + +(require 'gnus) +(require 'rfc822) +(require 'idna) + +(eval-and-compile + (cond + ((fboundp 'replace-in-string) + (defalias 'gnus-replace-in-string 'replace-in-string)) + ((fboundp 'replace-regexp-in-string) + (defun gnus-replace-in-string (string regexp newtext &optional literal) + (replace-regexp-in-string regexp newtext string nil literal))) + (t + (defun gnus-replace-in-string (string regexp newtext &optional literal) + (let ((start 0) tail) + (while (string-match regexp string start) + (setq tail (- (length string) (match-end 0))) + (setq string (replace-match newtext nil literal string)) + (setq start (- (length string) tail)))) + string)))) + +(defun gnus-idna-to-ascii-rhs-1 (header) + (save-excursion + (let (address header-data new-header-data rhs ace) + (setq header-data (message-fetch-field header)) + (when header-data + (dolist (element (message-tokenize-header header-data)) + (setq address (car (rfc822-addresses element))) + (when (string-match "\\(.*\\)@\\([^@]+\\)" address) + (setq ace (if (setq rhs (match-string 2 address)) + (idna-to-ascii rhs))) + (push (if (string= rhs ace) + element + (gnus-replace-in-string element (regexp-quote rhs) ace t)) + new-header-data))) + (message-remove-header header) + (message-position-on-field header) + (dolist (addr (reverse new-header-data)) + (insert addr ", ")) + (when new-header-data + (delete-backward-char 2)))))) + +(defun gnus-idna-to-ascii-rhs () + (gnus-idna-to-ascii-rhs-1 "From") + (gnus-idna-to-ascii-rhs-1 "To") + (gnus-idna-to-ascii-rhs-1 "Cc")) + +(add-hook 'message-send-hook 'gnus-idna-to-ascii-rhs) + +(defun gnus-idna-to-unicode-rhs () + (let ((inhibit-point-motion-hooks t) + buffer-read-only) + (goto-char (point-min)) + (while (re-search-forward "xn--.*[ \t\n\r.,<>()@!]" nil t) + ;(or (eobp) (forward-char)) + (let (ace unicode) + (when (setq ace (match-string 0)) + (setq unicode (idna-to-unicode ace)) + (unless (string= ace unicode) + (replace-match unicode))))))) + +(add-hook 'gnus-article-decode-hook 'gnus-idna-to-unicode-rhs 'append) + +(provide 'gnus-idna) + +;; gnus-idna.el ends here diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c79eec8..290651b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,18 @@ +2003-02-26 Teodor Zlatanov + + * spam.el: add spam-stat-load to gnus-get-new-news-hook + (spam-split): remove spam-stat-load call + +2003-02-26 Simon Josefsson + + * gnus-sum.el (gnus-summary-toggle-header): Run + gnus-article-decode-hook instead of calling a-decode-encoded-words + directly (the latter is run as part of the former). + +2003-02-26 ShengHuo ZHU + + * gnus-agent.el (gnus-agent-expire-group): Remove debug. + 2003-02-25 Jesper Harder * message.el (message-sendmail-envelope-from): New option. diff --git a/lisp/gnus-agent.el b/lisp/gnus-agent.el index 58c16ed..1f03fb2 100644 --- a/lisp/gnus-agent.el +++ b/lisp/gnus-agent.el @@ -2161,7 +2161,6 @@ The articles on which the expiration process runs are selected as follows: if ARTICLES is a list, just those articles. FORCE is equivalent to setting the expiration predicates to true." (interactive) -(debug) (if (not group) (gnus-agent-expire articles group force) diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 973163c..9096da3 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -8693,7 +8693,7 @@ If ARG is a negative number, hide the unwanted header lines." (1- (point)) (point-max)))) (insert-buffer-substring gnus-original-article-buffer s e) - (article-decode-encoded-words) + (run-hooks 'gnus-article-decode-hook) (if hidden (let ((gnus-treat-hide-headers nil) (gnus-treat-hide-boring-headers nil)) diff --git a/lisp/spam.el b/lisp/spam.el index a63c86b..3f38117 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -567,9 +567,6 @@ example like this: (: spam-split) See the Info node `(gnus)Fancy Mail Splitting' for more details." (interactive) - ;; load the spam-stat tables if needed - (when spam-use-stat (spam-stat-load)) - (let ((list-of-checks spam-list-of-checks) decision) (while (and list-of-checks (not decision)) @@ -789,8 +786,10 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)." (insert article-string) (spam-stat-buffer-is-non-spam)))))) + ;; Add hooks for loading and saving the spam stats (when spam-use-stat - (add-hook 'gnus-save-newsrc-hook 'spam-stat-save))) + (add-hook 'gnus-save-newsrc-hook 'spam-stat-save) + (add-hook 'gnus-get-new-news-hook 'spam-stat-load))) (file-error (progn (defalias 'spam-stat-register-ham-routine 'ignore)