Changes committed gnus/lisp (ChangeLog message.el)

"Reiner Steib" <[email protected]>
Newsgroups gmane.emacs.gnus.commits
Message-ID <[email protected]>
Modified: ChangeLog message.el

(message-form-letter-separator)
(message-send-form-letter-delay): New variables.
(message-send-form-letter): Use them.  New command to send form
letters.  Requested by Uwe Siart.


Index: ChangeLog
diff -u gnus/lisp/ChangeLog:7.1766 gnus/lisp/ChangeLog:7.1767
--- ChangeLog:7.1766	Sat Mar  1 02:48:13 2008
+++ ChangeLog	Sun Mar  2 14:58:15 2008
@@ -1,3 +1,10 @@
+2008-03-02  Reiner Steib  <[email protected]>
+
+	* message.el (message-form-letter-separator)
+	(message-send-form-letter-delay): New variables.
+	(message-send-form-letter): Use them.  New command to send form
+	letters.  Requested by Uwe Siart.
+
 2008-02-29  Andreas Seltenreich  <[email protected]>
 
 	* nnweb.el (nnweb-google-parse-1): Fix date parsing on articles with
Index: message.el
diff -u gnus/lisp/message.el:7.241 gnus/lisp/message.el:7.242
--- message.el:7.241	Sat Mar  1 02:48:13 2008
+++ message.el	Sun Mar  2 14:58:15 2008
@@ -7807,6 +7807,95 @@
 	(delete-region start end)
 	(insert match)))))
 
+
+;; To send pre-formatted letters like the example below, you can use
+;; `message-send-form-letter':
+;; --8<---------------cut here---------------start------------->8---
+;; To: [email protected]
+;; Subject: Verification of your contact information
+;; From: Contact verification <[email protected]>
+;; --text follows this line--
+;; Hi Alice,
+;; please verify that your contact information is still valid:
+;; Alice A, A avenue 11, 1111 A town, Austria
+;; ----------next form letter message follows this line----------
+;; To: [email protected]
+;; Subject: Verification of your contact information
+;; From: Contact verification <[email protected]>
+;; --text follows this line--
+;; Hallo Bob,
+;; please verify that your contact information is still valid:
+;; Bob, B street 22, 22222 Be town, Belgium
+;; ----------next form letter message follows this line----------
+;; To: [email protected]
+;; Subject: Verification of your contact information
+;; From: Contact verification <[email protected]>
+;; --text follows this line--
+;; Hi Charlie,
+;; please verify that your contact information is still valid:
+;; Charlie Chaplin, C plaza 33, 33333 C town, Chile
+;; --8<---------------cut here---------------end--------------->8---
+
+;; FIXME: What is the most common term (circular letter, form letter, serial
+;; letter, standard letter) for such kind of letter?  See also
+;; <http://en.wikipedia.org/wiki/Form_letter>
+
+(defcustom message-form-letter-separator
+  "\n----------next form letter message follows this line----------\n"
+  "Separator for `message-send-form-letter'."
+  ;; :group 'message-form-letter
+  :group 'message-various
+  :version "23.1" ;; No Gnus
+  :type 'string)
+
+(defcustom message-send-form-letter-delay 1
+  "Delay in seconds when sending a message with `message-send-form-letter'.
+Only used when `message-send-form-letter' is called with non-nil
+argument `force'."
+  ;; :group 'message-form-letter
+  :group 'message-various
+  :version "23.1" ;; No Gnus
+  :type 'integer)
+
+(defun message-send-form-letter (&optional force)
+  "Sent all form letter messages from current buffer.
+Unless FORCE, prompt before sending.
+
+The messages are separated by `message-form-letter-separator'.
+Header and body are separated by `mail-header-separator'."
+  (interactive "P")
+  (let ((sent 0) (skipped 0)
+	start end text
+	buff
+	to done)
+    (goto-char (point-min))
+    (while (not done)
+      (setq start (point)
+	    end (if (search-forward message-form-letter-separator nil t)
+		    (- (point) (length message-form-letter-separator) -1)
+		  (setq done t)
+		  (point-max)))
+      (setq text
+	    (buffer-substring-no-properties start end))
+      (setq buff (generate-new-buffer "*mail - form letter*"))
+      (with-current-buffer buff
+	(insert text)
+	(message-mode)
+	(setq to (message-fetch-field "To"))
+	(switch-to-buffer buff)
+	(when force
+	  (sit-for message-send-form-letter-delay))
+	(if (or force
+		  (y-or-n-p (format "Send message to `%s'? " to)))
+	    (progn
+	      (setq sent (1+ sent))
+	      (message-send-and-exit))
+	  (message (format "Message to `%s' skipped." to))
+	  (setq skipped (1+ skipped)))
+	(when (buffer-live-p buff)
+	  (kill-buffer buff))))
+    (message "%s message(s) sent, %s skipped." sent skipped)))
+
 (when (featurep 'xemacs)
   (require 'messagexmas)
   (message-xmas-redefine))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.