1 ;;; gnus-ml.el --- Mailing list minor mode for Gnus
3 ;; Copyright (C) 2000-2013 Free Software Foundation, Inc.
5 ;; Author: Julien Gilles <jgilles@free.fr>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
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 3 of the License, or
13 ;; (at your option) any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; implement (small subset of) RFC 2369
31 (eval-when-compile (require 'cl
))
33 (when (featurep 'xemacs
)
34 (require 'easy-mmode
))) ; for `define-minor-mode'
36 ;;; Mailing list minor mode
38 (defvar gnus-mailing-list-mode-map
39 (let ((map (make-sparse-keymap)))
41 "\C-c\C-nh" gnus-mailing-list-help
42 "\C-c\C-ns" gnus-mailing-list-subscribe
43 "\C-c\C-nu" gnus-mailing-list-unsubscribe
44 "\C-c\C-np" gnus-mailing-list-post
45 "\C-c\C-no" gnus-mailing-list-owner
46 "\C-c\C-na" gnus-mailing-list-archive
)
49 (defvar gnus-mailing-list-menu
)
51 (defun gnus-mailing-list-make-menu-bar ()
52 (unless (boundp 'gnus-mailing-list-menu
)
54 gnus-mailing-list-menu gnus-mailing-list-mode-map
""
56 ["Get help" gnus-mailing-list-help t
]
57 ["Subscribe" gnus-mailing-list-subscribe t
]
58 ["Unsubscribe" gnus-mailing-list-unsubscribe t
]
59 ["Post a message" gnus-mailing-list-post t
]
60 ["Mail to owner" gnus-mailing-list-owner t
]
61 ["Browse archive" gnus-mailing-list-archive t
]))))
64 (defun turn-on-gnus-mailing-list-mode ()
65 (when (gnus-group-find-parameter gnus-newsgroup-name
'to-list
)
66 (gnus-mailing-list-mode 1)))
69 (defun gnus-mailing-list-insinuate (&optional force
)
70 "Setup group parameters from List-Post header.
71 If FORCE is non-nil, replace the old ones."
74 (with-current-buffer gnus-original-article-buffer
75 (gnus-fetch-field "list-post"))))
78 (gnus-group-get-parameter gnus-newsgroup-name
'to-list
))
79 (gnus-message 1 "to-list is non-nil.")
80 (if (string-match "<mailto:\\([^>]*\\)>" list-post
)
81 (setq list-post
(match-string 1 list-post
)))
82 (gnus-group-add-parameter gnus-newsgroup-name
83 (cons 'to-list list-post
))
84 (gnus-mailing-list-mode 1))
85 (gnus-message 1 "no list-post in this message."))))
88 (when (featurep 'xemacs
)
89 (defvar gnus-mailing-list-mode-hook
)
90 (defvar gnus-mailing-list-mode-on-hook
)
91 (defvar gnus-mailing-list-mode-off-hook
)))
94 (define-minor-mode gnus-mailing-list-mode
95 "Minor mode for providing mailing-list commands.
97 \\{gnus-mailing-list-mode-map}"
98 :lighter
" Mailing-List"
99 :keymap gnus-mailing-list-mode-map
101 ((not (derived-mode-p 'gnus-summary-mode
))
102 (setq gnus-mailing-list-mode nil
))
103 (gnus-mailing-list-mode
105 (when (gnus-visual-p 'mailing-list-menu
'menu
)
106 (gnus-mailing-list-make-menu-bar)))))
110 (defun gnus-mailing-list-help ()
111 "Get help from mailing list server."
114 (with-current-buffer gnus-original-article-buffer
115 (gnus-fetch-field "list-help"))))
116 (cond (list-help (gnus-mailing-list-message list-help
))
117 (t (gnus-message 1 "no list-help in this group")))))
119 (defun gnus-mailing-list-subscribe ()
120 "Subscribe to mailing list."
122 (let ((list-subscribe
123 (with-current-buffer gnus-original-article-buffer
124 (gnus-fetch-field "list-subscribe"))))
125 (cond (list-subscribe (gnus-mailing-list-message list-subscribe
))
126 (t (gnus-message 1 "no list-subscribe in this group")))))
128 (defun gnus-mailing-list-unsubscribe ()
129 "Unsubscribe from mailing list."
131 (let ((list-unsubscribe
132 (with-current-buffer gnus-original-article-buffer
133 (gnus-fetch-field "list-unsubscribe"))))
134 (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe
))
135 (t (gnus-message 1 "no list-unsubscribe in this group")))))
137 (defun gnus-mailing-list-post ()
138 "Post message (really useful ?)"
141 (with-current-buffer gnus-original-article-buffer
142 (gnus-fetch-field "list-post"))))
143 (cond (list-post (gnus-mailing-list-message list-post
))
144 (t (gnus-message 1 "no list-post in this group")))))
146 (defun gnus-mailing-list-owner ()
147 "Mail to the mailing list owner."
150 (with-current-buffer gnus-original-article-buffer
151 (gnus-fetch-field "list-owner"))))
152 (cond (list-owner (gnus-mailing-list-message list-owner
))
153 (t (gnus-message 1 "no list-owner in this group")))))
155 (defun gnus-mailing-list-archive ()
158 (require 'browse-url
)
160 (with-current-buffer gnus-original-article-buffer
161 (gnus-fetch-field "list-archive"))))
163 (if (string-match "<\\(http:[^>]*\\)>" list-archive
)
164 (browse-url (match-string 1 list-archive
))
165 (browse-url list-archive
)))
166 (t (gnus-message 1 "no list-archive in this group")))))
168 ;;; Utility functions
170 (defun gnus-mailing-list-message (address)
171 "Send message to ADDRESS.
172 ADDRESS is specified by a \"mailto:\" URL."
174 ((string-match "<\\(mailto:[^>]*\\)>" address
)
176 (gnus-url-mailto (match-string 1 address
)))
177 ;; other case <http://...> to be done.
182 ;;; gnus-ml.el ends here