emacs: improve how cl-lib and pcase are required

We need to load `cl-lib' at run-time because we use more from it than
just macros.  Never-the-less many, but not all libraries required it
only at compile-time, which we got away with because at least some
libraries already required it at run-time as well.

We use `cl-lib' and (currently to a lesser extend) `pcase' throughout
the code-base, which means that we should require these features in
most libraries.

In the past we tried to only require these features in just the
libraries that actually need them, without fully succeeding.  We did
not succeed in doing so because that means we would have to check
every time that we use a function from these features whether they
are already being required in the current library.

An alternative would be to add the `require' forms at the top of every
library but that is a bit annoying too.

In order to make sure that these features are loaded when needed but
also to keep the noise down we only require them in "notmuch-lib.el",
which most other libraries require, and in most of the few libraries
that do not do so, namely "notmuch-draft.el", "notmuch-message.el" and
"notmuch-parser.el".  ("coolj.el", "make-deps.el", various generated
libraries, and "notmuch-compat.el" are left touched.)
This commit is contained in:
Jonas Bernoulli 2021-01-10 15:01:07 +01:00 committed by David Bremner
parent f47e3333b5
commit 9ca1f945d9
14 changed files with 9 additions and 26 deletions

View file

@ -21,8 +21,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'message)
(require 'notmuch-parser)
(require 'notmuch-lib)

View file

@ -32,8 +32,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'notmuch-lib)
(defvar-local notmuch-company-last-prefix nil)

View file

@ -25,6 +25,9 @@
;;; Code:
(require 'cl-lib)
(require 'pcase)
(require 'notmuch-maildir-fcc)
(require 'notmuch-tag)

View file

@ -21,7 +21,6 @@
;;; Code:
(require 'cl-lib)
(require 'widget)
(require 'wid-edit) ; For `widget-forward'.

View file

@ -22,10 +22,6 @@
;;; Code:
(eval-when-compile
(require 'cl-lib)
(require 'pcase))
(require 'notmuch-lib)
(require 'notmuch-hello)

View file

@ -22,6 +22,7 @@
;;; Code:
(require 'cl-lib)
(require 'pcase)
(require 'mm-util)
(require 'mm-view)

View file

@ -21,8 +21,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'message)
(require 'notmuch-lib)

View file

@ -21,6 +21,9 @@
;;; Code:
(require 'cl-lib)
(require 'pcase)
(require 'message)
(require 'notmuch-tag)

View file

@ -21,8 +21,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'message)
(require 'mm-view)
(require 'format-spec)

View file

@ -21,7 +21,8 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'cl-lib)
(require 'pcase)
(defun notmuch-sexp-create-parser ()
"Return a new streaming S-expression parser.

View file

@ -23,10 +23,6 @@
;;; Code:
(eval-when-compile
(require 'cl-lib)
(require 'pcase))
(require 'mm-view)
(require 'message)
(require 'mm-decode)

View file

@ -23,10 +23,6 @@
;;; Code:
(require 'cl-lib)
(eval-when-compile
(require 'pcase))
(require 'crm)
(require 'notmuch-lib)

View file

@ -24,8 +24,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'mail-parse)
(require 'notmuch-lib)

View file

@ -65,8 +65,6 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'mm-view)
(require 'message)