Mercurial > emacs
comparison lisp/gnus/message.el @ 90234:b1c1fc853d2f
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-86
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 562-568)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 125-128)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 30 Sep 2005 11:43:45 +0000 |
parents | ee12d75eb214 8e46fef0174c |
children | aa89c814f853 |
comparison
equal
deleted
inserted
replaced
90233:ee12d75eb214 | 90234:b1c1fc853d2f |
---|---|
1452 | 1452 |
1453 (defcustom message-use-idna (and (condition-case nil (require 'idna) | 1453 (defcustom message-use-idna (and (condition-case nil (require 'idna) |
1454 (file-error)) | 1454 (file-error)) |
1455 (mm-coding-system-p 'utf-8) | 1455 (mm-coding-system-p 'utf-8) |
1456 (executable-find idna-program) | 1456 (executable-find idna-program) |
1457 'ask) | 1457 (string= (idna-to-ascii "räksmörgås") |
1458 "Whether to encode non-ASCII in domain names into ASCII according to IDNA." | 1458 "xn--rksmrgs-5wao1o") |
1459 t) | |
1460 "Whether to encode non-ASCII in domain names into ASCII according to IDNA. | |
1461 GNU Libidn, and in particular the elisp package \"idna.el\" and | |
1462 the external program \"idn\", must be installed for this | |
1463 functionality to work." | |
1459 :version "22.1" | 1464 :version "22.1" |
1460 :group 'message-headers | 1465 :group 'message-headers |
1461 :link '(custom-manual "(message)IDNA") | 1466 :link '(custom-manual "(message)IDNA") |
1462 :type '(choice (const :tag "Ask" ask) | 1467 :type '(choice (const :tag "Ask" ask) |
1463 (const :tag "Never" nil) | 1468 (const :tag "Never" nil) |
1805 new subject) | 1810 new subject) |
1806 new)))) | 1811 new)))) |
1807 | 1812 |
1808 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/ | 1813 ;;; Suggested by Jonas Steverud @ www.dtek.chalmers.se/~d4jonas/ |
1809 | 1814 |
1810 ;;;###autoload | |
1811 (defun message-change-subject (new-subject) | 1815 (defun message-change-subject (new-subject) |
1812 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)." | 1816 "Ask for NEW-SUBJECT header, append (was: <Old Subject>)." |
1813 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged> | 1817 ;; <URL:http://www.landfield.com/usefor/drafts/draft-ietf-usefor-useage--1.02.unpaged> |
1814 (interactive | 1818 (interactive |
1815 (list | 1819 (list |
1837 (insert (concat "Subject: " | 1841 (insert (concat "Subject: " |
1838 new-subject | 1842 new-subject |
1839 " (was: " | 1843 " (was: " |
1840 old-subject ")\n"))))))))) | 1844 old-subject ")\n"))))))))) |
1841 | 1845 |
1842 ;;;###autoload | |
1843 (defun message-mark-inserted-region (beg end) | 1846 (defun message-mark-inserted-region (beg end) |
1844 "Mark some region in the current article with enclosing tags. | 1847 "Mark some region in the current article with enclosing tags. |
1845 See `message-mark-insert-begin' and `message-mark-insert-end'." | 1848 See `message-mark-insert-begin' and `message-mark-insert-end'." |
1846 (interactive "r") | 1849 (interactive "r") |
1847 (save-excursion | 1850 (save-excursion |
1849 (goto-char end) | 1852 (goto-char end) |
1850 (insert message-mark-insert-end) | 1853 (insert message-mark-insert-end) |
1851 (goto-char beg) | 1854 (goto-char beg) |
1852 (insert message-mark-insert-begin))) | 1855 (insert message-mark-insert-begin))) |
1853 | 1856 |
1854 ;;;###autoload | |
1855 (defun message-mark-insert-file (file) | 1857 (defun message-mark-insert-file (file) |
1856 "Insert FILE at point, marking it with enclosing tags. | 1858 "Insert FILE at point, marking it with enclosing tags. |
1857 See `message-mark-insert-begin' and `message-mark-insert-end'." | 1859 See `message-mark-insert-begin' and `message-mark-insert-end'." |
1858 (interactive "fFile to insert: ") | 1860 (interactive "fFile to insert: ") |
1859 ;; reverse insertion to get correct result. | 1861 ;; reverse insertion to get correct result. |
1862 (goto-char p) | 1864 (goto-char p) |
1863 (insert-file-contents file) | 1865 (insert-file-contents file) |
1864 (goto-char p) | 1866 (goto-char p) |
1865 (insert message-mark-insert-begin))) | 1867 (insert message-mark-insert-begin))) |
1866 | 1868 |
1867 ;;;###autoload | |
1868 (defun message-add-archive-header () | 1869 (defun message-add-archive-header () |
1869 "Insert \"X-No-Archive: Yes\" in the header and a note in the body. | 1870 "Insert \"X-No-Archive: Yes\" in the header and a note in the body. |
1870 The note can be customized using `message-archive-note'. When called with a | 1871 The note can be customized using `message-archive-note'. When called with a |
1871 prefix argument, ask for a text to insert. If you don't want the note in the | 1872 prefix argument, ask for a text to insert. If you don't want the note in the |
1872 body, set `message-archive-note' to nil." | 1873 body, set `message-archive-note' to nil." |
1882 (insert message-archive-note) | 1883 (insert message-archive-note) |
1883 (newline)) | 1884 (newline)) |
1884 (message-add-header message-archive-header) | 1885 (message-add-header message-archive-header) |
1885 (message-sort-headers))) | 1886 (message-sort-headers))) |
1886 | 1887 |
1887 ;;;###autoload | |
1888 (defun message-cross-post-followup-to-header (target-group) | 1888 (defun message-cross-post-followup-to-header (target-group) |
1889 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP. | 1889 "Mangles FollowUp-To and Newsgroups header to point to TARGET-GROUP. |
1890 With prefix-argument just set Follow-Up, don't cross-post." | 1890 With prefix-argument just set Follow-Up, don't cross-post." |
1891 (interactive | 1891 (interactive |
1892 (list ; Completion based on Gnus | 1892 (list ; Completion based on Gnus |
1926 "[ \t]*$") | 1926 "[ \t]*$") |
1927 (message-fetch-field "Newsgroups"))) | 1927 (message-fetch-field "Newsgroups"))) |
1928 (insert (concat "\nFollowup-To: " target-group))) | 1928 (insert (concat "\nFollowup-To: " target-group))) |
1929 (setq message-cross-post-old-target target-group)) | 1929 (setq message-cross-post-old-target target-group)) |
1930 | 1930 |
1931 ;;;###autoload | |
1932 (defun message-cross-post-insert-note (target-group cross-post in-old | 1931 (defun message-cross-post-insert-note (target-group cross-post in-old |
1933 old-groups) | 1932 old-groups) |
1934 "Insert a in message body note about a set Followup or Crosspost. | 1933 "Insert a in message body note about a set Followup or Crosspost. |
1935 If there have been previous notes, delete them. TARGET-GROUP specifies the | 1934 If there have been previous notes, delete them. TARGET-GROUP specifies the |
1936 group to Followup-To. When CROSS-POST is t, insert note about | 1935 group to Followup-To. When CROSS-POST is t, insert note about |
1959 (not cross-post) | 1958 (not cross-post) |
1960 (string-match "^[ \t]*poster[ \t]*$" target-group)) | 1959 (string-match "^[ \t]*poster[ \t]*$" target-group)) |
1961 (insert (concat message-followup-to-note target-group "\n")) | 1960 (insert (concat message-followup-to-note target-group "\n")) |
1962 (insert (concat message-cross-post-note target-group "\n"))))) | 1961 (insert (concat message-cross-post-note target-group "\n"))))) |
1963 | 1962 |
1964 ;;;###autoload | |
1965 (defun message-cross-post-followup-to (target-group) | 1963 (defun message-cross-post-followup-to (target-group) |
1966 "Crossposts message and set Followup-To to TARGET-GROUP. | 1964 "Crossposts message and set Followup-To to TARGET-GROUP. |
1967 With prefix-argument just set Follow-Up, don't cross-post." | 1965 With prefix-argument just set Follow-Up, don't cross-post." |
1968 (interactive | 1966 (interactive |
1969 (list ; Completion based on Gnus | 1967 (list ; Completion based on Gnus |
2001 current-prefix-arg)) t) | 1999 current-prefix-arg)) t) |
2002 in-old old-groups)))))))) | 2000 in-old old-groups)))))))) |
2003 | 2001 |
2004 ;;; Reduce To: to Cc: or Bcc: header | 2002 ;;; Reduce To: to Cc: or Bcc: header |
2005 | 2003 |
2006 ;;;###autoload | |
2007 (defun message-reduce-to-to-cc () | 2004 (defun message-reduce-to-to-cc () |
2008 "Replace contents of To: header with contents of Cc: or Bcc: header." | 2005 "Replace contents of To: header with contents of Cc: or Bcc: header." |
2009 (interactive) | 2006 (interactive) |
2010 (let ((cc-content | 2007 (let ((cc-content |
2011 (save-restriction (message-narrow-to-headers) | 2008 (save-restriction (message-narrow-to-headers) |
2027 (message-remove-header (if bcc | 2024 (message-remove-header (if bcc |
2028 "bcc" | 2025 "bcc" |
2029 "cc")))))))) | 2026 "cc")))))))) |
2030 | 2027 |
2031 ;;; End of functions adopted from `message-utils.el'. | 2028 ;;; End of functions adopted from `message-utils.el'. |
2029 | |
2030 (defun message-remove-duplicates (list) | |
2031 (let (new) | |
2032 (while list | |
2033 (or (member (car list) new) | |
2034 (setq new (cons (car list) new))) | |
2035 (setq list (cdr list))) | |
2036 (nreverse new))) | |
2032 | 2037 |
2033 (defun message-remove-header (header &optional is-regexp first reverse) | 2038 (defun message-remove-header (header &optional is-regexp first reverse) |
2034 "Remove HEADER in the narrowed buffer. | 2039 "Remove HEADER in the narrowed buffer. |
2035 If IS-REGEXP, HEADER is a regular expression. | 2040 If IS-REGEXP, HEADER is a regular expression. |
2036 If FIRST, only remove the first instance of the header. | 2041 If FIRST, only remove the first instance of the header. |
4955 (defun message-idna-to-ascii-rhs-1 (header) | 4960 (defun message-idna-to-ascii-rhs-1 (header) |
4956 "Interactively potentially IDNA encode domain names in HEADER." | 4961 "Interactively potentially IDNA encode domain names in HEADER." |
4957 (let ((field (message-fetch-field header)) | 4962 (let ((field (message-fetch-field header)) |
4958 rhs ace address) | 4963 rhs ace address) |
4959 (when field | 4964 (when field |
4960 (dolist (address (mail-header-parse-addresses field)) | 4965 (dolist (rhs |
4961 (setq address (car address) | 4966 (message-remove-duplicates |
4962 rhs (downcase (or (cadr (split-string address "@")) "")) | 4967 (mapcar (lambda (rhs) (or (cadr (split-string rhs "@")) "")) |
4963 ace (downcase (idna-to-ascii rhs))) | 4968 (mapcar 'downcase |
4969 (mapcar | |
4970 'car (mail-header-parse-addresses field)))))) | |
4971 (setq ace (downcase (idna-to-ascii rhs))) | |
4964 (when (and (not (equal rhs ace)) | 4972 (when (and (not (equal rhs ace)) |
4965 (or (not (eq message-use-idna 'ask)) | 4973 (or (not (eq message-use-idna 'ask)) |
4966 (y-or-n-p (format "Replace %s with %s? " rhs ace)))) | 4974 (y-or-n-p (format "Replace %s with %s in %s:? " |
4975 rhs ace header)))) | |
4967 (goto-char (point-min)) | 4976 (goto-char (point-min)) |
4968 (while (re-search-forward (concat "^" header ":") nil t) | 4977 (while (re-search-forward (concat "^" header ":") nil t) |
4969 (message-narrow-to-field) | 4978 (message-narrow-to-field) |
4970 (while (search-forward (concat "@" rhs) nil t) | 4979 (while (search-forward (concat "@" rhs) nil t) |
4971 (replace-match (concat "@" ace) t t)) | 4980 (replace-match (concat "@" ace) t t)) |
4980 (save-excursion | 4989 (save-excursion |
4981 (save-restriction | 4990 (save-restriction |
4982 (message-narrow-to-head) | 4991 (message-narrow-to-head) |
4983 (message-idna-to-ascii-rhs-1 "From") | 4992 (message-idna-to-ascii-rhs-1 "From") |
4984 (message-idna-to-ascii-rhs-1 "To") | 4993 (message-idna-to-ascii-rhs-1 "To") |
4994 (message-idna-to-ascii-rhs-1 "Reply-To") | |
4995 (message-idna-to-ascii-rhs-1 "Mail-Reply-To") | |
4996 (message-idna-to-ascii-rhs-1 "Mail-Followup-To") | |
4985 (message-idna-to-ascii-rhs-1 "Cc"))))) | 4997 (message-idna-to-ascii-rhs-1 "Cc"))))) |
4986 | 4998 |
4987 (defun message-generate-headers (headers) | 4999 (defun message-generate-headers (headers) |
4988 "Prepare article HEADERS. | 5000 "Prepare article HEADERS. |
4989 Headers already prepared in the buffer are not modified." | 5001 Headers already prepared in the buffer are not modified." |