Mercurial > emacs
annotate lisp/gnus/gnus-ml.el @ 91555:21d9f8ca293c
Update copyright years and GPL version.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 06 Feb 2008 04:22:47 +0000 |
parents | 107ccd98fa12 |
children | 606f2d163a64 1e3a407766b9 |
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 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
78224
24202b793a08
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
31717 | 14 ;; any later version. |
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 | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31717 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; implement (small subset of) RFC 2369 | |
29 | |
30 ;;; Code: | |
31 | |
32 (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
|
33 (require 'gnus-msg) |
31717 | 34 (eval-when-compile (require 'cl)) |
35 | |
36 ;;; Mailing list minor mode | |
37 | |
38 (defvar gnus-mailing-list-mode nil | |
39 "Minor mode for providing mailing-list commands.") | |
40 | |
41 (defvar gnus-mailing-list-mode-map nil) | |
42 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
43 (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
|
44 |
31717 | 45 (unless gnus-mailing-list-mode-map |
46 (setq gnus-mailing-list-mode-map (make-sparse-keymap)) | |
47 | |
48 (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
|
49 "\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
|
50 "\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
|
51 "\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
|
52 "\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
|
53 "\C-c\C-no" gnus-mailing-list-owner |
71262 | 54 "\C-c\C-na" gnus-mailing-list-archive)) |
31717 | 55 |
56 (defun gnus-mailing-list-make-menu-bar () | |
57 (unless (boundp 'gnus-mailing-list-menu) | |
58 (easy-menu-define | |
59 gnus-mailing-list-menu gnus-mailing-list-mode-map "" | |
60 '("Mailing-Lists" | |
61 ["Get help" gnus-mailing-list-help t] | |
62 ["Subscribe" gnus-mailing-list-subscribe t] | |
63 ["Unsubscribe" gnus-mailing-list-unsubscribe t] | |
64 ["Post a message" gnus-mailing-list-post t] | |
65 ["Mail to owner" gnus-mailing-list-owner t] | |
66 ["Browse archive" gnus-mailing-list-archive t])))) | |
67 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
68 ;;;###autoload |
31717 | 69 (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
|
70 (when (gnus-group-find-parameter gnus-newsgroup-name 'to-list) |
31717 | 71 (gnus-mailing-list-mode 1))) |
72 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
73 ;;;###autoload |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
74 (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
|
75 "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
|
76 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
|
77 (interactive "P") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
78 (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
|
79 (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
|
80 (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
|
81 (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
|
82 (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
|
83 (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
|
84 (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
|
85 (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
|
86 (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
|
87 (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
|
88 (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
|
89 (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
|
90 (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
|
91 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
92 ;;;###autoload |
31717 | 93 (defun gnus-mailing-list-mode (&optional arg) |
94 "Minor mode for providing mailing-list commands. | |
95 | |
96 \\{gnus-mailing-list-mode-map}" | |
97 (interactive "P") | |
98 (when (eq major-mode 'gnus-summary-mode) | |
99 (when (set (make-local-variable 'gnus-mailing-list-mode) | |
100 (if (null arg) (not gnus-mailing-list-mode) | |
101 (> (prefix-numeric-value arg) 0))) | |
102 ;; Set up the menu. | |
103 (when (gnus-visual-p 'mailing-list-menu 'menu) | |
104 (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
|
105 (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
|
106 gnus-mailing-list-mode-map) |
31717 | 107 (gnus-run-hooks 'gnus-mailing-list-mode-hook)))) |
108 | |
109 ;;; Commands | |
110 | |
111 (defun gnus-mailing-list-help () | |
112 "Get help from mailing list server." | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
113 (interactive) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
114 (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
|
115 (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
|
116 (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
|
117 (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
|
118 (t (gnus-message 1 "no list-help in this group"))))) |
31717 | 119 |
120 (defun gnus-mailing-list-subscribe () | |
71262 | 121 "Subscribe to mailing list." |
31717 | 122 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
123 (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
|
124 (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
|
125 (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
|
126 (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
|
127 (t (gnus-message 1 "no list-subscribe in this group"))))) |
31717 | 128 |
129 (defun gnus-mailing-list-unsubscribe () | |
71262 | 130 "Unsubscribe from mailing list." |
31717 | 131 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
132 (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
|
133 (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
|
134 (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
|
135 (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
|
136 (t (gnus-message 1 "no list-unsubscribe in this group"))))) |
31717 | 137 |
138 (defun gnus-mailing-list-post () | |
139 "Post message (really useful ?)" | |
140 (interactive) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
141 (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
|
142 (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
|
143 (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
|
144 (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
|
145 (t (gnus-message 1 "no list-post in this group"))))) |
31717 | 146 |
147 (defun gnus-mailing-list-owner () | |
71262 | 148 "Mail to the mailing list owner." |
31717 | 149 (interactive) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
150 (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
|
151 (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
|
152 (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
|
153 (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
|
154 (t (gnus-message 1 "no list-owner in this group"))))) |
31717 | 155 |
156 (defun gnus-mailing-list-archive () | |
71262 | 157 "Browse archive." |
31717 | 158 (interactive) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
159 (require 'browse-url) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
160 (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
|
161 (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
|
162 (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
|
163 (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
|
164 (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
|
165 (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
|
166 (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
|
167 (t (gnus-message 1 "no list-archive in this group"))))) |
31717 | 168 |
169 ;;; Utility functions | |
170 | |
171 (defun gnus-mailing-list-message (address) | |
71262 | 172 "Send message to ADDRESS. |
173 ADDRESS is specified by a \"mailto:\" URL." | |
174 (cond | |
175 ((string-match "<\\(mailto:[^>]*\\)>" address) | |
176 (require 'gnus-art) | |
177 (gnus-url-mailto (match-string 1 address))) | |
178 ;; other case <http://...> to be done. | |
179 (t nil))) | |
31717 | 180 |
181 (provide 'gnus-ml) | |
182 | |
52401 | 183 ;;; arch-tag: 936c0fe6-acce-4c16-87d0-eded88078896 |
31717 | 184 ;;; gnus-ml.el ends here |