emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105033: Allow sending mail in "emacs


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105033: Allow sending mail in "emacs -Q" by not calling customize-save-variable
Date: Fri, 08 Jul 2011 09:42:21 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105033
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Fri 2011-07-08 09:42:21 +0200
message:
  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.
modified:
  lisp/ChangeLog
  lisp/mail/sendmail.el
  lisp/mail/smtpmail.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-07-08 00:08:53 +0000
+++ b/lisp/ChangeLog    2011-07-08 07:42:21 +0000
@@ -1,3 +1,11 @@
+2011-07-08  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * 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  <address@hidden>
 
        * arc-mode.el (archive-zip-expunge, archive-zip-update)

=== modified file 'lisp/mail/sendmail.el'
--- a/lisp/mail/sendmail.el     2011-07-06 15:45:00 +0000
+++ b/lisp/mail/sendmail.el     2011-07-08 07:42:21 +0000
@@ -168,44 +168,48 @@
 (defvar sendmail-query-once-function 'query
   "Either a function to send email, or the symbol `query'.")
 
+(autoload 'custom-file "cus-edit")
+
 ;;;###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 ((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))))
-      (customize-save-variable
-       'sendmail-query-once-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)))))))
+    (let* ((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))))))
+      (if (ignore-errors (custom-file))
+         (customize-save-variable 'sendmail-query-once-function function)
+       (setq sendmail-query-once-function function))))
   (funcall sendmail-query-once-function))
 
 ;;;###autoload(custom-initialize-delay 'send-mail-function nil)

=== modified file 'lisp/mail/smtpmail.el'
--- a/lisp/mail/smtpmail.el     2011-07-07 14:54:12 +0000
+++ b/lisp/mail/smtpmail.el     2011-07-08 07:42:21 +0000
@@ -587,6 +587,8 @@
 (defun smtpmail-response-text (response)
   (mapconcat 'identity (cdr response) "\n"))
 
+(autoload 'custom-file "cus-edit")
+
 (defun smtpmail-query-smtp-server ()
   (let ((server (read-string "Outgoing SMTP mail server: "))
        (ports '(587 "smtp"))
@@ -598,8 +600,12 @@
                (setq port (pop ports)))
       (when (setq stream (ignore-errors
                           (open-network-stream "smtp" nil server port)))
-       (customize-save-variable 'smtpmail-smtp-server server)
-       (customize-save-variable 'smtpmail-smtp-service port)
+       (if (ignore-errors (custom-file))
+           (progn
+             (customize-save-variable 'smtpmail-smtp-server server)
+             (customize-save-variable 'smtpmail-smtp-service port))
+         (setq smtpmail-smtp-server server
+               smtpmail-smtp-service port))
        (delete-process stream)))
     (unless smtpmail-smtp-server
       (error "Couldn't contact an SMTP server"))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]