Allow sending mail in "emacs -Q" by not calling customize-save-variable

* mail/smtpmail.el (smtpmail-query-smtp-server): Ditto.

* mail/sendmail.el (sendmail-query-once): If we aren't allowed to
save customizations (with "emacs -Q"), just set the variable
instead of erroring out.
parent 47588180
2011-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
* mail/sendmail.el (sendmail-query-once): If we aren't allowed to
save customizations (with "emacs -Q"), just set the variable
instead of erroring out.
* mail/smtpmail.el (smtpmail-query-smtp-server): Ditto.
2011-07-08 Juri Linkov <juri@jurta.org> 2011-07-08 Juri Linkov <juri@jurta.org>
* arc-mode.el (archive-zip-expunge, archive-zip-update) * arc-mode.el (archive-zip-expunge, archive-zip-update)
......
...@@ -168,22 +168,23 @@ This is used by the default mail-sending commands. See also ...@@ -168,22 +168,23 @@ This is used by the default mail-sending commands. See also
(defvar sendmail-query-once-function 'query (defvar sendmail-query-once-function 'query
"Either a function to send email, or the symbol `query'.") "Either a function to send email, or the symbol `query'.")
(autoload 'custom-file "cus-edit")
;;;###autoload ;;;###autoload
(defun sendmail-query-once () (defun sendmail-query-once ()
"Send an email via `sendmail-query-once-function'. "Send an email via `sendmail-query-once-function'.
If `sendmail-query-once-function' is `query', ask the user what If `sendmail-query-once-function' is `query', ask the user what
function to use, and then save that choice." function to use, and then save that choice."
(when (equal sendmail-query-once-function 'query) (when (equal sendmail-query-once-function 'query)
(let ((default (let* ((default
(cond (cond
((or (and window-system (eq system-type 'darwin)) ((or (and window-system (eq system-type 'darwin))
(eq system-type 'windows-nt)) (eq system-type 'windows-nt))
'mailclient-send-it) 'mailclient-send-it)
((and sendmail-program ((and sendmail-program
(executable-find sendmail-program)) (executable-find sendmail-program))
'sendmail-send-it)))) 'sendmail-send-it)))
(customize-save-variable (function
'sendmail-query-once-function
(if (or (not default) (if (or (not default)
;; We have detected no OS-level mail senders, or we ;; We have detected no OS-level mail senders, or we
;; have already configured smtpmail, so we use the ;; have already configured smtpmail, so we use the
...@@ -205,7 +206,10 @@ function to use, and then save that choice." ...@@ -205,7 +206,10 @@ function to use, and then save that choice."
(if (y-or-n-p "Configure outgoing SMTP in Emacs? ") (if (y-or-n-p "Configure outgoing SMTP in Emacs? ")
'smtpmail-send-it 'smtpmail-send-it
default)) default))
(kill-buffer (current-buffer))))))) (kill-buffer (current-buffer))))))
(if (ignore-errors (custom-file))
(customize-save-variable 'sendmail-query-once-function function)
(setq sendmail-query-once-function function))))
(funcall sendmail-query-once-function)) (funcall sendmail-query-once-function))
;;;###autoload(custom-initialize-delay 'send-mail-function nil) ;;;###autoload(custom-initialize-delay 'send-mail-function nil)
......
...@@ -587,6 +587,8 @@ The list is in preference order.") ...@@ -587,6 +587,8 @@ The list is in preference order.")
(defun smtpmail-response-text (response) (defun smtpmail-response-text (response)
(mapconcat 'identity (cdr response) "\n")) (mapconcat 'identity (cdr response) "\n"))
(autoload 'custom-file "cus-edit")
(defun smtpmail-query-smtp-server () (defun smtpmail-query-smtp-server ()
(let ((server (read-string "Outgoing SMTP mail server: ")) (let ((server (read-string "Outgoing SMTP mail server: "))
(ports '(587 "smtp")) (ports '(587 "smtp"))
...@@ -598,8 +600,12 @@ The list is in preference order.") ...@@ -598,8 +600,12 @@ The list is in preference order.")
(setq port (pop ports))) (setq port (pop ports)))
(when (setq stream (ignore-errors (when (setq stream (ignore-errors
(open-network-stream "smtp" nil server port))) (open-network-stream "smtp" nil server port)))
(if (ignore-errors (custom-file))
(progn
(customize-save-variable 'smtpmail-smtp-server server) (customize-save-variable 'smtpmail-smtp-server server)
(customize-save-variable 'smtpmail-smtp-service port) (customize-save-variable 'smtpmail-smtp-service port))
(setq smtpmail-smtp-server server
smtpmail-smtp-service port))
(delete-process stream))) (delete-process stream)))
(unless smtpmail-smtp-server (unless smtpmail-smtp-server
(error "Couldn't contact an SMTP server")))) (error "Couldn't contact an SMTP server"))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment