Mercurial > emacs
annotate lisp/gnus/gnus-ml.el @ 100260:c663881a61c6
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1490
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 06 Dec 2008 17:26:18 +0000 |
parents | f42ef85caf91 |
children | a9dc0e7c3f2b |
rev | line source |
---|---|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1 ;;; gnus-ml.el --- Mailing list minor mode for Gnus |
31717 | 2 |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
79708 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Julien Gilles <jgilles@free.fr> | |
71262 | 7 ;; Keywords: news, mail |
31717 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
31717 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
31717 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
31717 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; implement (small subset of) RFC 2369 | |
27 | |
28 ;;; Code: | |
29 | |
30 (require 'gnus) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
31 (require 'gnus-msg) |
31717 | 32 (eval-when-compile (require 'cl)) |
33 | |
34 ;;; Mailing list minor mode | |
35 | |
36 (defvar gnus-mailing-list-mode nil | |
37 "Minor mode for providing mailing-list commands.") | |
38 | |
39 (defvar gnus-mailing-list-mode-map nil) | |
40 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
41 (defvar gnus-mailing-list-menu) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
42 |
31717 | 43 (unless gnus-mailing-list-mode-map |
44 (setq gnus-mailing-list-mode-map (make-sparse-keymap)) | |
45 | |
46 (gnus-define-keys gnus-mailing-list-mode-map | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
47 "\C-c\C-nh" gnus-mailing-list-help |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
48 "\C-c\C-ns" gnus-mailing-list-subscribe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
49 "\C-c\C-nu" gnus-mailing-list-unsubscribe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
50 "\C-c\C-np" gnus-mailing-list-post |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
51 "\C-c\C-no" gnus-mailing-list-owner |
71262 | 52 "\C-c\C-na" gnus-mailing-list-archive)) |
31717 | 53 |
54 (defun gnus-mailing-list-make-menu-bar () | |
55 (unless (boundp 'gnus-mailing-list-menu) | |
56 (easy-menu-define | |
57 gnus-mailing-list-menu gnus-mailing-list-mode-map "" | |
58 '("Mailing-Lists" | |
59 ["Get help" gnus-mailing-list-help t] | |
60 ["Subscribe" gnus-mailing-list-subscribe t] | |
61 ["Unsubscribe" gnus-mailing-list-unsubscribe t] | |
62 ["Post a message" gnus-mailing-list-post t] | |
63 ["Mail to owner" gnus-mailing-list-owner t] | |
64 ["Browse archive" gnus-mailing-list-archive t])))) | |
65 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
66 ;;;###autoload |
31717 | 67 (defun turn-on-gnus-mailing-list-mode () |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
68 (when (gnus-group-find-parameter gnus-newsgroup-name 'to-list) |
31717 | 69 (gnus-mailing-list-mode 1))) |
70 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
71 ;;;###autoload |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
72 (defun gnus-mailing-list-insinuate (&optional force) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
73 "Setup group parameters from List-Post header. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
74 If FORCE is non-nil, replace the old ones." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
75 (interactive "P") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
76 (let ((list-post |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
77 (with-current-buffer gnus-original-article-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
78 (gnus-fetch-field "list-post")))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
79 (if list-post |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
80 (if (and (not force) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
81 (gnus-group-get-parameter gnus-newsgroup-name 'to-list)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
82 (gnus-message 1 "to-list is non-nil.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
83 (if (string-match "<mailto:\\([^>]*\\)>" list-post) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
84 (setq list-post (match-string 1 list-post))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
85 (gnus-group-add-parameter gnus-newsgroup-name |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
86 (cons 'to-list list-post)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
87 (gnus-mailing-list-mode 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
88 (gnus-message 1 "no list-post in this message.")))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
89 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
90 ;;;###autoload |
31717 | 91 (defun gnus-mailing-list-mode (&optional arg) |
92 "Minor mode for providing mailing-list commands. | |
93 | |
94 \\{gnus-mailing-list-mode-map}" | |
95 (interactive "P") | |
96 (when (eq major-mode 'gnus-summary-mode) | |
97 (when (set (make-local-variable 'gnus-mailing-list-mode) | |
98 (if (null arg) (not gnus-mailing-list-mode) | |
99 (> (prefix-numeric-value arg) 0))) | |
100 ;; Set up the menu. | |
101 (when (gnus-visual-p 'mailing-list-menu 'menu) | |
102 (gnus-mailing-list-make-menu-bar)) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
103 (add-minor-mode 'gnus-mailing-list-mode " Mailing-List" |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
104 gnus-mailing-list-mode-map) |
31717 | 105 (gnus-run-hooks 'gnus-mailing-list-mode-hook)))) |
106 | |
107 ;;; Commands | |
108 | |
109 (defun gnus-mailing-list-help () | |
110 "Get help from mailing list server." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
111 (interactive) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
112 (let ((list-help |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
113 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
114 (gnus-fetch-field "list-help")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
115 (cond (list-help (gnus-mailing-list-message list-help)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
116 (t (gnus-message 1 "no list-help in this group"))))) |
31717 | 117 |
118 (defun gnus-mailing-list-subscribe () | |
71262 | 119 "Subscribe to mailing list." |
31717 | 120 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
121 (let ((list-subscribe |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
122 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
123 (gnus-fetch-field "list-subscribe")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
124 (cond (list-subscribe (gnus-mailing-list-message list-subscribe)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
125 (t (gnus-message 1 "no list-subscribe in this group"))))) |
31717 | 126 |
127 (defun gnus-mailing-list-unsubscribe () | |
71262 | 128 "Unsubscribe from mailing list." |
31717 | 129 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
130 (let ((list-unsubscribe |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
131 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
132 (gnus-fetch-field "list-unsubscribe")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
133 (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
134 (t (gnus-message 1 "no list-unsubscribe in this group"))))) |
31717 | 135 |
136 (defun gnus-mailing-list-post () | |
137 "Post message (really useful ?)" | |
138 (interactive) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
139 (let ((list-post |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
140 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
141 (gnus-fetch-field "list-post")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
142 (cond (list-post (gnus-mailing-list-message list-post)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
143 (t (gnus-message 1 "no list-post in this group"))))) |
31717 | 144 |
145 (defun gnus-mailing-list-owner () | |
71262 | 146 "Mail to the mailing list owner." |
31717 | 147 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
148 (let ((list-owner |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
149 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
150 (gnus-fetch-field "list-owner")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
151 (cond (list-owner (gnus-mailing-list-message list-owner)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
152 (t (gnus-message 1 "no list-owner in this group"))))) |
31717 | 153 |
154 (defun gnus-mailing-list-archive () | |
71262 | 155 "Browse archive." |
31717 | 156 (interactive) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
157 (require 'browse-url) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
158 (let ((list-archive |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
159 (with-current-buffer gnus-original-article-buffer |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
160 (gnus-fetch-field "list-archive")))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
161 (cond (list-archive |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
162 (if (string-match "<\\(http:[^>]*\\)>" list-archive) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
163 (browse-url (match-string 1 list-archive)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
164 (browse-url list-archive))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
165 (t (gnus-message 1 "no list-archive in this group"))))) |
31717 | 166 |
167 ;;; Utility functions | |
168 | |
169 (defun gnus-mailing-list-message (address) | |
71262 | 170 "Send message to ADDRESS. |
171 ADDRESS is specified by a \"mailto:\" URL." | |
172 (cond | |
173 ((string-match "<\\(mailto:[^>]*\\)>" address) | |
174 (require 'gnus-art) | |
175 (gnus-url-mailto (match-string 1 address))) | |
176 ;; other case <http://...> to be done. | |
177 (t nil))) | |
31717 | 178 |
179 (provide 'gnus-ml) | |
180 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
181 ;; arch-tag: 936c0fe6-acce-4c16-87d0-eded88078896 |
31717 | 182 ;;; gnus-ml.el ends here |