31717
|
1 ;;; gnus-ml.el --- Mailing list minor mode for Gnus
|
|
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
|
|
29 ;;; Code:
|
|
30
|
|
31 (require 'gnus)
|
|
32 (eval-when-compile (require 'cl))
|
|
33
|
|
34 ;;; Mailing list minor mode
|
|
35
|
|
36 (defvar gnus-mailing-list-mode nil
|
|
37 "Minor mode for providing mailing-list commands.")
|
|
38
|
|
39 (defvar gnus-mailing-list-mode-map nil)
|
|
40
|
|
41 (unless gnus-mailing-list-mode-map
|
|
42 (setq gnus-mailing-list-mode-map (make-sparse-keymap))
|
|
43
|
|
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
|
|
51 ))
|
|
52
|
|
53 (defun gnus-mailing-list-make-menu-bar ()
|
|
54 (unless (boundp 'gnus-mailing-list-menu)
|
|
55 (easy-menu-define
|
|
56 gnus-mailing-list-menu gnus-mailing-list-mode-map ""
|
|
57 '("Mailing-Lists"
|
|
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]))))
|
|
64
|
|
65 (defun turn-on-gnus-mailing-list-mode ()
|
|
66 (when (gnus-group-get-parameter group 'to-list)
|
|
67 (gnus-mailing-list-mode 1)))
|
|
68
|
|
69 (defun gnus-mailing-list-mode (&optional arg)
|
|
70 "Minor mode for providing mailing-list commands.
|
|
71
|
|
72 \\{gnus-mailing-list-mode-map}"
|
|
73 (interactive "P")
|
|
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)))
|
|
78 ;; Set up the menu.
|
|
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))))
|
|
83
|
|
84 ;;; Commands
|
|
85
|
|
86 (defun gnus-mailing-list-help ()
|
|
87 "Get help from mailing list server."
|
|
88 (interactive)
|
|
89 (cond (list-help (gnus-mailing-list-message list-help))
|
|
90 (t (display-message 'no-log "no list-help in this group"))))
|
|
91
|
|
92 (defun gnus-mailing-list-subscribe ()
|
|
93 "Subscribe"
|
|
94 (interactive)
|
|
95 (cond (list-subscribe (gnus-mailing-list-message list-subscribe))
|
|
96 (t (display-message 'no-log "no list-subscribe in this group"))))
|
|
97
|
|
98
|
|
99 (defun gnus-mailing-list-unsubscribe ()
|
|
100 "Unsubscribe"
|
|
101 (interactive)
|
|
102 (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe))
|
|
103 (t (display-message 'no-log "no list-unsubscribe in this group"))))
|
|
104
|
|
105 (defun gnus-mailing-list-post ()
|
|
106 "Post message (really useful ?)"
|
|
107 (interactive)
|
|
108 (cond (list-post (gnus-mailing-list-message list-post))
|
|
109 (t (display-message 'no-log "no list-post in this group")))
|
|
110 )
|
|
111
|
|
112 (defun gnus-mailing-list-owner ()
|
|
113 "Mail to the owner"
|
|
114 (interactive)
|
|
115 (cond (list-owner (gnus-mailing-list-message list-owner))
|
|
116 (t (display-message 'no-log "no list-owner in this group")))
|
|
117 )
|
|
118
|
|
119 (defun gnus-mailing-list-archive ()
|
|
120 "Browse archive"
|
|
121 (interactive)
|
|
122 (cond (list-archive (gnus-mailing-list-message list-archive))
|
|
123 (t (display-message 'no-log "no list-owner in this group")))
|
|
124 )
|
|
125
|
|
126 ;;; Utility functions
|
|
127
|
|
128 (defun gnus-xmas-mailing-list-menu-add ()
|
|
129 (gnus-xmas-menu-add mailing-list
|
|
130 gnus-mailing-list-menu))
|
|
131
|
|
132 (add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add)
|
|
133
|
|
134 (defun gnus-mailing-list-message (address)
|
|
135 ""
|
|
136 (let ((mailto "")
|
|
137 (to ())
|
|
138 (subject "None")
|
|
139 (body "")
|
|
140 )
|
|
141 (cond
|
|
142 ((string-match "<mailto:\\([^>]*\\)>" address)
|
|
143 (let ((args (match-string 1 address)))
|
|
144 (cond ; with param
|
|
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))
|
|
154 ))
|
|
155 (t (setq mailto args))))) ; without param
|
|
156
|
|
157 ; other case <http://... to be done.
|
|
158 (t nil))
|
|
159 (gnus-setup-message 'message (message-mail mailto subject))
|
|
160 (insert body)
|
|
161 ))
|
|
162
|
|
163 (provide 'gnus-ml)
|
|
164
|
|
165 ;;; gnus-ml.el ends here
|