1 ;;; gnus-ml.el --- Mailing list minor mode for Gnus
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
5 ;; Author: Julien Gilles <jgilles@free.fr>
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 2, or (at your option)
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; 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.
27 ;; implement (small subset of) RFC 2369
32 (eval-when-compile (require 'cl
))
34 ;;; Mailing list minor mode
36 (defvar gnus-mailing-list-mode nil
37 "Minor mode for providing mailing-list commands.")
39 (defvar gnus-mailing-list-mode-map nil
)
41 (unless gnus-mailing-list-mode-map
42 (setq gnus-mailing-list-mode-map
(make-sparse-keymap))
44 (gnus-define-keys gnus-mailing-list-mode-map
45 "\C-nh" gnus-mailing-list-help
46 "\C-ns" gnus-mailing-list-subscribe
47 "\C-nu" gnus-mailing-list-unsubscribe
48 "\C-np" gnus-mailing-list-post
49 "\C-no" gnus-mailing-list-owner
50 "\C-na" gnus-mailing-list-archive
53 (defun gnus-mailing-list-make-menu-bar ()
54 (unless (boundp 'gnus-mailing-list-menu
)
56 gnus-mailing-list-menu gnus-mailing-list-mode-map
""
58 ["Get help" gnus-mailing-list-help t
]
59 ["Subscribe" gnus-mailing-list-subscribe t
]
60 ["Unsubscribe" gnus-mailing-list-unsubscribe t
]
61 ["Post a message" gnus-mailing-list-post t
]
62 ["Mail to owner" gnus-mailing-list-owner t
]
63 ["Browse archive" gnus-mailing-list-archive t
]))))
65 (defun turn-on-gnus-mailing-list-mode ()
66 (when (gnus-group-get-parameter group
'to-list
)
67 (gnus-mailing-list-mode 1)))
69 (defun gnus-mailing-list-mode (&optional arg
)
70 "Minor mode for providing mailing-list commands.
72 \\{gnus-mailing-list-mode-map}"
74 (when (eq major-mode
'gnus-summary-mode
)
75 (when (set (make-local-variable 'gnus-mailing-list-mode
)
76 (if (null arg
) (not gnus-mailing-list-mode
)
77 (> (prefix-numeric-value arg
) 0)))
79 (when (gnus-visual-p 'mailing-list-menu
'menu
)
80 (gnus-mailing-list-make-menu-bar))
81 (gnus-add-minor-mode 'gnus-mailing-list-mode
" Mailing-List" gnus-mailing-list-mode-map
)
82 (gnus-run-hooks 'gnus-mailing-list-mode-hook
))))
86 (defun gnus-mailing-list-help ()
87 "Get help from mailing list server."
89 (cond (list-help (gnus-mailing-list-message list-help
))
90 (t (display-message 'no-log
"no list-help in this group"))))
92 (defun gnus-mailing-list-subscribe ()
95 (cond (list-subscribe (gnus-mailing-list-message list-subscribe
))
96 (t (display-message 'no-log
"no list-subscribe in this group"))))
99 (defun gnus-mailing-list-unsubscribe ()
102 (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe
))
103 (t (display-message 'no-log
"no list-unsubscribe in this group"))))
105 (defun gnus-mailing-list-post ()
106 "Post message (really useful ?)"
108 (cond (list-post (gnus-mailing-list-message list-post
))
109 (t (display-message 'no-log
"no list-post in this group")))
112 (defun gnus-mailing-list-owner ()
115 (cond (list-owner (gnus-mailing-list-message list-owner
))
116 (t (display-message 'no-log
"no list-owner in this group")))
119 (defun gnus-mailing-list-archive ()
122 (cond (list-archive (gnus-mailing-list-message list-archive
))
123 (t (display-message 'no-log
"no list-owner in this group")))
126 ;;; Utility functions
128 (defun gnus-xmas-mailing-list-menu-add ()
129 (gnus-xmas-menu-add mailing-list
130 gnus-mailing-list-menu
))
132 (add-hook 'gnus-mailing-list-mode-hook
'gnus-xmas-mailing-list-menu-add
)
134 (defun gnus-mailing-list-message (address)
142 ((string-match "<mailto:\\([^>]*\\)>" address
)
143 (let ((args (match-string 1 address
)))
145 ((string-match "\\(.*\\)\\?\\(.*\\)" args
)
146 (setq mailto
(match-string 1 args
))
147 (let ((param (match-string 2 args
)))
148 (if (string-match "subject=\\([^&]*\\)" param
)
149 (setq subject
(match-string 1 param
)))
150 (if (string-match "body=\\([^&]*\\)" param
)
151 (setq body
(match-string 1 param
)))
152 (if (string-match "to=\\([^&]*\\)" param
)
153 (push (match-string 1 param
) to
))
155 (t (setq mailto args
))))) ; without param
157 ; other case <http://... to be done.
159 (gnus-setup-message 'message
(message-mail mailto subject
))
165 ;;; gnus-ml.el ends here