From: Chong Yidong Date: Sat, 3 Sep 2011 20:24:12 +0000 (-0400) Subject: Make sendmail-query-once update send-mail-function directly. X-Git-Tag: emacs-pretest-24.0.90~104^2~155^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2784c43403c278a542a9f930a4da07a4a2ca284c;p=emacs.git Make sendmail-query-once update send-mail-function directly. * mail/sendmail.el (sendmail-query-once-function): Deleted. (sendmail-query-once): Save directly to send-mail-function. Update message-send-mail-function too. * mail/smtpmail.el (smtpmail-try-auth-methods): Clarify prompt. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3c27b51dfdf..c1d943ccaf0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2011-09-03 Chong Yidong + + * mail/sendmail.el (sendmail-query-once-function): Deleted. + (sendmail-query-once): Save directly to send-mail-function. + Update message-send-mail-function too. + + * mail/smtpmail.el (smtpmail-try-auth-methods): Clarify prompt. + 2011-09-03 Christoph Scholtes * progmodes/python.el (python-mode-map): Use correct function to diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 158435de86b..cb02a4b374d 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -156,51 +156,6 @@ This is used by the default mail-sending commands. See also :version "24.1" :group 'sendmail) -(defvar sendmail-query-once-function 'query - "Either a function to send email, or the symbol `query'.") - -;;;###autoload -(defun sendmail-query-once () - "Send an email via `sendmail-query-once-function'. -If `sendmail-query-once-function' is `query', ask the user what -function to use, and then save that choice." - (when (equal sendmail-query-once-function 'query) - (let* ((mail-buffer (current-buffer)) - (default - (cond - ((or (and window-system (eq system-type 'darwin)) - (eq system-type 'windows-nt)) - 'mailclient-send-it) - ((and sendmail-program - (executable-find sendmail-program)) - 'sendmail-send-it))) - (function - (if (or (not default) - ;; We have detected no OS-level mail senders, or we - ;; have already configured smtpmail, so we use the - ;; internal SMTP service. - (and (boundp 'smtpmail-smtp-server) - smtpmail-smtp-server)) - 'smtpmail-send-it - ;; Query the user. - (unwind-protect - (progn - (pop-to-buffer "*Mail Help*") - (erase-buffer) - (insert "Sending mail from Emacs hasn't been set up yet.\n\n" - "Type `y' to configure outgoing SMTP, or `n' to use\n" - "the default mail sender on your system.\n\n" - "To change this again at a later date, customize the\n" - "`send-mail-function' variable.\n") - (goto-char (point-min)) - (if (y-or-n-p "Configure outgoing SMTP in Emacs? ") - 'smtpmail-send-it - default)) - (kill-buffer (current-buffer)) - (set-buffer mail-buffer))))) - (customize-save-variable 'sendmail-query-once-function function))) - (funcall sendmail-query-once-function)) - ;;;###autoload (defcustom mail-header-separator (purecopy "--text follows this line--") "Line used to separate headers from text in messages being composed." @@ -543,6 +498,51 @@ by Emacs.)") "Additional expressions to highlight in Mail mode.") +;;;###autoload +(defun sendmail-query-once () + "Query for `send-mail-function' and send mail with it. +This also saves the value of `send-mail-function' via Customize." + (let* ((mail-buffer (current-buffer)) + ;; Compute default mail sender, preferring smtpmail if it's + ;; already configured. + (default (cond + ((and (boundp 'smtpmail-smtp-server) + smtpmail-smtp-server) + 'smtpmail-send-it) + ((or (and window-system (eq system-type 'darwin)) + (eq system-type 'windows-nt)) + 'mailclient-send-it) + ((and sendmail-program + (executable-find sendmail-program)) + 'sendmail-send-it))) + (send-function (if (eq default 'smtpmail-send-it) + 'smtpmail-send-it))) + (unless send-function + ;; Query the user. + (with-temp-buffer + (rename-buffer "*Mail Help*" t) + (erase-buffer) + (insert "Emacs has not been set up for sending mail.\n +Type `y' to configure and use Emacs as a mail client, +or `n' to use your system's default mailer.\n +To change your decision later, customize `send-mail-function'.\n") + (goto-char (point-min)) + (display-buffer (current-buffer)) + (if (y-or-n-p "Set up Emacs for sending SMTP mail? ") + ;; FIXME: We should check and correct the From: field too. + (setq send-function 'smtpmail-send-it) + (setq send-function default)))) + (when send-function + (customize-save-variable 'send-mail-function send-function) + ;; HACK: Message mode stupidly has `message-send-mail-function', + ;; so we must update it too or sending again in the current + ;; Emacs session will still call `sendmail-query-once'. + (and (boundp 'message-send-mail-function) + (eq message-send-mail-function 'sendmail-query-once) + (customize-set-variable 'message-send-mail-function + send-function)) + (funcall send-function)))) + (defun sendmail-sync-aliases () (when mail-personal-alias-file (let ((modtime (nth 5 (file-attributes mail-personal-alias-file)))) diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 69c49c471c0..544570a1bc3 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -490,7 +490,7 @@ The list is in preference order.") (let* ((mechs (cdr-safe (assoc 'auth supported-extensions))) (mech (car (smtpmail-intersection mechs smtpmail-auth-supported))) (auth-source-creation-prompts - '((user . "SMTP user at %h: ") + '((user . "SMTP user name for %h: ") (secret . "SMTP password for %u@%h: "))) (auth-info (car (auth-source-search