Synch to No Gnus 200410041929.
[elisp/gnus.git-] / lisp / message.el
index 740bc5f..6c77352 100644 (file)
@@ -40,7 +40,8 @@
   (require 'cl)
   (require 'smtp)
   (defvar gnus-message-group-art)
-  (defvar gnus-list-identifiers)) ; gnus-sum is required where necessary
+  (defvar gnus-list-identifiers) ; gnus-sum is required where necessary
+  (require 'hashcash))
 (require 'canlock)
 (require 'mailheader)
 (require 'nnheader)
@@ -1636,6 +1637,13 @@ no, only reply back to the author."
                 (const :tag "Never" nil)
                 (const :tag "Always" t)))
 
+(defcustom message-generate-hashcash nil
+  "*Whether to generate X-Hashcash: headers.
+You must have the \"hashcash\" binary installed, see `hashcash-path'."
+  :group 'message-headers
+  :link '(custom-manual "(message)Mail Headers")
+  :type 'boolean)
+
 ;;; Internal variables.
 
 (defvar message-sending-message "Sending...")
@@ -3598,8 +3606,7 @@ be added to the \"References\" field."
        ;; Insert a blank line if it is peeled off.
        (insert "\n")))
     (goto-char start)
-    (while functions
-      (funcall (pop functions)))
+    (mapc 'funcall functions)
     (when message-citation-line-function
       (unless (bolp)
        (insert "\n"))
@@ -3630,8 +3637,7 @@ be added to the \"References\" field."
                                  "unknown sender"))
        (setq x-no-archive (message-fetch-field "x-no-archive")))
       (goto-char start)
-      (while functions
-       (funcall (pop functions)))
+      (mapc 'funcall functions)
       (when message-citation-line-function
        (unless (bolp)
          (insert "\n"))
@@ -4079,16 +4085,15 @@ not have PROP."
 (defun message-do-actions (actions)
   "Perform all actions in ACTIONS."
   ;; Now perform actions on successful sending.
-  (while actions
+  (dolist (action actions)
     (ignore-errors
       (cond
        ;; A simple function.
-       ((functionp (car actions))
-       (funcall (car actions)))
+       ((functionp action)
+       (funcall action))
        ;; Something to be evaled.
        (t
-       (eval (car actions)))))
-    (pop actions)))
+       (eval action))))))
 
 (defsubst message-maybe-split-and-send-mail ()
   "Split a message if necessary, and send it via mail.
@@ -4215,6 +4220,13 @@ This sub function is for exclusive use of `message-send-mail'."
         (message-this-is-mail t)
         (headers message-required-mail-headers)
         failure)
+    (when message-generate-hashcash
+      (save-restriction
+       (message-narrow-to-headers)
+       (message-remove-header "X-Hashcash"))
+      (message "Generating hashcash...")
+      (mail-add-payment)
+      (message "Generating hashcash...done"))
     (save-restriction
       (message-narrow-to-headers)
       ;; Generate the Mail-Followup-To header if the header is not there...
@@ -5858,7 +5870,7 @@ they are."
     ;; When sending via news, make sure the total folded length will
     ;; be less than 998 characters.  This is to cater to broken INN
     ;; 2.3 which counts the total number of characters in a header
-    ;; rather than the physical line length of each line, as it shuld.
+    ;; rather than the physical line length of each line, as it should.
     ;;
     ;; This hack should be removed when it's believed than INN 2.3 is
     ;; no longer widely used.
@@ -6856,18 +6868,17 @@ the message."
                      subject
                    (nnheader-decode-subject subject))
                ""))
-       (if message-wash-forwarded-subjects
-           (setq subject (message-wash-subject subject)))
+       (when message-wash-forwarded-subjects
+         (setq subject (message-wash-subject subject)))
        ;; Make sure funcs is a list.
        (and funcs
             (not (listp funcs))
             (setq funcs (list funcs)))
        ;; Apply funcs in order, passing subject generated by previous
        ;; func to the next one.
-       (while funcs
-         (when (functionp (car funcs))
-           (setq subject (funcall (car funcs) subject)))
-         (setq funcs (cdr funcs)))
+       (dolist (func funcs)
+         (when (functionp func)
+           (setq subject (funcall func subject))))
        subject))))
 
 ;;;###autoload