emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r104785: Add the new `sendmail-query-


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104785: Add the new `sendmail-query-once' function to sendmail.el.
Date: Wed, 29 Jun 2011 22:21:29 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104785
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Wed 2011-06-29 22:21:29 +0200
message:
  Add the new `sendmail-query-once' function to sendmail.el.
modified:
  lisp/ChangeLog
  lisp/mail/sendmail.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-06-29 18:38:39 +0000
+++ b/lisp/ChangeLog    2011-06-29 20:21:29 +0000
@@ -1,3 +1,8 @@
+2011-06-29  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * mail/sendmail.el (sendmail-query-once): New function.
+       (sendmail-query-once-function): New variable.
+
 2011-06-29  Glenn Morris  <address@hidden>
 
        * files.el (auto-mode-alist): Add .f03, .f08 for f90-mode.

=== modified file 'lisp/mail/sendmail.el'
--- a/lisp/mail/sendmail.el     2011-06-22 23:39:29 +0000
+++ b/lisp/mail/sendmail.el     2011-06-29 20:21:29 +0000
@@ -164,6 +164,7 @@
 This is used by the default mail-sending commands.  See also
 `message-send-mail-function' for use with the Message package."
   :type '(radio (function-item sendmail-send-it :tag "Use Sendmail package")
+               (function-item sendmail-query-once :tag "Query the user")
                (function-item smtpmail-send-it :tag "Use SMTPmail package")
                (function-item feedmail-send-it :tag "Use Feedmail package")
                (function-item mailclient-send-it :tag "Use Mailclient package")
@@ -171,6 +172,48 @@
   :initialize 'custom-initialize-delay
   :group 'sendmail)
 
+(defvar sendmail-query-once-function 'query
+  "Either a function to send email, or the symbol `query'.")
+
+(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)))))))
+  (funcall sendmail-query-once-function))
+
 ;;;###autoload(custom-initialize-delay 'send-mail-function nil)
 
 ;;;###autoload


reply via email to

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