Subject: bug#25874: 24.4; sendmail-query-user-about-smtp allows nil function

From: [email-masked]
Date: Sun, 26 Feb 2017 22:26:11 -0500

tags 25874 patch
quit

[email-masked] writes:

> 3. Emacs will prompt "Send mail via: "
>
>    (This is sendmail.el:sendmail-query-user-about-smtp asking how you
>    would like to send mail. Valid responses are: "mail client",
>    "transport", or "smtp")
>
> 4. Hit the Enter key, assuming Emacs will pick a reasonable default
>
> 5. Be surprised when you get a mysterious error message:

How about making Emacs give a reasonable default then:

>From 449169796a4a14abc4ff34aa78c5308b53ee20a3 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Sun, 26 Feb 2017 22:17:28 -0500
Subject: [PATCH v1] Set default when asking for send-mail-function
 (Bug#25874).

* lisp/mail/sendmail.el (sendmail-query-user-about-smtp): Pass first
option as default for `completing-read'.
---
 lisp/mail/sendmail.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 70c8ea1f93..42b688fbab 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -555,8 +555,9 @@ sendmail-query-user-about-smtp
 	    (goto-char (point-min))
 	    (display-buffer (current-buffer))
 	    (let ((completion-ignore-case t))
-	      (completing-read "Send mail via: "
-			       options nil 'require-match)))))
+              (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)))))
 
-- 
2.11.1