Mercurial > emacs
annotate lisp/gnus/gnus-ml.el @ 88256:db2e6586ecf5
(rmail-msgbeg, rmail-msgend): Fix and make obsolete.
(rmail-process-new-messages): Use mail-decode-encoded-word-string
on the subject. Requires mail-parse from Gnus.
(rmail-highlight-headers): Doc.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Sat, 21 Jan 2006 15:00:38 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
88155 | 1 ;;; gnus-ml.el --- Mailing list minor mode for Gnus |
31717 | 2 |
88155 | 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
31717 | 5 |
6 ;; Author: Julien Gilles <jgilles@free.fr> | |
7 ;; Keywords: news | |
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 | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 | |
88155 | 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 | |
88155 | 49 "\C-c\C-nh" gnus-mailing-list-help |
50 "\C-c\C-ns" gnus-mailing-list-subscribe | |
51 "\C-c\C-nu" gnus-mailing-list-unsubscribe | |
52 "\C-c\C-np" gnus-mailing-list-post | |
53 "\C-c\C-no" gnus-mailing-list-owner | |
54 "\C-c\C-na" gnus-mailing-list-archive | |
31717 | 55 )) |
56 | |
57 (defun gnus-mailing-list-make-menu-bar () | |
58 (unless (boundp 'gnus-mailing-list-menu) | |
59 (easy-menu-define | |
60 gnus-mailing-list-menu gnus-mailing-list-mode-map "" | |
61 '("Mailing-Lists" | |
62 ["Get help" gnus-mailing-list-help t] | |
63 ["Subscribe" gnus-mailing-list-subscribe t] | |
64 ["Unsubscribe" gnus-mailing-list-unsubscribe t] | |
65 ["Post a message" gnus-mailing-list-post t] | |
66 ["Mail to owner" gnus-mailing-list-owner t] | |
67 ["Browse archive" gnus-mailing-list-archive t])))) | |
68 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
69 ;;;###autoload |
31717 | 70 (defun turn-on-gnus-mailing-list-mode () |
88155 | 71 (when (gnus-group-find-parameter gnus-newsgroup-name 'to-list) |
31717 | 72 (gnus-mailing-list-mode 1))) |
73 | |
33269
d551fdccd8bc
2000-10-01 08:32:42 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
74 ;;;###autoload |
88155 | 75 (defun gnus-mailing-list-insinuate (&optional force) |
76 "Setup group parameters from List-Post header. | |
77 If FORCE is non-nil, replace the old ones." | |
78 (interactive "P") | |
79 (let ((list-post | |
80 (with-current-buffer gnus-original-article-buffer | |
81 (gnus-fetch-field "list-post")))) | |
82 (if list-post | |
83 (if (and (not force) | |
84 (gnus-group-get-parameter gnus-newsgroup-name 'to-list)) | |
85 (gnus-message 1 "to-list is non-nil.") | |
86 (if (string-match "<mailto:\\([^>]*\\)>" list-post) | |
87 (setq list-post (match-string 1 list-post))) | |
88 (gnus-group-add-parameter gnus-newsgroup-name | |
89 (cons 'to-list list-post)) | |
90 (gnus-mailing-list-mode 1)) | |
91 (gnus-message 1 "no list-post in this message.")))) | |
92 | |
93 ;;;###autoload | |
31717 | 94 (defun gnus-mailing-list-mode (&optional arg) |
95 "Minor mode for providing mailing-list commands. | |
96 | |
97 \\{gnus-mailing-list-mode-map}" | |
98 (interactive "P") | |
99 (when (eq major-mode 'gnus-summary-mode) | |
100 (when (set (make-local-variable 'gnus-mailing-list-mode) | |
101 (if (null arg) (not gnus-mailing-list-mode) | |
102 (> (prefix-numeric-value arg) 0))) | |
103 ;; Set up the menu. | |
104 (when (gnus-visual-p 'mailing-list-menu 'menu) | |
105 (gnus-mailing-list-make-menu-bar)) | |
106 (gnus-add-minor-mode 'gnus-mailing-list-mode " Mailing-List" gnus-mailing-list-mode-map) | |
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 () | |
121 "Subscribe" | |
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 () | |
130 "Unsubscribe" | |
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 () | |
148 "Mail to the owner" | |
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 () | |
157 "Browse archive" | |
158 (interactive) | |
88155 | 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")))) |
88155 | 163 (cond (list-archive |
164 (if (string-match "<\\(http:[^>]*\\)>" list-archive) | |
165 (browse-url (match-string 1 list-archive)) | |
166 (browse-url list-archive))) | |
167 (t (gnus-message 1 "no list-archive in this group"))))) | |
31717 | 168 |
169 ;;; Utility functions | |
170 | |
171 (defun gnus-mailing-list-message (address) | |
172 "" | |
173 (let ((mailto "") | |
174 (to ()) | |
175 (subject "None") | |
176 (body "") | |
177 ) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
178 (cond |
31717 | 179 ((string-match "<mailto:\\([^>]*\\)>" address) |
180 (let ((args (match-string 1 address))) | |
88155 | 181 (cond ; with param |
31717 | 182 ((string-match "\\(.*\\)\\?\\(.*\\)" args) |
183 (setq mailto (match-string 1 args)) | |
184 (let ((param (match-string 2 args))) | |
185 (if (string-match "subject=\\([^&]*\\)" param) | |
186 (setq subject (match-string 1 param))) | |
187 (if (string-match "body=\\([^&]*\\)" param) | |
188 (setq body (match-string 1 param))) | |
189 (if (string-match "to=\\([^&]*\\)" param) | |
190 (push (match-string 1 param) to)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
191 )) |
88155 | 192 (t (setq mailto args))))) ; without param |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
193 |
31717 | 194 ; other case <http://... to be done. |
195 (t nil)) | |
196 (gnus-setup-message 'message (message-mail mailto subject)) | |
197 (insert body) | |
198 )) | |
199 | |
200 (provide 'gnus-ml) | |
201 | |
88155 | 202 ;;; arch-tag: 936c0fe6-acce-4c16-87d0-eded88078896 |
31717 | 203 ;;; gnus-ml.el ends here |