]> git.eshelyaron.com Git - emacs.git/commitdiff
Only save the mailer choice after sending the mail
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 15 Apr 2018 18:42:44 +0000 (20:42 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 15 Apr 2018 18:42:44 +0000 (20:42 +0200)
* lisp/mail/sendmail.el (sendmail-query-once): Only save the
mailer choice after we've sent the mail, so that if that fails,
the user has an easy way to back out of the choice and make
another (bug#14487).
(sendmail-query-user-about-smtp): Return the choice; don't save it.

lisp/mail/sendmail.el

index cfbefd91d93dc85da9d216983fc6a150b2523b53..c9f8fec1e1bede45727c7523f0894226d3bdf46d 100644 (file)
@@ -505,9 +505,13 @@ This also saves the value of `send-mail-function' via Customize."
   ;; If send-mail-function is already setup, we're incorrectly called
   ;; a second time, probably because someone's using an old value
   ;; of send-mail-function.
-  (when (eq send-mail-function 'sendmail-query-once)
-    (sendmail-query-user-about-smtp))
-  (funcall send-mail-function))
+  (if (not (eq send-mail-function 'sendmail-query-once))
+      (funcall send-mail-function)
+    (let ((function (sendmail-query-user-about-smtp)))
+      (funcall function)
+      (when (y-or-n-p "Save this mail sending choice?")
+        (setq send-mail-function function)
+        (customize-save-variable 'send-mail-function function)))))
 
 (defun sendmail-query-user-about-smtp ()
   (let* ((options `(("mail client" . mailclient-send-it)
@@ -552,8 +556,8 @@ This also saves the value of `send-mail-function' via Customize."
               (completing-read
                (format "Send mail via (default %s): " (caar options))
                options nil 'require-match nil nil (car options))))))
-    (customize-save-variable 'send-mail-function
-                            (cdr (assoc-string choice options t)))))
+    ;; Return the choice.
+    (cdr (assoc-string choice options t))))
 \f
 (defun sendmail-sync-aliases ()
   (when mail-personal-alias-file