diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-18 23:11:36 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-18 23:32:52 -0700 |
commit | 0d0ec3916c1a7089dc172347b0031cca4046b21d (patch) | |
tree | 7f58d8f75b9df91b6ad1da36d81f6188e1685254 | |
parent | 27fd09aaa26563f0c8f0b6fc6481cc646015e25c (diff) | |
download | mailscripts-0d0ec3916c1a7089dc172347b0031cca4046b21d.tar.gz |
mailscripts.el: load notmuch and gnus libs only when required
They are both large, and most users will use at most one of the two.
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | mailscripts.el | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 5aea66f..f5bf071 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ mailscripts (28-1) UNRELEASED; urgency=medium - new commands: mailscripts-git-format-patch-{attach,drafts} - new DWIM wrapper command: mailscripts-prepare-patch - rewrite short description and add a brief commentary + - load the notmuch library only when code that requires it is called - move the mailscripts customisation group into the mail group - add declarations to fix byte compilation warnings - fix usage of cl-case in an internal function. diff --git a/mailscripts.el b/mailscripts.el index e255aec..566b38b 100644 --- a/mailscripts.el +++ b/mailscripts.el @@ -33,11 +33,11 @@ ;;; Code: (require 'cl-lib) -(require 'notmuch) (require 'thingatpt) (require 'vc) (require 'message) -(require 'gnus) + +(eval-when-compile (require 'notmuch)) (defgroup mailscripts nil "Customisation of functions in the mailscripts package." @@ -81,6 +81,7 @@ must be set to the one you use." If NO-OPEN, don't open the thread." (interactive "sBug number: ") + (require 'notmuch) (call-process-shell-command (concat "notmuch-slurp-debbug " bug)) (unless no-open (let* ((search (concat "Bug#" bug)) @@ -102,10 +103,14 @@ If NO-OPEN, don't open the thread." (skip-chars-forward "#bBug" (+ 4 (point))) (notmuch-slurp-debbug (number-to-string (number-at-point))))) +(declare-function notmuch-show-get-subject "notmuch-show") +(declare-function notmuch-refresh-this-buffer "notmuch-lib") + ;;;###autoload (defun notmuch-slurp-this-debbug () "When viewing a Debian bug in notmuch, download any missing messages." (interactive) + (require 'notmuch) (let ((subject (notmuch-show-get-subject))) (notmuch-slurp-debbug (if (string-match "Bug#\\([0-9]+\\):" subject) @@ -128,6 +133,7 @@ particular, this Emacs Lisp function supports passing only entire threads to the notmuch-extract-patch(1) command." (interactive "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): \nP") + (require 'notmuch) (let ((thread-id ;; If `notmuch-show' was called with a notmuch query rather ;; than a thread ID, as `org-notmuch-follow-link' in @@ -165,6 +171,10 @@ threads to the notmuch-extract-patch(1) command." (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) +(declare-function notmuch-foreach-mime-part "notmuch") +(declare-function notmuch--call-process "notmuch-lib") +(declare-function notmuch-show-get-message-id "notmuch-show") + ;;;###autoload (defun notmuch-extract-message-patches (repo branch) "Extract patches attached to current message to branch BRANCH in repo REPO. @@ -176,6 +186,7 @@ attachments with filenames which look like they were generated by git-format-patch(1)." (interactive "Dgit repo: \nsnew branch name (or leave blank to apply to current HEAD): ") + (require 'notmuch) (with-current-notmuch-show-message (let ((default-directory (expand-file-name repo)) (mm-handle (mm-dissect-buffer t))) @@ -288,6 +299,7 @@ See also the interactive wrapper command `mailscripts-prepare-patch'." (declare-function gnus-group-read-ephemeral-group "gnus-group") (defun mailscripts--gfp-drafts-gnus (args) + (require 'gnus) (let* ((temp (make-temp-file "patches")) (group (concat "nndoc+ephemeral:" temp)) (method `(nndoc ,temp (nndoc-article-type mbox))) @@ -311,6 +323,7 @@ See also the interactive wrapper command `mailscripts-prepare-patch'." (gnus-summary-goto-article message-id))) (defun mailscripts--gfp-drafts-notmuch (args) + (require 'notmuch) (let ((temp (make-temp-file "patches" t)) (insert (cl-list* "insert" (format "--folder=%s" notmuch-draft-folder) "--create-folder" notmuch-draft-tags))) |