Mercurial > emacs
comparison lisp/gnus/message.el @ 107427:ecbe0edc4f69
Stop message.el from loading about 40 libraries it doesn't always need.
The general approach is to autoload rather than require, and to
require in the specific functions rather than the file. (Bug#5642)
* url/url.el: Move mailcap require earlier in the file.
* gnus/gmm-utils.el: Don't require wid-edit.
(widget-create-child-value, widget-convert, widget-default-get):
Autoload.
* gnus/gnus-util.el: Don't require time-date, netrc.
(message-fetch-field, gnus-group-name-decode): Declare rather than
autoloading.
(gnus-fetch-field): Require message.
(gnus-decode-newsgroups): Require gnus-group.
* gnus/ietf-drums.el: Don't require time-date.
* gnus/message.el: Don't require hashcash, canlock, ecomplete.
Do require mail-utils. Require nnheader only when compiling.
(smtpmail-default-smtp-server): Remove declaration.
(message-send-mail-function): Check smtpmail-default-smtp-server
is bound rather than requiring smtpmail.
(message-auto-save-directory, message-insert-signature): Use
expand-file-name rather than nnheader-concat.
(nnheader-insert-file-contents): Autoload.
(hashcash-wait-async): Declare.
(message-send-mail): Only call gnus-setup-posting-charset if
gnus-group-posting-charset-alist is bound. Require hashcash if needed.
(message-send-mail-with-sendmail): Require sendmail.
(canlock-password, canlock-password-for-verify): Declare.
(message-canlock-password): Require canlock.
(nnheader-get-report): Autoload.
(gnus-setup-posting-charset): Declare.
(message-send-news): Require gnus-msg.
(message-make-references, message-make-in-reply-to): Use mail-header-id
rather than the alias mail-header-message-id.
(ecomplete-add-item, ecomplete-save): Declare.
(message-put-addresses-in-ecomplete): Require ecomplete.
(ecomplete-display-matches): Autoload.
* gnus/mm-decode.el: Don't require mailcap, gnus-util.
(gnus-map-function, gnus-replace-in-string, gnus-read-shell-command)
(message-fetch-field, mailcap-parse-mailcaps, mailcap-mime-info):
Autoload.
(mailcap-mime-extensions): Declare.
* gnus/mm-encode.el: Don't require mailcap.
(mailcap-extension-to-mime): Autoload.
* gnus/mml-sec.el: Don't require password-cache.
* gnus/mml.el (gnus-setup-posting-charset): Declare rather than autoload.
(mailcap-parse-mimetypes, mailcap-mime-types): Declare.
(mml-minibuffer-read-type): Require mailcap.
(mml-preview): Require gnus-msg.
* gnus/mml1991.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/mml2015.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/nneething.el (mailcap): Require mailcap.
* gnus/nnheader.el: (declare-function): Add compatibility stub.
(message-remove-header): Declare rather than autoload.
(nnheader-replace-header): Require message.
* gnus/nnimap.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine-user-or-password): Declare.
(nnimap-open-connection): Require netrc.
* gnus/nntp.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine, netrc-get): Declare.
(nntp-send-authinfo): Require netrc.
* gnus/rfc2047.el: Don't require qp.
(quoted-printable-encode-region, quoted-printable-decode-string):
Autoload.
* gnus/sieve-mode.el: Don't require easymenu.
(easy-menu-add-item): Autoload it.
* gnus/spam-stat.el (time-to-number-of-days): Autoload it.
* password-cache.el (password-cache, password-cache-expiry):
Autoload.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 18 Mar 2010 19:55:37 -0700 |
parents | a3c102291ce1 |
children | 0fe940324254 |
comparison
equal
deleted
inserted
replaced
107426:e3c196b081c6 | 107427:ecbe0edc4f69 |
---|---|
32 (eval-and-compile | 32 (eval-and-compile |
33 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) | 33 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
34 (eval-when-compile | 34 (eval-when-compile |
35 (require 'cl)) | 35 (require 'cl)) |
36 | 36 |
37 (require 'hashcash) | |
38 (require 'canlock) | |
39 (require 'mailheader) | 37 (require 'mailheader) |
40 (require 'gmm-utils) | 38 (require 'gmm-utils) |
41 (require 'nnheader) | 39 (require 'mail-utils) |
40 ;; Only for the trivial macros mail-header-from, mail-header-date | |
41 ;; mail-header-references, mail-header-subject, mail-header-id | |
42 (eval-when-compile (require 'nnheader)) | |
42 ;; This is apparently necessary even though things are autoloaded. | 43 ;; This is apparently necessary even though things are autoloaded. |
43 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better | 44 ;; Because we dynamically bind mail-abbrev-mode-regexp, we'd better |
44 ;; require mailabbrev here. | 45 ;; require mailabbrev here. |
45 (if (featurep 'xemacs) | 46 (if (featurep 'xemacs) |
46 (require 'mail-abbrevs) | 47 (require 'mail-abbrevs) |
47 (require 'mailabbrev)) | 48 (require 'mailabbrev)) |
48 (require 'mail-parse) | 49 (require 'mail-parse) |
49 (require 'mml) | 50 (require 'mml) |
50 (require 'rfc822) | 51 (require 'rfc822) |
51 (require 'ecomplete) | |
52 | 52 |
53 (autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/ | 53 (autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/ |
54 | 54 |
55 (defvar gnus-message-group-art) | 55 (defvar gnus-message-group-art) |
56 (defvar gnus-list-identifiers) ; gnus-sum is required where necessary | 56 (defvar gnus-list-identifiers) ; gnus-sum is required where necessary |
653 "Message to be inserted in the cancel message." | 653 "Message to be inserted in the cancel message." |
654 :group 'message-interface | 654 :group 'message-interface |
655 :link '(custom-manual "(message)Canceling News") | 655 :link '(custom-manual "(message)Canceling News") |
656 :type 'string) | 656 :type 'string) |
657 | 657 |
658 (defvar smtpmail-default-smtp-server) | |
659 | |
660 (defun message-send-mail-function () | 658 (defun message-send-mail-function () |
661 "Return suitable value for the variable `message-send-mail-function'." | 659 "Return suitable value for the variable `message-send-mail-function'." |
662 (cond ((and (require 'sendmail) | 660 (cond ((and (require 'sendmail) |
663 (boundp 'sendmail-program) | 661 (boundp 'sendmail-program) |
664 sendmail-program | 662 sendmail-program |
665 (executable-find sendmail-program)) | 663 (executable-find sendmail-program)) |
666 'message-send-mail-with-sendmail) | 664 'message-send-mail-with-sendmail) |
667 ((and (locate-library "smtpmail") | 665 ((and (locate-library "smtpmail") |
668 (require 'smtpmail) | 666 (boundp 'smtpmail-default-smtp-server) |
669 smtpmail-default-smtp-server) | 667 smtpmail-default-smtp-server) |
670 'message-smtpmail-send-it) | 668 'message-smtpmail-send-it) |
671 ((locate-library "mailclient") | 669 ((locate-library "mailclient") |
672 'message-send-mail-with-mailclient) | 670 'message-send-mail-with-mailclient) |
673 (t | 671 (t |
674 (lambda () | 672 (error "Don't know how to send mail. Please customize `message-send-mail-function'")))) |
675 (error "Don't know how to send mail. Please customize `message-send-mail-function'"))))) | |
676 | 673 |
677 ;; Useful to set in site-init.el | 674 ;; Useful to set in site-init.el |
678 (defcustom message-send-mail-function | 675 (defcustom message-send-mail-function |
679 (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it) | 676 (cond ((eq send-mail-function 'smtpmail-send-it) 'message-smtpmail-send-it) |
680 ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it) | 677 ((eq send-mail-function 'feedmail-send-it) 'feedmail-send-it) |
1280 `egg-self-insert-command', you may want to add it to this list." | 1277 `egg-self-insert-command', you may want to add it to this list." |
1281 :group 'message-various | 1278 :group 'message-various |
1282 :type '(repeat function)) | 1279 :type '(repeat function)) |
1283 | 1280 |
1284 (defcustom message-auto-save-directory | 1281 (defcustom message-auto-save-directory |
1285 (file-name-as-directory (nnheader-concat message-directory "drafts")) | 1282 (file-name-as-directory (expand-file-name "drafts" message-directory)) |
1286 "*Directory where Message auto-saves buffers if Gnus isn't running. | 1283 "*Directory where Message auto-saves buffers if Gnus isn't running. |
1287 If nil, Message won't auto-save." | 1284 If nil, Message won't auto-save." |
1288 :group 'message-buffers | 1285 :group 'message-buffers |
1289 :link '(custom-manual "(message)Various Message Variables") | 1286 :link '(custom-manual "(message)Various Message Variables") |
1290 :type '(choice directory (const :tag "Don't auto-save" nil))) | 1287 :type '(choice directory (const :tag "Don't auto-save" nil))) |
1955 (setq paren t)) | 1952 (setq paren t)) |
1956 ((and (eq (char-after) ?\)) | 1953 ((and (eq (char-after) ?\)) |
1957 (not quoted)) | 1954 (not quoted)) |
1958 (setq paren nil)))) | 1955 (setq paren nil)))) |
1959 (nreverse elems))))) | 1956 (nreverse elems))))) |
1957 | |
1958 (autoload 'nnheader-insert-file-contents "nnheader") | |
1960 | 1959 |
1961 (defun message-mail-file-mbox-p (file) | 1960 (defun message-mail-file-mbox-p (file) |
1962 "Say whether FILE looks like a Unix mbox file." | 1961 "Say whether FILE looks like a Unix mbox file." |
1963 (when (and (file-exists-p file) | 1962 (when (and (file-exists-p file) |
1964 (file-readable-p file) | 1963 (file-readable-p file) |
3408 (if (and message-signature-directory | 3407 (if (and message-signature-directory |
3409 ;; don't actually use the signature directory | 3408 ;; don't actually use the signature directory |
3410 ;; if message-signature-file contains a path. | 3409 ;; if message-signature-file contains a path. |
3411 (not (file-name-directory | 3410 (not (file-name-directory |
3412 message-signature-file))) | 3411 message-signature-file))) |
3413 (nnheader-concat message-signature-directory | 3412 (expand-file-name message-signature-file |
3414 message-signature-file) | 3413 message-signature-directory) |
3415 message-signature-file)) | 3414 message-signature-file)) |
3416 (file-exists-p signature-file)))) | 3415 (file-exists-p signature-file)))) |
3417 (when signature | 3416 (when signature |
3418 (goto-char (point-max)) | 3417 (goto-char (point-max)) |
3419 ;; Insert the signature. | 3418 ;; Insert the signature. |
4412 (setq n (+ n 1)) | 4411 (setq n (+ n 1)) |
4413 (setq p (pop plist)) | 4412 (setq p (pop plist)) |
4414 (erase-buffer))) | 4413 (erase-buffer))) |
4415 (kill-buffer tembuf)))) | 4414 (kill-buffer tembuf)))) |
4416 | 4415 |
4416 (declare-function hashcash-wait-async "hashcash" (&optional buffer)) | |
4417 | |
4417 (defun message-send-mail (&optional arg) | 4418 (defun message-send-mail (&optional arg) |
4418 (require 'mail-utils) | 4419 (require 'mail-utils) |
4419 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp")) | 4420 (let* ((tembuf (message-generate-new-buffer-clone-locals " message temp")) |
4420 (case-fold-search nil) | 4421 (case-fold-search nil) |
4421 (news (message-news-p)) | 4422 (news (message-news-p)) |
4422 (mailbuf (current-buffer)) | 4423 (mailbuf (current-buffer)) |
4423 (message-this-is-mail t) | 4424 (message-this-is-mail t) |
4425 ;; gnus-setup-posting-charset is autoloaded in mml.el (FIXME | |
4426 ;; maybe it should not be), which this file requires. Hence | |
4427 ;; the fboundp test is always true. Loading it from gnus-msg | |
4428 ;; loads many Gnus files (Bug#5642). If | |
4429 ;; gnus-group-posting-charset-alist hasn't been customized, | |
4430 ;; this is just going to return nil anyway. FIXME it would | |
4431 ;; be good to improve this further, because even if g-g-p-c-a | |
4432 ;; has been customized, that is likely to just be for news. | |
4433 ;; Eg either move the definition from gnus-msg, or separate out | |
4434 ;; the mail and news parts. | |
4424 (message-posting-charset | 4435 (message-posting-charset |
4425 (if (fboundp 'gnus-setup-posting-charset) | 4436 (if (and (fboundp 'gnus-setup-posting-charset) |
4437 (boundp 'gnus-group-posting-charset-alist)) | |
4426 (gnus-setup-posting-charset nil) | 4438 (gnus-setup-posting-charset nil) |
4427 message-posting-charset)) | 4439 message-posting-charset)) |
4428 (headers message-required-mail-headers)) | 4440 (headers message-required-mail-headers)) |
4429 (when (and message-generate-hashcash | 4441 (when (and message-generate-hashcash |
4430 (not (eq message-generate-hashcash 'opportunistic))) | 4442 (not (eq message-generate-hashcash 'opportunistic))) |
4431 (message "Generating hashcash...") | 4443 (message "Generating hashcash...") |
4444 (require 'hashcash) | |
4432 ;; Wait for calculations already started to finish... | 4445 ;; Wait for calculations already started to finish... |
4433 (hashcash-wait-async) | 4446 (hashcash-wait-async) |
4434 ;; ...and do calculations not already done. mail-add-payment | 4447 ;; ...and do calculations not already done. mail-add-payment |
4435 ;; will leave existing X-Hashcash headers alone. | 4448 ;; will leave existing X-Hashcash headers alone. |
4436 (mail-add-payment) | 4449 (mail-add-payment) |
4548 (set-buffer mailbuf) | 4561 (set-buffer mailbuf) |
4549 (push 'mail message-sent-message-via))) | 4562 (push 'mail message-sent-message-via))) |
4550 | 4563 |
4551 (defun message-send-mail-with-sendmail () | 4564 (defun message-send-mail-with-sendmail () |
4552 "Send off the prepared buffer with sendmail." | 4565 "Send off the prepared buffer with sendmail." |
4566 (require 'sendmail) | |
4553 (let ((errbuf (if message-interactive | 4567 (let ((errbuf (if message-interactive |
4554 (message-generate-new-buffer-clone-locals | 4568 (message-generate-new-buffer-clone-locals |
4555 " sendmail errors") | 4569 " sendmail errors") |
4556 0)) | 4570 0)) |
4557 resend-to-addresses delimline) | 4571 resend-to-addresses delimline) |
4711 (sha1 (concat (message-unique-id) | 4725 (sha1 (concat (message-unique-id) |
4712 (format "%x%x%x" (random) (random t) (random)) | 4726 (format "%x%x%x" (random) (random t) (random)) |
4713 (prin1-to-string (recent-keys)) | 4727 (prin1-to-string (recent-keys)) |
4714 (prin1-to-string (garbage-collect)))))) | 4728 (prin1-to-string (garbage-collect)))))) |
4715 | 4729 |
4730 (defvar canlock-password) | |
4731 (defvar canlock-password-for-verify) | |
4732 | |
4716 (defun message-canlock-password () | 4733 (defun message-canlock-password () |
4717 "The password used by message for cancel locks. | 4734 "The password used by message for cancel locks. |
4718 This is the value of `canlock-password', if that option is non-nil. | 4735 This is the value of `canlock-password', if that option is non-nil. |
4719 Otherwise, generate and save a value for `canlock-password' first." | 4736 Otherwise, generate and save a value for `canlock-password' first." |
4737 (require 'canlock) | |
4720 (unless canlock-password | 4738 (unless canlock-password |
4721 (customize-save-variable 'canlock-password (message-canlock-generate)) | 4739 (customize-save-variable 'canlock-password (message-canlock-generate)) |
4722 (setq canlock-password-for-verify canlock-password)) | 4740 (setq canlock-password-for-verify canlock-password)) |
4723 canlock-password) | 4741 canlock-password) |
4724 | 4742 |
4725 (defun message-insert-canlock () | 4743 (defun message-insert-canlock () |
4726 (when message-insert-canlock | 4744 (when message-insert-canlock |
4727 (message-canlock-password) | 4745 (message-canlock-password) |
4728 (canlock-insert-header))) | 4746 (canlock-insert-header))) |
4729 | 4747 |
4748 (autoload 'nnheader-get-report "nnheader") | |
4749 | |
4750 (declare-function gnus-setup-posting-charset "gnus-msg" (group)) | |
4751 | |
4730 (defun message-send-news (&optional arg) | 4752 (defun message-send-news (&optional arg) |
4753 (require 'gnus-msg) | |
4731 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*")) | 4754 (let* ((tembuf (message-generate-new-buffer-clone-locals " *message temp*")) |
4732 (case-fold-search nil) | 4755 (case-fold-search nil) |
4733 (method (if (functionp message-post-method) | 4756 (method (if (functionp message-post-method) |
4734 (funcall message-post-method arg) | 4757 (funcall message-post-method arg) |
4735 message-post-method)) | 4758 message-post-method)) |
5464 (int-to-string (count-lines (point) (point-max)))))) | 5487 (int-to-string (count-lines (point) (point-max)))))) |
5465 | 5488 |
5466 (defun message-make-references () | 5489 (defun message-make-references () |
5467 "Return the References header for this message." | 5490 "Return the References header for this message." |
5468 (when message-reply-headers | 5491 (when message-reply-headers |
5469 (let ((message-id (mail-header-message-id message-reply-headers)) | 5492 (let ((message-id (mail-header-id message-reply-headers)) |
5470 (references (mail-header-references message-reply-headers))) | 5493 (references (mail-header-references message-reply-headers))) |
5471 (if (or references message-id) | 5494 (if (or references message-id) |
5472 (concat (or references "") (and references " ") | 5495 (concat (or references "") (and references " ") |
5473 (or message-id "")) | 5496 (or message-id "")) |
5474 nil)))) | 5497 nil)))) |
5476 (defun message-make-in-reply-to () | 5499 (defun message-make-in-reply-to () |
5477 "Return the In-Reply-To header for this message." | 5500 "Return the In-Reply-To header for this message." |
5478 (when message-reply-headers | 5501 (when message-reply-headers |
5479 (let ((from (mail-header-from message-reply-headers)) | 5502 (let ((from (mail-header-from message-reply-headers)) |
5480 (date (mail-header-date message-reply-headers)) | 5503 (date (mail-header-date message-reply-headers)) |
5481 (msg-id (mail-header-message-id message-reply-headers))) | 5504 (msg-id (mail-header-id message-reply-headers))) |
5482 (when from | 5505 (when from |
5483 (let ((name (mail-extract-address-components from))) | 5506 (let ((name (mail-extract-address-components from))) |
5484 (concat | 5507 (concat |
5485 msg-id (if msg-id " (") | 5508 msg-id (if msg-id " (") |
5486 (if (car name) | 5509 (if (car name) |
8001 (setq result (or result (looking-at regexp)))) | 8024 (setq result (or result (looking-at regexp)))) |
8002 (if reverse | 8025 (if reverse |
8003 (not result) | 8026 (not result) |
8004 result))) | 8027 result))) |
8005 | 8028 |
8029 (declare-function ecomplete-add-item "ecomplete" (type key text)) | |
8030 (declare-function ecomplete-save "ecomplete" ()) | |
8031 | |
8006 (defun message-put-addresses-in-ecomplete () | 8032 (defun message-put-addresses-in-ecomplete () |
8033 (require 'ecomplete) | |
8007 (dolist (header '("to" "cc" "from" "reply-to")) | 8034 (dolist (header '("to" "cc" "from" "reply-to")) |
8008 (let ((value (message-field-value header))) | 8035 (let ((value (message-field-value header))) |
8009 (dolist (string (mail-header-parse-addresses value 'raw)) | 8036 (dolist (string (mail-header-parse-addresses value 'raw)) |
8010 (setq string | 8037 (setq string |
8011 (gnus-replace-in-string | 8038 (gnus-replace-in-string |
8012 (gnus-replace-in-string string "^ +\\| +$" "") "\n" "")) | 8039 (gnus-replace-in-string string "^ +\\| +$" "") "\n" "")) |
8013 (ecomplete-add-item 'mail (car (mail-header-parse-address string)) | 8040 (ecomplete-add-item 'mail (car (mail-header-parse-address string)) |
8014 string)))) | 8041 string)))) |
8015 (ecomplete-save)) | 8042 (ecomplete-save)) |
8043 | |
8044 (autoload 'ecomplete-display-matches "ecomplete") | |
8016 | 8045 |
8017 (defun message-display-abbrev (&optional choose) | 8046 (defun message-display-abbrev (&optional choose) |
8018 "Display the next possible abbrev for the text before point." | 8047 "Display the next possible abbrev for the text before point." |
8019 (interactive (list t)) | 8048 (interactive (list t)) |
8020 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?\t ? )) | 8049 (when (and (memq (char-after (point-at-bol)) '(?C ?T ?\t ? )) |