aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2011-07-08 09:42:21 +0200
committerLars Magne Ingebrigtsen2011-07-08 09:42:21 +0200
commitd760b73104d0533a222adb058f48da3e4ca61f3f (patch)
tree60023af6e5de887b55f1ddbf899396599fbb7c1f
parent47588180c91d0f150a5baa73c0461ebaa5f1b5ce (diff)
downloademacs-d760b73104d0533a222adb058f48da3e4ca61f3f.tar.gz
emacs-d760b73104d0533a222adb058f48da3e4ca61f3f.zip
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.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/mail/sendmail.el68
-rw-r--r--lisp/mail/smtpmail.el10
3 files changed, 52 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 74b36f4ab05..35337de3fa4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12011-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * mail/sendmail.el (sendmail-query-once): If we aren't allowed to
4 save customizations (with "emacs -Q"), just set the variable
5 instead of erroring out.
6
7 * mail/smtpmail.el (smtpmail-query-smtp-server): Ditto.
8
12011-07-08 Juri Linkov <juri@jurta.org> 92011-07-08 Juri Linkov <juri@jurta.org>
2 10
3 * arc-mode.el (archive-zip-expunge, archive-zip-update) 11 * arc-mode.el (archive-zip-expunge, archive-zip-update)
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 6480d6a393f..b14c7e50137 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -168,44 +168,48 @@ This is used by the default mail-sending commands. See also
168(defvar sendmail-query-once-function 'query 168(defvar sendmail-query-once-function 'query
169 "Either a function to send email, or the symbol `query'.") 169 "Either a function to send email, or the symbol `query'.")
170 170
171(autoload 'custom-file "cus-edit")
172
171;;;###autoload 173;;;###autoload
172(defun sendmail-query-once () 174(defun sendmail-query-once ()
173 "Send an email via `sendmail-query-once-function'. 175 "Send an email via `sendmail-query-once-function'.
174If `sendmail-query-once-function' is `query', ask the user what 176If `sendmail-query-once-function' is `query', ask the user what
175function to use, and then save that choice." 177function to use, and then save that choice."
176 (when (equal sendmail-query-once-function 'query) 178 (when (equal sendmail-query-once-function 'query)
177 (let ((default 179 (let* ((default
178 (cond 180 (cond
179 ((or (and window-system (eq system-type 'darwin)) 181 ((or (and window-system (eq system-type 'darwin))
180 (eq system-type 'windows-nt)) 182 (eq system-type 'windows-nt))
181 'mailclient-send-it) 183 'mailclient-send-it)
182 ((and sendmail-program 184 ((and sendmail-program
183 (executable-find sendmail-program)) 185 (executable-find sendmail-program))
184 'sendmail-send-it)))) 186 'sendmail-send-it)))
185 (customize-save-variable 187 (function
186 'sendmail-query-once-function 188 (if (or (not default)
187 (if (or (not default) 189 ;; We have detected no OS-level mail senders, or we
188 ;; We have detected no OS-level mail senders, or we 190 ;; have already configured smtpmail, so we use the
189 ;; have already configured smtpmail, so we use the 191 ;; internal SMTP service.
190 ;; internal SMTP service. 192 (and (boundp 'smtpmail-smtp-server)
191 (and (boundp 'smtpmail-smtp-server) 193 smtpmail-smtp-server))
192 smtpmail-smtp-server)) 194 'smtpmail-send-it
193 'smtpmail-send-it 195 ;; Query the user.
194 ;; Query the user. 196 (unwind-protect
195 (unwind-protect 197 (progn
196 (progn 198 (pop-to-buffer "*Mail Help*")
197 (pop-to-buffer "*Mail Help*") 199 (erase-buffer)
198 (erase-buffer) 200 (insert "Sending mail from Emacs hasn't been set up yet.\n\n"
199 (insert "Sending mail from Emacs hasn't been set up yet.\n\n" 201 "Type `y' to configure outgoing SMTP, or `n' to use\n"
200 "Type `y' to configure outgoing SMTP, or `n' to use\n" 202 "the default mail sender on your system.\n\n"
201 "the default mail sender on your system.\n\n" 203 "To change this again at a later date, customize the\n"
202 "To change this again at a later date, customize the\n" 204 "`send-mail-function' variable.\n")
203 "`send-mail-function' variable.\n") 205 (goto-char (point-min))
204 (goto-char (point-min)) 206 (if (y-or-n-p "Configure outgoing SMTP in Emacs? ")
205 (if (y-or-n-p "Configure outgoing SMTP in Emacs? ") 207 'smtpmail-send-it
206 'smtpmail-send-it 208 default))
207 default)) 209 (kill-buffer (current-buffer))))))
208 (kill-buffer (current-buffer))))))) 210 (if (ignore-errors (custom-file))
211 (customize-save-variable 'sendmail-query-once-function function)
212 (setq sendmail-query-once-function function))))
209 (funcall sendmail-query-once-function)) 213 (funcall sendmail-query-once-function))
210 214
211;;;###autoload(custom-initialize-delay 'send-mail-function nil) 215;;;###autoload(custom-initialize-delay 'send-mail-function nil)
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 073e2fa4a3c..57356f3315b 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -587,6 +587,8 @@ The list is in preference order.")
587(defun smtpmail-response-text (response) 587(defun smtpmail-response-text (response)
588 (mapconcat 'identity (cdr response) "\n")) 588 (mapconcat 'identity (cdr response) "\n"))
589 589
590(autoload 'custom-file "cus-edit")
591
590(defun smtpmail-query-smtp-server () 592(defun smtpmail-query-smtp-server ()
591 (let ((server (read-string "Outgoing SMTP mail server: ")) 593 (let ((server (read-string "Outgoing SMTP mail server: "))
592 (ports '(587 "smtp")) 594 (ports '(587 "smtp"))
@@ -598,8 +600,12 @@ The list is in preference order.")
598 (setq port (pop ports))) 600 (setq port (pop ports)))
599 (when (setq stream (ignore-errors 601 (when (setq stream (ignore-errors
600 (open-network-stream "smtp" nil server port))) 602 (open-network-stream "smtp" nil server port)))
601 (customize-save-variable 'smtpmail-smtp-server server) 603 (if (ignore-errors (custom-file))
602 (customize-save-variable 'smtpmail-smtp-service port) 604 (progn
605 (customize-save-variable 'smtpmail-smtp-server server)
606 (customize-save-variable 'smtpmail-smtp-service port))
607 (setq smtpmail-smtp-server server
608 smtpmail-smtp-service port))
603 (delete-process stream))) 609 (delete-process stream)))
604 (unless smtpmail-smtp-server 610 (unless smtpmail-smtp-server
605 (error "Couldn't contact an SMTP server")))) 611 (error "Couldn't contact an SMTP server"))))