X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;ds=sidebyside;f=lisp%2Fgnus-ml.el;h=d99680f5924d426366ae88f94d476043708f85f2;hb=328bdcc7ef80844d091a42062f46952b8458367f;hp=645f218e9652eaf13af86fb9decb12f0b1d9193c;hpb=227dd529d6f999e2f49d9b0c93ce5fef64114433;p=gnus diff --git a/lisp/gnus-ml.el b/lisp/gnus-ml.el index 645f218e9..d99680f59 100644 --- a/lisp/gnus-ml.el +++ b/lisp/gnus-ml.el @@ -1,23 +1,24 @@ -;;; gnus-ml.el --- Mailing list minor mode for gnus +;;; gnus-ml.el --- Mailing list minor mode for Gnus -;; Copyright (C) 2000 by Julien Gilles +;; Copyright (C) 2000-2011 Free Software Foundation, Inc. ;; Author: Julien Gilles -;; Keywords: news +;; Keywords: news, mail -;; This program is free software; you can redistribute it and/or modify +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2 of the License, or +;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. -;; This program is distributed in the hope that it will be useful, +;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with this program; if not, write to the Free Software -;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -26,26 +27,26 @@ ;;; Code: (require 'gnus) +(require 'gnus-msg) (eval-when-compile (require 'cl)) +(eval-when-compile + (when (featurep 'xemacs) + (require 'easy-mmode))) ; for `define-minor-mode' ;;; Mailing list minor mode -(defvar gnus-mailing-list-mode nil - "Minor mode for providing mailing-list commands.") - -(defvar gnus-mailing-list-mode-map nil) - -(unless gnus-mailing-list-mode-map - (setq gnus-mailing-list-mode-map (make-sparse-keymap)) +(defvar gnus-mailing-list-mode-map + (let ((map (make-sparse-keymap))) + (gnus-define-keys map + "\C-c\C-nh" gnus-mailing-list-help + "\C-c\C-ns" gnus-mailing-list-subscribe + "\C-c\C-nu" gnus-mailing-list-unsubscribe + "\C-c\C-np" gnus-mailing-list-post + "\C-c\C-no" gnus-mailing-list-owner + "\C-c\C-na" gnus-mailing-list-archive) + map)) - (gnus-define-keys gnus-mailing-list-mode-map - "\C-nh" gnus-mailing-list-help - "\C-ns" gnus-mailing-list-subscribe - "\C-nu" gnus-mailing-list-unsubscribe - "\C-np" gnus-mailing-list-post - "\C-no" gnus-mailing-list-owner - "\C-na" gnus-mailing-list-archive - )) +(defvar gnus-mailing-list-menu) (defun gnus-mailing-list-make-menu-bar () (unless (boundp 'gnus-mailing-list-menu) @@ -59,103 +60,122 @@ ["Mail to owner" gnus-mailing-list-owner t] ["Browse archive" gnus-mailing-list-archive t])))) +;;;###autoload (defun turn-on-gnus-mailing-list-mode () - (when (gnus-group-get-parameter group 'to-list) + (when (gnus-group-find-parameter gnus-newsgroup-name 'to-list) (gnus-mailing-list-mode 1))) -(defun gnus-mailing-list-mode (&optional arg) +;;;###autoload +(defun gnus-mailing-list-insinuate (&optional force) + "Setup group parameters from List-Post header. +If FORCE is non-nil, replace the old ones." + (interactive "P") + (let ((list-post + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-post")))) + (if list-post + (if (and (not force) + (gnus-group-get-parameter gnus-newsgroup-name 'to-list)) + (gnus-message 1 "to-list is non-nil.") + (if (string-match "]*\\)>" list-post) + (setq list-post (match-string 1 list-post))) + (gnus-group-add-parameter gnus-newsgroup-name + (cons 'to-list list-post)) + (gnus-mailing-list-mode 1)) + (gnus-message 1 "no list-post in this message.")))) + +(eval-when-compile + (when (featurep 'xemacs) + (defvar gnus-mailing-list-mode-hook) + (defvar gnus-mailing-list-mode-on-hook) + (defvar gnus-mailing-list-mode-off-hook))) + +;;;###autoload +(define-minor-mode gnus-mailing-list-mode "Minor mode for providing mailing-list commands. \\{gnus-mailing-list-mode-map}" - (interactive "P") - (when (eq major-mode 'gnus-summary-mode) - (when (set (make-local-variable 'gnus-mailing-list-mode) - (if (null arg) (not gnus-mailing-list-mode) - (> (prefix-numeric-value arg) 0))) - ;; Set up the menu. - (when (gnus-visual-p 'mailing-list-menu 'menu) - (gnus-mailing-list-make-menu-bar)) - (gnus-add-minor-mode 'gnus-mailing-list-mode " Mailing-List" gnus-mailing-list-mode-map) - (gnus-run-hooks 'gnus-mailing-list-mode-hook)))) + :lighter " Mailing-List" + :keymap gnus-mailing-list-mode-map + (cond + ((not (derived-mode-p 'gnus-summary-mode)) + (setq gnus-mailing-list-mode nil)) + (gnus-mailing-list-mode + ;; Set up the menu. + (when (gnus-visual-p 'mailing-list-menu 'menu) + (gnus-mailing-list-make-menu-bar))))) ;;; Commands (defun gnus-mailing-list-help () "Get help from mailing list server." - (interactive) - (cond (list-help (gnus-mailing-list-message list-help)) - (t (display-message 'no-log "no list-help in this group")))) + (interactive) + (let ((list-help + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-help")))) + (cond (list-help (gnus-mailing-list-message list-help)) + (t (gnus-message 1 "no list-help in this group"))))) (defun gnus-mailing-list-subscribe () - "Subscribe" + "Subscribe to mailing list." (interactive) - (cond (list-subscribe (gnus-mailing-list-message list-subscribe)) - (t (display-message 'no-log "no list-subscribe in this group")))) - + (let ((list-subscribe + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-subscribe")))) + (cond (list-subscribe (gnus-mailing-list-message list-subscribe)) + (t (gnus-message 1 "no list-subscribe in this group"))))) (defun gnus-mailing-list-unsubscribe () - "Unsubscribe" + "Unsubscribe from mailing list." (interactive) - (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe)) - (t (display-message 'no-log "no list-unsubscribe in this group")))) + (let ((list-unsubscribe + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-unsubscribe")))) + (cond (list-unsubscribe (gnus-mailing-list-message list-unsubscribe)) + (t (gnus-message 1 "no list-unsubscribe in this group"))))) (defun gnus-mailing-list-post () "Post message (really useful ?)" (interactive) - (cond (list-post (gnus-mailing-list-message list-post)) - (t (display-message 'no-log "no list-post in this group"))) - ) + (let ((list-post + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-post")))) + (cond (list-post (gnus-mailing-list-message list-post)) + (t (gnus-message 1 "no list-post in this group"))))) (defun gnus-mailing-list-owner () - "Mail to the owner" + "Mail to the mailing list owner." (interactive) - (cond (list-owner (gnus-mailing-list-message list-owner)) - (t (display-message 'no-log "no list-owner in this group"))) - ) + (let ((list-owner + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-owner")))) + (cond (list-owner (gnus-mailing-list-message list-owner)) + (t (gnus-message 1 "no list-owner in this group"))))) (defun gnus-mailing-list-archive () - "Browse archive" + "Browse archive." (interactive) - (cond (list-archive (gnus-mailing-list-message list-archive)) - (t (display-message 'no-log "no list-owner in this group"))) - ) + (require 'browse-url) + (let ((list-archive + (with-current-buffer gnus-original-article-buffer + (gnus-fetch-field "list-archive")))) + (cond (list-archive + (if (string-match "<\\(http:[^>]*\\)>" list-archive) + (browse-url (match-string 1 list-archive)) + (browse-url list-archive))) + (t (gnus-message 1 "no list-archive in this group"))))) ;;; Utility functions -(defun gnus-xmas-mailing-list-menu-add () - (gnus-xmas-menu-add mailing-list - gnus-mailing-list-menu)) - -(add-hook 'gnus-mailing-list-mode-hook 'gnus-xmas-mailing-list-menu-add) - (defun gnus-mailing-list-message (address) - "" - (let ((mailto "") - (to ()) - (subject "None") - (body "") - ) - (cond - ((string-match "]*\\)>" address) - (let ((args (match-string 1 address))) - (cond ; with param - ((string-match "\\(.*\\)\\?\\(.*\\)" args) - (setq mailto (match-string 1 args)) - (let ((param (match-string 2 args))) - (if (string-match "subject=\\([^&]*\\)" param) - (setq subject (match-string 1 param))) - (if (string-match "body=\\([^&]*\\)" param) - (setq body (match-string 1 param))) - (if (string-match "to=\\([^&]*\\)" param) - (push (match-string 1 param) to)) - )) - (t (setq mailto args))))) ; without param - - ; other case ]*\\)>" address) + (require 'gnus-art) + (gnus-url-mailto (match-string 1 address))) + ;; other case to be done. + (t nil))) (provide 'gnus-ml)