aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2012-02-10 19:16:19 +0100
committerLars Ingebrigtsen2012-02-10 19:16:19 +0100
commitcc26d239af9a82cff079556a1daff4b4bf60eb5c (patch)
treef9a7bdaf6d51729ef4f639709b5e752394747748
parent3647f557cf42ae6b33414a454503d2695798a6e6 (diff)
downloademacs-cc26d239af9a82cff079556a1daff4b4bf60eb5c.tar.gz
emacs-cc26d239af9a82cff079556a1daff4b4bf60eb5c.zip
Prompt in a more logical fashion when sending bug reports
* gnus/message.el (message-default-send-mail-function): Made into own function for reuse by emacsbug.el. * mail/emacsbug.el (report-emacs-bug-hook): Query the user first about SMTP before checking the From header. * mail/sendmail.el (sendmail-query-user-about-smtp): Refacored out into own function for reuse by emacsbug.el.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/gnus/ChangeLog5
-rw-r--r--lisp/gnus/message.el8
-rw-r--r--lisp/mail/emacsbug.el51
-rw-r--r--lisp/mail/sendmail.el63
5 files changed, 81 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 52b9eb38374..c28dc491863 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-02-10 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * mail/emacsbug.el (report-emacs-bug-hook): Query the user first
4 about SMTP before checking the From header.
5
6 * mail/sendmail.el (sendmail-query-user-about-smtp): Refacored out
7 into own function for reuse by emacsbug.el.
8
12012-02-10 Leo Liu <sdl.web@gmail.com> 92012-02-10 Leo Liu <sdl.web@gmail.com>
2 10
3 * subr.el (condition-case-unless-debug): Rename from 11 * subr.el (condition-case-unless-debug): Rename from
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 9305114b634..38b9139b7dd 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
12012-02-10 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * message.el (message-default-send-mail-function): Made into own
4 function for reuse by emacsbug.el.
5
12012-02-09 Juanma Barranquero <lekktu@gmail.com> 62012-02-09 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * gnus.el (gnus-method-ephemeral-p): Move after declaration of defsubst 8 * gnus.el (gnus-method-ephemeral-p): Move after declaration of defsubst
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 5678acc5a2f..2d8bb36f94a 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -655,14 +655,16 @@ Done before generating the new subject of a forward."
655 (t 655 (t
656 (error "Don't know how to send mail. Please customize `message-send-mail-function'")))) 656 (error "Don't know how to send mail. Please customize `message-send-mail-function'"))))
657 657
658;; Useful to set in site-init.el 658(defun message-default-send-mail-function ()
659(defcustom message-send-mail-function
660 (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it) 659 (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it)
661 ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it) 660 ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it)
662 ((eq send-mail-function 'sendmail-query-once) 'sendmail-query-once) 661 ((eq send-mail-function 'sendmail-query-once) 'sendmail-query-once)
663 ((eq send-mail-function 'mailclient-send-it) 662 ((eq send-mail-function 'mailclient-send-it)
664 'message-send-mail-with-mailclient) 663 'message-send-mail-with-mailclient)
665 (t (message-send-mail-function))) 664 (t (message-send-mail-function))))
665
666;; Useful to set in site-init.el
667(defcustom message-send-mail-function (message-default-send-mail-function)
666 "Function to call to send the current buffer as mail. 668 "Function to call to send the current buffer as mail.
667The headers should be delimited by a line whose contents match the 669The headers should be delimited by a line whose contents match the
668variable `mail-header-separator'. 670variable `mail-header-separator'.
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 20b436172ba..50fcfceee35 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -32,6 +32,9 @@
32 32
33;;; Code: 33;;; Code:
34 34
35(require 'sendmail)
36(require 'message)
37
35(defgroup emacsbug nil 38(defgroup emacsbug nil
36 "Sending Emacs bug reports." 39 "Sending Emacs bug reports."
37 :group 'maint 40 :group 'maint
@@ -365,26 +368,7 @@ usually do not have translators for other languages.\n\n")))
365 (string-equal (buffer-substring-no-properties (point-min) (point)) 368 (string-equal (buffer-substring-no-properties (point-min) (point))
366 report-emacs-bug-orig-text) 369 report-emacs-bug-orig-text)
367 (error "No text entered in bug report")) 370 (error "No text entered in bug report"))
368 (or report-emacs-bug-no-confirmation 371 ;; Warning for novice users.
369 ;; mailclient.el does not handle From (at present).
370 (if (derived-mode-p 'message-mode)
371 (eq message-send-mail-function 'message-send-mail-with-mailclient)
372 (eq send-mail-function 'mailclient-send-it))
373 ;; Not narrowing to the headers, but that's OK.
374 (let ((from (mail-fetch-field "From")))
375 (and (or (not from)
376 (message-bogus-recipient-p from)
377 ;; This is the default user-mail-address. On today's
378 ;; systems, it seems more likely to be wrong than right,
379 ;; since most people don't run their own mail server.
380 (string-match (format "\\<%s@%s\\>"
381 (regexp-quote (user-login-name))
382 (regexp-quote (system-name)))
383 from))
384 (not (yes-or-no-p
385 (format "Is `%s' really your email address? " from)))
386 (error "Please edit the From address and try again"))))
387 ;; The last warning for novice users.
388 (unless (or report-emacs-bug-no-confirmation 372 (unless (or report-emacs-bug-no-confirmation
389 (yes-or-no-p 373 (yes-or-no-p
390 "Send this bug report to the Emacs maintainers? ")) 374 "Send this bug report to the Emacs maintainers? "))
@@ -407,7 +391,32 @@ and send the mail again%s."
407 report-emacs-bug-send-command) 391 report-emacs-bug-send-command)
408 ""))))) 392 "")))))
409 (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer")) 393 (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer"))
410 394 ;; Query the user for the SMTP method, so that we can skip
395 ;; questions about From header validity if the user is going to
396 ;; use mailclient, anyway.
397 (when (eq send-mail-function 'sendmail-query-once)
398 (sendmail-query-user-about-smtp)
399 (when (derived-mode-p 'message-mode)
400 (setq message-send-mail-function (message-default-send-mail-function))))
401 (or report-emacs-bug-no-confirmation
402 ;; mailclient.el does not need a valid From
403 (if (derived-mode-p 'message-mode)
404 (eq message-send-mail-function 'message-send-mail-with-mailclient)
405 (eq send-mail-function 'mailclient-send-it))
406 ;; Not narrowing to the headers, but that's OK.
407 (let ((from (mail-fetch-field "From")))
408 (and (or (not from)
409 (message-bogus-recipient-p from)
410 ;; This is the default user-mail-address. On today's
411 ;; systems, it seems more likely to be wrong than right,
412 ;; since most people don't run their own mail server.
413 (string-match (format "\\<%s@%s\\>"
414 (regexp-quote (user-login-name))
415 (regexp-quote (system-name)))
416 from))
417 (not (yes-or-no-p
418 (format "Is `%s' really your email address? " from)))
419 (error "Please edit the From address and try again"))))
411 ;; Delete the uninteresting text that was just to help fill out the report. 420 ;; Delete the uninteresting text that was just to help fill out the report.
412 (rfc822-goto-eoh) 421 (rfc822-goto-eoh)
413 (forward-line 1) 422 (forward-line 1)
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 18d928e4b90..91e0b183a68 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -513,48 +513,51 @@ This also saves the value of `send-mail-function' via Customize."
513 ;; a second time, probably because someone's using an old value 513 ;; a second time, probably because someone's using an old value
514 ;; of send-mail-function. 514 ;; of send-mail-function.
515 (when (eq send-mail-function 'sendmail-query-once) 515 (when (eq send-mail-function 'sendmail-query-once)
516 (let* ((options `(("mail client" . mailclient-send-it) 516 (sendmail-query-user-about-smtp))
517 ,@(when (and sendmail-program 517 (funcall send-mail-function))
518 (executable-find sendmail-program)) 518
519 '(("transport" . sendmail-send-it))) 519(defun sendmail-query-user-about-smtp ()
520 ("smtp" . smtpmail-send-it))) 520 (let* ((options `(("mail client" . mailclient-send-it)
521 (choice 521 ,@(when (and sendmail-program
522 ;; Query the user. 522 (executable-find sendmail-program))
523 (with-temp-buffer 523 '(("transport" . sendmail-send-it)))
524 (rename-buffer "*Emacs Mail Setup Help*" t) 524 ("smtp" . smtpmail-send-it)))
525 (insert "\ 525 (choice
526 ;; Query the user.
527 (with-temp-buffer
528 (rename-buffer "*Emacs Mail Setup Help*" t)
529 (insert "\
526 Emacs is about to send an email message, but it has not been 530 Emacs is about to send an email message, but it has not been
527 configured for sending email. To tell Emacs how to send email: 531 configured for sending email. To tell Emacs how to send email:
528 532
529 - Type `" 533 - Type `"
530 (propertize "mail client" 'face 'bold) 534 (propertize "mail client" 'face 'bold)
531 "' to start your default email client and 535 "' to start your default email client and
532 pass it the message text.\n\n") 536 pass it the message text.\n\n")
533 (and sendmail-program 537 (and sendmail-program
534 (executable-find sendmail-program) 538 (executable-find sendmail-program)
535 (insert "\ 539 (insert "\
536 - Type `" 540 - Type `"
537 (propertize "transport" 'face 'bold) 541 (propertize "transport" 'face 'bold)
538 "' to invoke the system's mail transport agent 542 "' to invoke the system's mail transport agent
539 (the `" 543 (the `"
540 sendmail-program 544 sendmail-program
541 "' program).\n\n")) 545 "' program).\n\n"))
542 (insert "\ 546 (insert "\
543 - Type `" 547 - Type `"
544 (propertize "smtp" 'face 'bold) 548 (propertize "smtp" 'face 'bold)
545 "' to send mail directly to an \"outgoing mail\" server. 549 "' to send mail directly to an \"outgoing mail\" server.
546 (Emacs may prompt you for SMTP settings). 550 (Emacs may prompt you for SMTP settings).
547 551
548 Emacs will record your selection and will use it thereafter. 552 Emacs will record your selection and will use it thereafter.
549 To change it later, customize the option `send-mail-function'.\n") 553 To change it later, customize the option `send-mail-function'.\n")
550 (goto-char (point-min)) 554 (goto-char (point-min))
551 (display-buffer (current-buffer)) 555 (display-buffer (current-buffer))
552 (let ((completion-ignore-case t)) 556 (let ((completion-ignore-case t))
553 (completing-read "Send mail via: " 557 (completing-read "Send mail via: "
554 options nil 'require-match))))) 558 options nil 'require-match)))))
555 (customize-save-variable 'send-mail-function 559 (customize-save-variable 'send-mail-function
556 (cdr (assoc-string choice options t))))) 560 (cdr (assoc-string choice options t)))))
557 (funcall send-mail-function))
558 561
559(defun sendmail-sync-aliases () 562(defun sendmail-sync-aliases ()
560 (when mail-personal-alias-file 563 (when mail-personal-alias-file