aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-05-21 13:57:14 +0300
committerEli Zaretskii2023-05-21 13:57:14 +0300
commit71622d70e8bd0f4289df098a8d9b3ab06f4bdcc0 (patch)
tree0bf3d878e6b1bc8f7c2e9bc08471b011e65c4489
parentf8cdb9e05067fba5dee193ac604e75a67a7ff2c9 (diff)
downloademacs-71622d70e8bd0f4289df098a8d9b3ab06f4bdcc0.tar.gz
emacs-71622d70e8bd0f4289df098a8d9b3ab06f4bdcc0.zip
New Rmail commands for reading mailing-lists
* lisp/mail/rmail.el (rmail--mailing-list-message): New internal function. (rmail-mailing-list-help, rmail-mailing-list-post) (rmail-mailing-list-unsubscribe, rmail-mailing-list-archive): New commands. (rmail-mode-map): Add menu items for the new commands. * etc/NEWS: Announce the new Rmail commands.
-rw-r--r--etc/NEWS9
-rw-r--r--lisp/mail/rmail.el92
2 files changed, 100 insertions, 1 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 04ef976a8d1..7729dbc79fa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -333,6 +333,15 @@ instead of:
333*** New ':vc' keyword. 333*** New ':vc' keyword.
334This keyword enables the user to install packages using 'package-vc'. 334This keyword enables the user to install packages using 'package-vc'.
335 335
336** Rmail
337
338---
339*** New commands for reading mailing lists.
340The new Rmail commands 'rmail-mailing-list-post',
341'rmail-mailing-list-unsubscribe', 'rmail-mailing-list-help', and
342'rmail-mailing-list-archive allow to, respectively, post to,
343unsubscribe from, request help about, and browse the archives, of the
344mailing list from which the current email message was delivered.
336 345
337* New Modes and Packages in Emacs 30.1 346* New Modes and Packages in Emacs 30.1
338 347
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index d07a1fda901..872299c2415 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -40,6 +40,7 @@
40(require 'mail-utils) 40(require 'mail-utils)
41(require 'rfc2047) 41(require 'rfc2047)
42(require 'auth-source) 42(require 'auth-source)
43(require 'rfc6068)
43 44
44(declare-function compilation--message->loc "compile" (cl-x) t) 45(declare-function compilation--message->loc "compile" (cl-x) t)
45(declare-function epa--find-coding-system-for-mime-charset "epa" (mime-charset)) 46(declare-function epa--find-coding-system-for-mime-charset "epa" (mime-charset))
@@ -1120,10 +1121,36 @@ The buffer is expected to be narrowed to just the header of the message."
1120 (define-key map [menu-bar mail] 1121 (define-key map [menu-bar mail]
1121 (cons "Mail" (make-sparse-keymap "Mail"))) 1122 (cons "Mail" (make-sparse-keymap "Mail")))
1122 1123
1124 (define-key map [menu-bar mail mailing-list]
1125 (cons "Mailing List" (make-sparse-keymap "Mailing List")))
1126
1127 (define-key map [menu-bar mail mailing-list list-help]
1128 '(menu-item "Mailing List Help" rmail-mailing-list-help
1129 :enable (rmail-get-header "List-Help")
1130 :help "Compose email requesting help about this mailing list"))
1131
1132 (define-key map [menu-bar mail mailing-list list-archive]
1133 '(menu-item "Mailing List Archive" rmail-mailing-list-archive
1134 :enable (rmail-get-header "List-Archive")
1135 :help "Browse the archive of this mailing list"))
1136
1137 (define-key map [menu-bar mail mailing-list list-unsubscribe]
1138 '(menu-item "Unsubscribe From List" rmail-mailing-list-unsubscribe
1139 :enable (rmail-get-header "List-Unsubscribe")
1140 :help "Compose email to unsubscribe from this mailing list"))
1141
1142 (define-key map [menu-bar mail mailing-list list-post]
1143 '(menu-item "Post To List" rmail-mailing-list-post
1144 :enable (rmail-get-header "List-Post")
1145 :help "Compose email to post to this mailing list"))
1146
1147 (define-key map [menu-bar mail lambda1]
1148 '("----"))
1149
1123 (define-key map [menu-bar mail rmail-get-new-mail] 1150 (define-key map [menu-bar mail rmail-get-new-mail]
1124 '("Get New Mail" . rmail-get-new-mail)) 1151 '("Get New Mail" . rmail-get-new-mail))
1125 1152
1126 (define-key map [menu-bar mail lambda] 1153 (define-key map [menu-bar mail lambda2]
1127 '("----")) 1154 '("----"))
1128 1155
1129 (define-key map [menu-bar mail continue] 1156 (define-key map [menu-bar mail continue]
@@ -4765,6 +4792,69 @@ Content-Transfer-Encoding: base64\n")
4765 (setq buffer-file-coding-system rmail-message-encoding)))) 4792 (setq buffer-file-coding-system rmail-message-encoding))))
4766(add-hook 'after-save-hook 'rmail-after-save-hook) 4793(add-hook 'after-save-hook 'rmail-after-save-hook)
4767 4794
4795
4796;;; Mailing list support
4797(defun rmail--mailing-list-message (which)
4798 "Send a message to mailing list whose purpose is identified by WHICH.
4799WHICH is a symbol, one of `help', `unsubscribe', or `post'."
4800 (let ((header
4801 (cond ((eq which 'help) "List-Help")
4802 ((eq which 'unsubscribe) "List-Unsubscribe")
4803 ((eq which 'post) "List-Post")))
4804 (msg
4805 (cond ((eq which 'post)
4806 "Write Subject and body, then type \\[%s] to send the message.")
4807 (t
4808 "Type \\[%s] to send the message.")))
4809 address header-list to subject)
4810 (setq address (rmail-get-header header))
4811 (cond ((and address (string-match "<\\(mailto:[^>]*\\)>" address))
4812 (setq address (match-string 1 address))
4813 (setq header-list (rfc6068-parse-mailto-url address)
4814 to (cdr (assoc-string "To" header-list t))
4815 subject (or (cdr (assoc-string "Subject" header-list t)) ""))
4816 (rmail-start-mail nil to subject nil nil rmail-buffer)
4817 (message (substitute-command-keys
4818 (format msg (get mail-user-agent 'sendfunc)))))
4819 (t
4820 (user-error "This message does not specify \"%s\" address"
4821 header)))))
4822
4823(defun rmail-mailing-list-help ()
4824 "Send Help request to the mailing list which delivered the current message.
4825This command starts composing an email message to the mailing list
4826requesting help about the list. When the message is ready, send it
4827as usual, via your MUA's send-email command."
4828 (interactive nil rmail-mode)
4829 (rmail--mailing-list-message 'help))
4830
4831(defun rmail-mailing-list-post ()
4832 "Post a message to the mailing list which delivered the current message.
4833This command starts composing an email message to the mailing list.
4834Fill the Subject and the body of the message. When the message is
4835ready, send it as usual, via your MUA's send-email command."
4836 (interactive nil rmail-mode)
4837 (rmail--mailing-list-message 'post))
4838
4839(defun rmail-mailing-list-unsubscribe ()
4840 "Send unsubscribe request to the mailing list which delivered current message.
4841This command starts composing an email message to the mailing list
4842requesting to unsubscribe you from the list. When the message is
4843ready, send it as usual, via your MUA's send-email command."
4844 (interactive nil rmail-mode)
4845 (rmail--mailing-list-message 'unsubscribe))
4846
4847(defun rmail-mailing-list-archive ()
4848 "Browse the archive of the mailing list which delivered the current message."
4849 (interactive nil rmail-mode)
4850 (let* ((header (rmail-get-header "List-Archive"))
4851 (url (and (stringp header)
4852 (string-match " *<\\([^>]*\\)>" header)
4853 (match-string 1 header))))
4854 (if url
4855 (browse-url url)
4856 (user-error
4857 "This message does not specify a valid \"List-Archive\" URL"))))
4768 4858
4769(provide 'rmail) 4859(provide 'rmail)
4770 4860