Mercurial > emacs
annotate lisp/gnus/gnus-ml.el @ 38857:0999a3a48e17
(defcustom): Doc fix.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 17 Aug 2001 10:58:17 +0000 |
parents | a26d9b55abb6 |
children | 0d8b17d428b5 |
rev | line source |
---|---|
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
33269
diff
changeset
|
1 ;;; gnus-ml.el --- mailing list minor mode for Gnus |
31717 | 2 |
3 ;; Copyright (C) 2000 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Julien Gilles <jgilles@free.fr> | |
6 ;; Keywords: news | |
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 2, or (at your option) | |
13 ;; 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; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; implement (small subset of) RFC 2369 | |
28 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
29 ;;; Usage: |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
30 |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
31 ;; (add-hook 'gnus-summary-mode-hook 'turn-on-gnus-mailing-list-mode) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
32 |
31717 | 33 ;;; Code: |
34 | |
35 (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
|
36 (require 'gnus-msg) |
31717 | 37 (eval-when-compile (require 'cl)) |
38 | |
39 ;;; Mailing list minor mode | |
40 | |
41 (defvar gnus-mailing-list-mode nil | |
42 "Minor mode for providing mailing-list commands.") | |
43 | |
44 (defvar gnus-mailing-list-mode-map nil) | |
45 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
46 (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
|
47 |
31717 | 48 (unless gnus-mailing-list-mode-map |
49 (setq gnus-mailing-list-mode-map (make-sparse-keymap)) | |
50 | |
51 (gnus-define-keys gnus-mailing-list-mode-map | |
52 "\C-nh" gnus-mailing-list-help | |
53 "\C-ns" gnus-mailing-list-subscribe | |
54 "\C-nu" gnus-mailing-list-unsubscribe | |
55 "\C-np" gnus-mailing-list-post | |
56 "\C-no" gnus-mailing-list-owner | |
57 "\C-na" gnus-mailing-list-archive | |
58 )) | |
59 | |
60 (defun gnus-mailing-list-make-menu-bar () | |
61 (unless (boundp 'gnus-mailing-list-menu) | |
62 (easy-menu-define | |
63 gnus-mailing-list-menu gnus-mailing-list-mode-map "" | |
64 '("Mailing-Lists" | |
65 ["Get help" gnus-mailing-list-help t] | |
66 ["Subscribe" gnus-mailing-list-subscribe t] | |
67 ["Unsubscribe" gnus-mailing-list-unsubscribe t] | |
68 ["Post a message" gnus-mailing-list-post t] | |
69 ["Mail to owner" gnus-mailing-list-owner t] | |
70 ["Browse archive" gnus-mailing-list-archive t])))) | |
71 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
72 ;;;###autoload |
31717 | 73 (defun turn-on-gnus-mailing-list-mode () |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
74 (when (gnus-group-get-parameter gnus-newsgroup-name 'to-list) |
31717 | 75 (gnus-mailing-list-mode 1))) |
76 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
77 ;;;###autoload |
31717 | 78 (defun gnus-mailing-list-mode (&optional arg) |
79 "Minor mode for providing mailing-list commands. | |
80 | |
81 \\{gnus-mailing-list-mode-map}" | |
82 (interactive "P") | |
83 (when (eq major-mode 'gnus-summary-mode) | |
84 (when (set (make-local-variable 'gnus-mailing-list-mode) | |
85 (if (null arg) (not gnus-mailing-list-mode) | |
86 (> (prefix-numeric-value arg) 0))) | |
87 ;; Set up the menu. | |
88 (when (gnus-visual-p 'mailing-list-menu 'menu) | |
89 (gnus-mailing-list-make-menu-bar)) | |
90 (gnus-add-minor-mode 'gnus-mailing-list-mode " Mailing-List" gnus-mailing-list-mode-map) | |
91 (gnus-run-hooks 'gnus-mailing-list-mode-hook)))) | |
92 | |
93 ;;; Commands | |
94 | |
95 (defun gnus-mailing-list-help () | |
96 "Get help from mailing list server." | |
97 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
98 (let ((list-help |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
99 (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
|
100 (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
|
101 (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
|
102 (t (gnus-message 1 "no list-help in this group"))))) |
31717 | 103 |
104 (defun gnus-mailing-list-subscribe () | |
105 "Subscribe" | |
106 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
107 (let ((list-subscribe |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
108 (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
|
109 (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
|
110 (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
|
111 (t (gnus-message 1 "no list-subscribe in this group"))))) |
31717 | 112 |
113 (defun gnus-mailing-list-unsubscribe () | |
114 "Unsubscribe" | |
115 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
116 (let ((list-unsubscribe |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
117 (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
|
118 (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
|
119 (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
|
120 (t (gnus-message 1 "no list-unsubscribe in this group"))))) |
31717 | 121 |
122 (defun gnus-mailing-list-post () | |
123 "Post message (really useful ?)" | |
124 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
125 (let ((list-post |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
126 (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
|
127 (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
|
128 (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
|
129 (t (gnus-message 1 "no list-post in this group"))))) |
31717 | 130 |
131 (defun gnus-mailing-list-owner () | |
132 "Mail to the owner" | |
133 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
134 (let ((list-owner |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
135 (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
|
136 (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
|
137 (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
|
138 (t (gnus-message 1 "no list-owner in this group"))))) |
31717 | 139 |
140 (defun gnus-mailing-list-archive () | |
141 "Browse archive" | |
142 (interactive) | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
143 (let ((list-archive |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
144 (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
|
145 (gnus-fetch-field "list-archive")))) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
146 (cond (list-archive (gnus-mailing-list-message list-archive)) |
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
147 (t (gnus-message 1 "no list-owner in this group"))))) |
31717 | 148 |
149 ;;; Utility functions | |
150 | |
151 (defun gnus-mailing-list-message (address) | |
152 "" | |
153 (let ((mailto "") | |
154 (to ()) | |
155 (subject "None") | |
156 (body "") | |
157 ) | |
158 (cond | |
159 ((string-match "<mailto:\\([^>]*\\)>" address) | |
160 (let ((args (match-string 1 address))) | |
161 (cond ; with param | |
162 ((string-match "\\(.*\\)\\?\\(.*\\)" args) | |
163 (setq mailto (match-string 1 args)) | |
164 (let ((param (match-string 2 args))) | |
165 (if (string-match "subject=\\([^&]*\\)" param) | |
166 (setq subject (match-string 1 param))) | |
167 (if (string-match "body=\\([^&]*\\)" param) | |
168 (setq body (match-string 1 param))) | |
169 (if (string-match "to=\\([^&]*\\)" param) | |
170 (push (match-string 1 param) to)) | |
171 )) | |
172 (t (setq mailto args))))) ; without param | |
173 | |
174 ; other case <http://... to be done. | |
175 (t nil)) | |
176 (gnus-setup-message 'message (message-mail mailto subject)) | |
177 (insert body) | |
178 )) | |
179 | |
180 (provide 'gnus-ml) | |
181 | |
182 ;;; gnus-ml.el ends here |