(require 'mail-utils)
(require 'rfc2047)
(require 'auth-source)
+(require 'rfc6068)
(declare-function compilation--message->loc "compile" (cl-x) t)
(declare-function epa--find-coding-system-for-mime-charset "epa" (mime-charset))
(define-key map [menu-bar mail]
(cons "Mail" (make-sparse-keymap "Mail")))
+ (define-key map [menu-bar mail mailing-list]
+ (cons "Mailing List" (make-sparse-keymap "Mailing List")))
+
+ (define-key map [menu-bar mail mailing-list list-help]
+ '(menu-item "Mailing List Help" rmail-mailing-list-help
+ :enable (rmail-get-header "List-Help")
+ :help "Compose email requesting help about this mailing list"))
+
+ (define-key map [menu-bar mail mailing-list list-archive]
+ '(menu-item "Mailing List Archive" rmail-mailing-list-archive
+ :enable (rmail-get-header "List-Archive")
+ :help "Browse the archive of this mailing list"))
+
+ (define-key map [menu-bar mail mailing-list list-unsubscribe]
+ '(menu-item "Unsubscribe From List" rmail-mailing-list-unsubscribe
+ :enable (rmail-get-header "List-Unsubscribe")
+ :help "Compose email to unsubscribe from this mailing list"))
+
+ (define-key map [menu-bar mail mailing-list list-post]
+ '(menu-item "Post To List" rmail-mailing-list-post
+ :enable (rmail-get-header "List-Post")
+ :help "Compose email to post to this mailing list"))
+
+ (define-key map [menu-bar mail lambda1]
+ '("----"))
+
(define-key map [menu-bar mail rmail-get-new-mail]
'("Get New Mail" . rmail-get-new-mail))
- (define-key map [menu-bar mail lambda]
+ (define-key map [menu-bar mail lambda2]
'("----"))
(define-key map [menu-bar mail continue]
(setq buffer-file-coding-system rmail-message-encoding))))
(add-hook 'after-save-hook 'rmail-after-save-hook)
+\f
+;;; Mailing list support
+(defun rmail--mailing-list-message (which)
+ "Send a message to mailing list whose purpose is identified by WHICH.
+WHICH is a symbol, one of `help', `unsubscribe', or `post'."
+ (let ((header
+ (cond ((eq which 'help) "List-Help")
+ ((eq which 'unsubscribe) "List-Unsubscribe")
+ ((eq which 'post) "List-Post")))
+ (msg
+ (cond ((eq which 'post)
+ "Write Subject and body, then type \\[%s] to send the message.")
+ (t
+ "Type \\[%s] to send the message.")))
+ address header-list to subject)
+ (setq address (rmail-get-header header))
+ (cond ((and address (string-match "<\\(mailto:[^>]*\\)>" address))
+ (setq address (match-string 1 address))
+ (setq header-list (rfc6068-parse-mailto-url address)
+ to (cdr (assoc-string "To" header-list t))
+ subject (or (cdr (assoc-string "Subject" header-list t)) ""))
+ (rmail-start-mail nil to subject nil nil rmail-buffer)
+ (message (substitute-command-keys
+ (format msg (get mail-user-agent 'sendfunc)))))
+ (t
+ (user-error "This message does not specify \"%s\" address"
+ header)))))
+
+(defun rmail-mailing-list-help ()
+ "Send Help request to the mailing list which delivered the current message.
+This command starts composing an email message to the mailing list
+requesting help about the list. When the message is ready, send it
+as usual, via your MUA's send-email command."
+ (interactive nil rmail-mode)
+ (rmail--mailing-list-message 'help))
+
+(defun rmail-mailing-list-post ()
+ "Post a message to the mailing list which delivered the current message.
+This command starts composing an email message to the mailing list.
+Fill the Subject and the body of the message. When the message is
+ready, send it as usual, via your MUA's send-email command."
+ (interactive nil rmail-mode)
+ (rmail--mailing-list-message 'post))
+
+(defun rmail-mailing-list-unsubscribe ()
+ "Send unsubscribe request to the mailing list which delivered current message.
+This command starts composing an email message to the mailing list
+requesting to unsubscribe you from the list. When the message is
+ready, send it as usual, via your MUA's send-email command."
+ (interactive nil rmail-mode)
+ (rmail--mailing-list-message 'unsubscribe))
+
+(defun rmail-mailing-list-archive ()
+ "Browse the archive of the mailing list which delivered the current message."
+ (interactive nil rmail-mode)
+ (let* ((header (rmail-get-header "List-Archive"))
+ (url (and (stringp header)
+ (string-match " *<\\([^>]*\\)>" header)
+ (match-string 1 header))))
+ (if url
+ (browse-url url)
+ (user-error
+ "This message does not specify a valid \"List-Archive\" URL"))))
(provide 'rmail)