diff options
| author | Stefan Monnier | 2019-07-30 16:37:01 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-07-30 16:37:01 -0400 |
| commit | 3a59cc84069376802ba8fd731b524d78db58262c (patch) | |
| tree | 1276ded76d3bf9762099f780f407025cf9f2b81b | |
| parent | add146f09f0f73f4af4760cc6205b287076c08d8 (diff) | |
| download | emacs-3a59cc84069376802ba8fd731b524d78db58262c.tar.gz emacs-3a59cc84069376802ba8fd731b524d78db58262c.zip | |
* lisp/gnus/message.el: Reduce redundancy with send-mail-function
(message-send-mail-function) <function>: Remove `local-library` tests
for libs distributed with Emacs.
(message-use-send-mail-function): New function.
(message-default-send-mail-function): Default to it, and remove cases
already handled by it.
(message--default-send-mail-function): New function.
(message-send-mail-function) <variable>: Use it as new default.
(message-sendmail-f-is-evil): Obey mail-specify-envelope-from if available.
(message-check, message-with-reply-buffer): Use `declare`.
(message-smtpmail-send-it): smtpmail accepts mail-header-separator,
so simplify and declare obsolete.
(message-send-mail-with-mailclient): Declare obsolete.
(message-check-news-body-syntax): Don't presume that the checksum is
a fixnum.
| -rw-r--r-- | lisp/gnus/message.el | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index ea7a282b8ba..30c5f7cbda0 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -666,30 +666,29 @@ variable should be a regexp or a list of regexps." | |||
| 666 | 666 | ||
| 667 | (defun message-send-mail-function () | 667 | (defun message-send-mail-function () |
| 668 | "Return suitable value for the variable `message-send-mail-function'." | 668 | "Return suitable value for the variable `message-send-mail-function'." |
| 669 | (cond ((and (require 'sendmail) | 669 | (declare (obsolete nil "27.1")) |
| 670 | (boundp 'sendmail-program) | 670 | (require 'sendmail) |
| 671 | sendmail-program | 671 | (defvar sendmail-program) |
| 672 | (executable-find sendmail-program)) | 672 | (cond ((executable-find sendmail-program) |
| 673 | 'message-send-mail-with-sendmail) | 673 | #'message-send-mail-with-sendmail) |
| 674 | ((and (locate-library "smtpmail") | 674 | ((bound-and-true-p 'smtpmail-default-smtp-server) |
| 675 | (boundp 'smtpmail-default-smtp-server) | 675 | #'message-smtpmail-send-it) |
| 676 | smtpmail-default-smtp-server) | ||
| 677 | 'message-smtpmail-send-it) | ||
| 678 | ((locate-library "mailclient") | ||
| 679 | 'message-send-mail-with-mailclient) | ||
| 680 | (t | 676 | (t |
| 681 | (error "Don't know how to send mail. Please customize `message-send-mail-function'")))) | 677 | #'message-send-mail-with-mailclient))) |
| 682 | 678 | ||
| 683 | (defun message-default-send-mail-function () | 679 | (defun message-default-send-mail-function () |
| 684 | (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it) | 680 | (cond ((eq send-mail-function #'feedmail-send-it) #'feedmail-send-it) |
| 685 | ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it) | 681 | ((eq send-mail-function #'sendmail-query-once) #'sendmail-query-once) |
| 686 | ((eq send-mail-function 'sendmail-query-once) 'sendmail-query-once) | 682 | ((eq send-mail-function #'sendmail-send-it) |
| 687 | ((eq send-mail-function 'mailclient-send-it) | 683 | #'message-send-mail-with-sendmail) |
| 688 | 'message-send-mail-with-mailclient) | 684 | (t #'message-use-send-mail-function))) |
| 689 | (t (message-send-mail-function)))) | 685 | |
| 686 | (defun message--default-send-mail-function () | ||
| 687 | "Use the setting of `send-mail-function' if applicable." | ||
| 688 | (funcall (message-default-send-mail-function))) | ||
| 690 | 689 | ||
| 691 | ;; Useful to set in site-init.el | 690 | ;; Useful to set in site-init.el |
| 692 | (defcustom message-send-mail-function (message-default-send-mail-function) | 691 | (defcustom message-send-mail-function #'message--default-send-mail-function |
| 693 | "Function to call to send the current buffer as mail. | 692 | "Function to call to send the current buffer as mail. |
| 694 | The headers should be delimited by a line whose contents match the | 693 | The headers should be delimited by a line whose contents match the |
| 695 | variable `mail-header-separator'. | 694 | variable `mail-header-separator'. |
| @@ -702,7 +701,9 @@ default is system dependent and determined by the function | |||
| 702 | `message-send-mail-function'. | 701 | `message-send-mail-function'. |
| 703 | 702 | ||
| 704 | See also `send-mail-function'." | 703 | See also `send-mail-function'." |
| 705 | :type '(radio (function-item message-send-mail-with-sendmail) | 704 | :type '(radio (function-item message--default-send-mail-function |
| 705 | :tag "Use send-mail-function") | ||
| 706 | (function-item message-send-mail-with-sendmail) | ||
| 706 | (function-item message-send-mail-with-mh) | 707 | (function-item message-send-mail-with-mh) |
| 707 | (function-item message-send-mail-with-qmail) | 708 | (function-item message-send-mail-with-qmail) |
| 708 | (function-item message-smtpmail-send-it) | 709 | (function-item message-smtpmail-send-it) |
| @@ -712,8 +713,8 @@ See also `send-mail-function'." | |||
| 712 | :tag "Use Mailclient package") | 713 | :tag "Use Mailclient package") |
| 713 | (function :tag "Other")) | 714 | (function :tag "Other")) |
| 714 | :group 'message-sending | 715 | :group 'message-sending |
| 715 | :version "23.2" | 716 | :version "27.1" |
| 716 | :initialize 'custom-initialize-default | 717 | :initialize #'custom-initialize-default |
| 717 | :link '(custom-manual "(message)Mail Variables") | 718 | :link '(custom-manual "(message)Mail Variables") |
| 718 | :group 'message-mail) | 719 | :group 'message-mail) |
| 719 | 720 | ||
| @@ -834,7 +835,10 @@ symbol `never', the posting is not allowed. If it is the symbol | |||
| 834 | (const never) | 835 | (const never) |
| 835 | (const ask))) | 836 | (const ask))) |
| 836 | 837 | ||
| 837 | (defcustom message-sendmail-f-is-evil nil | 838 | (defcustom message-sendmail-f-is-evil |
| 839 | (if (boundp 'mail-specify-envelope-from) | ||
| 840 | (not mail-specify-envelope-from) | ||
| 841 | nil) | ||
| 838 | "Non-nil means don't add \"-f username\" to the sendmail command line. | 842 | "Non-nil means don't add \"-f username\" to the sendmail command line. |
| 839 | Doing so would be even more evil than leaving it out." | 843 | Doing so would be even more evil than leaving it out." |
| 840 | :group 'message-sending | 844 | :group 'message-sending |
| @@ -1920,10 +1924,10 @@ You must have the \"hashcash\" binary installed, see `hashcash-path'." | |||
| 1920 | "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW." | 1924 | "Ask QUESTION, displaying remaining args in a temporary buffer if SHOW." |
| 1921 | `(message-talkative-question 'y-or-n-p ,question ,show ,@text)) | 1925 | `(message-talkative-question 'y-or-n-p ,question ,show ,@text)) |
| 1922 | 1926 | ||
| 1923 | (defmacro message-delete-line (&optional n) | 1927 | (defsubst message-delete-line (&optional n) |
| 1924 | "Delete the current line (and the next N lines)." | 1928 | "Delete the current line (and the next N lines)." |
| 1925 | `(delete-region (progn (beginning-of-line) (point)) | 1929 | (delete-region (progn (beginning-of-line) (point)) |
| 1926 | (progn (forward-line ,(or n 1)) (point)))) | 1930 | (progn (forward-line (or n 1)) (point)))) |
| 1927 | 1931 | ||
| 1928 | (defun message-mark-active-p () | 1932 | (defun message-mark-active-p () |
| 1929 | "Non-nil means the mark and region are currently active in this buffer." | 1933 | "Non-nil means the mark and region are currently active in this buffer." |
| @@ -2039,13 +2043,11 @@ see `message-narrow-to-headers-or-head'." | |||
| 2039 | 2043 | ||
| 2040 | (defmacro message-with-reply-buffer (&rest forms) | 2044 | (defmacro message-with-reply-buffer (&rest forms) |
| 2041 | "Evaluate FORMS in the reply buffer, if it exists." | 2045 | "Evaluate FORMS in the reply buffer, if it exists." |
| 2046 | (declare (indent 0) (debug t)) | ||
| 2042 | `(when (buffer-live-p message-reply-buffer) | 2047 | `(when (buffer-live-p message-reply-buffer) |
| 2043 | (with-current-buffer message-reply-buffer | 2048 | (with-current-buffer message-reply-buffer |
| 2044 | ,@forms))) | 2049 | ,@forms))) |
| 2045 | 2050 | ||
| 2046 | (put 'message-with-reply-buffer 'lisp-indent-function 0) | ||
| 2047 | (put 'message-with-reply-buffer 'edebug-form-spec '(body)) | ||
| 2048 | |||
| 2049 | (defun message-fetch-reply-field (header) | 2051 | (defun message-fetch-reply-field (header) |
| 2050 | "Fetch field HEADER from the message we're replying to." | 2052 | "Fetch field HEADER from the message we're replying to." |
| 2051 | (message-with-reply-buffer | 2053 | (message-with-reply-buffer |
| @@ -4174,13 +4176,11 @@ It should typically alter the sending method in some way or other." | |||
| 4174 | 4176 | ||
| 4175 | (defmacro message-check (type &rest forms) | 4177 | (defmacro message-check (type &rest forms) |
| 4176 | "Eval FORMS if TYPE is to be checked." | 4178 | "Eval FORMS if TYPE is to be checked." |
| 4179 | (declare (indent 1) (debug t)) | ||
| 4177 | `(or (message-check-element ,type) | 4180 | `(or (message-check-element ,type) |
| 4178 | (save-excursion | 4181 | (save-excursion |
| 4179 | ,@forms))) | 4182 | ,@forms))) |
| 4180 | 4183 | ||
| 4181 | (put 'message-check 'lisp-indent-function 1) | ||
| 4182 | (put 'message-check 'edebug-form-spec '(form body)) | ||
| 4183 | |||
| 4184 | (defun message-text-with-property (prop &optional start end reverse) | 4184 | (defun message-text-with-property (prop &optional start end reverse) |
| 4185 | "Return a list of start and end positions where the text has PROP. | 4185 | "Return a list of start and end positions where the text has PROP. |
| 4186 | START and END bound the search, they default to `point-min' and | 4186 | START and END bound the search, they default to `point-min' and |
| @@ -4818,24 +4818,25 @@ to find out how to use this." | |||
| 4818 | ;; Pass it on to mh. | 4818 | ;; Pass it on to mh. |
| 4819 | (mh-send-letter))) | 4819 | (mh-send-letter))) |
| 4820 | 4820 | ||
| 4821 | (defun message-use-send-mail-function () | ||
| 4822 | (run-hooks 'message-send-mail-hook) | ||
| 4823 | (funcall send-mail-function)) | ||
| 4824 | |||
| 4821 | (defun message-smtpmail-send-it () | 4825 | (defun message-smtpmail-send-it () |
| 4822 | "Send the prepared message buffer with `smtpmail-send-it'. | 4826 | "Send the prepared message buffer with `smtpmail-send-it'. |
| 4823 | The only difference from `smtpmail-send-it' is that this command | 4827 | The only difference from `smtpmail-send-it' is that this command |
| 4824 | evaluates `message-send-mail-hook' just before sending a message. | 4828 | evaluates `message-send-mail-hook' just before sending a message. |
| 4825 | It is useful if your ISP requires the POP-before-SMTP | 4829 | It is useful if your ISP requires the POP-before-SMTP |
| 4826 | authentication. See the Gnus manual for details." | 4830 | authentication. See the Gnus manual for details." |
| 4831 | (declare (obsolete message-use-send-mail-function "27.1")) | ||
| 4827 | (run-hooks 'message-send-mail-hook) | 4832 | (run-hooks 'message-send-mail-hook) |
| 4828 | ;; Change header-delimiter to be what smtpmail expects. | ||
| 4829 | (goto-char (point-min)) | ||
| 4830 | (when (re-search-forward | ||
| 4831 | (concat "^" (regexp-quote mail-header-separator) "\n")) | ||
| 4832 | (replace-match "\n")) | ||
| 4833 | (smtpmail-send-it)) | 4833 | (smtpmail-send-it)) |
| 4834 | 4834 | ||
| 4835 | (defun message-send-mail-with-mailclient () | 4835 | (defun message-send-mail-with-mailclient () |
| 4836 | "Send the prepared message buffer with `mailclient-send-it'. | 4836 | "Send the prepared message buffer with `mailclient-send-it'. |
| 4837 | The only difference from `mailclient-send-it' is that this | 4837 | The only difference from `mailclient-send-it' is that this |
| 4838 | command evaluates `message-send-mail-hook' just before sending a message." | 4838 | command evaluates `message-send-mail-hook' just before sending a message." |
| 4839 | (declare (obsolete message-use-send-mail-function "27.1")) | ||
| 4839 | (run-hooks 'message-send-mail-hook) | 4840 | (run-hooks 'message-send-mail-hook) |
| 4840 | (mailclient-send-it)) | 4841 | (mailclient-send-it)) |
| 4841 | 4842 | ||
| @@ -5325,7 +5326,7 @@ Otherwise, generate and save a value for `canlock-password' first." | |||
| 5325 | (message-check 'new-text | 5326 | (message-check 'new-text |
| 5326 | (or | 5327 | (or |
| 5327 | (not message-checksum) | 5328 | (not message-checksum) |
| 5328 | (not (eq (message-checksum) message-checksum)) | 5329 | (not (equal (message-checksum) message-checksum)) |
| 5329 | (if (message-gnksa-enable-p 'quoted-text-only) | 5330 | (if (message-gnksa-enable-p 'quoted-text-only) |
| 5330 | (y-or-n-p | 5331 | (y-or-n-p |
| 5331 | "It looks like no new text has been added. Really post? ") | 5332 | "It looks like no new text has been added. Really post? ") |
| @@ -7815,8 +7816,8 @@ Pre-defined symbols include `message-tool-bar-gnome' and | |||
| 7815 | (repeat :tag "User defined list" gmm-tool-bar-item) | 7816 | (repeat :tag "User defined list" gmm-tool-bar-item) |
| 7816 | (symbol)) | 7817 | (symbol)) |
| 7817 | :version "23.1" ;; No Gnus | 7818 | :version "23.1" ;; No Gnus |
| 7818 | :initialize 'custom-initialize-default | 7819 | :initialize #'custom-initialize-default |
| 7819 | :set 'message-tool-bar-update | 7820 | :set #'message-tool-bar-update |
| 7820 | :group 'message) | 7821 | :group 'message) |
| 7821 | 7822 | ||
| 7822 | (defcustom message-tool-bar-gnome | 7823 | (defcustom message-tool-bar-gnome |
| @@ -7840,8 +7841,8 @@ Pre-defined symbols include `message-tool-bar-gnome' and | |||
| 7840 | See `gmm-tool-bar-from-list' for details on the format of the list." | 7841 | See `gmm-tool-bar-from-list' for details on the format of the list." |
| 7841 | :type '(repeat gmm-tool-bar-item) | 7842 | :type '(repeat gmm-tool-bar-item) |
| 7842 | :version "23.1" ;; No Gnus | 7843 | :version "23.1" ;; No Gnus |
| 7843 | :initialize 'custom-initialize-default | 7844 | :initialize #'custom-initialize-default |
| 7844 | :set 'message-tool-bar-update | 7845 | :set #'message-tool-bar-update |
| 7845 | :group 'message) | 7846 | :group 'message) |
| 7846 | 7847 | ||
| 7847 | (defcustom message-tool-bar-retro | 7848 | (defcustom message-tool-bar-retro |
| @@ -7860,8 +7861,8 @@ See `gmm-tool-bar-from-list' for details on the format of the list." | |||
| 7860 | See `gmm-tool-bar-from-list' for details on the format of the list." | 7861 | See `gmm-tool-bar-from-list' for details on the format of the list." |
| 7861 | :type '(repeat gmm-tool-bar-item) | 7862 | :type '(repeat gmm-tool-bar-item) |
| 7862 | :version "23.1" ;; No Gnus | 7863 | :version "23.1" ;; No Gnus |
| 7863 | :initialize 'custom-initialize-default | 7864 | :initialize #'custom-initialize-default |
| 7864 | :set 'message-tool-bar-update | 7865 | :set #'message-tool-bar-update |
| 7865 | :group 'message) | 7866 | :group 'message) |
| 7866 | 7867 | ||
| 7867 | (defcustom message-tool-bar-zap-list | 7868 | (defcustom message-tool-bar-zap-list |
| @@ -7873,8 +7874,8 @@ These items are not displayed on the message mode tool bar. | |||
| 7873 | See `gmm-tool-bar-from-list' for the format of the list." | 7874 | See `gmm-tool-bar-from-list' for the format of the list." |
| 7874 | :type 'gmm-tool-bar-zap-list | 7875 | :type 'gmm-tool-bar-zap-list |
| 7875 | :version "23.1" ;; No Gnus | 7876 | :version "23.1" ;; No Gnus |
| 7876 | :initialize 'custom-initialize-default | 7877 | :initialize #'custom-initialize-default |
| 7877 | :set 'message-tool-bar-update | 7878 | :set #'message-tool-bar-update |
| 7878 | :group 'message) | 7879 | :group 'message) |
| 7879 | 7880 | ||
| 7880 | (defvar image-load-path) | 7881 | (defvar image-load-path) |