]> git.cworth.org Git - notmuch/commitdiff
emacs: improve how cl-lib and pcase are required
authorJonas Bernoulli <jonas@bernoul.li>
Sun, 10 Jan 2021 14:01:07 +0000 (15:01 +0100)
committerDavid Bremner <david@tethera.net>
Fri, 15 Jan 2021 10:46:38 +0000 (06:46 -0400)
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.)

14 files changed:
emacs/notmuch-address.el
emacs/notmuch-company.el
emacs/notmuch-draft.el
emacs/notmuch-hello.el
emacs/notmuch-jump.el
emacs/notmuch-lib.el
emacs/notmuch-maildir-fcc.el
emacs/notmuch-message.el
emacs/notmuch-mua.el
emacs/notmuch-parser.el
emacs/notmuch-show.el
emacs/notmuch-tag.el
emacs/notmuch-tree.el
emacs/notmuch.el

index f313c4152c7b58a6754e349170884eb85447a638..ca24c744210f0d80c9d29aeaf94c05cd6dae32d1 100644 (file)
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 (require 'notmuch-parser)
 (require 'notmuch-lib)
index 4439cc15edbd7b426b465dbeb8bd30c20766c58f..c6a004aebe92bcd447ee93729a54a2518052200b 100644 (file)
@@ -32,8 +32,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'notmuch-lib)
 
 (defvar-local notmuch-company-last-prefix nil)
index bc688434ec874d142eb356f66c29cb93f46dad69..2939da555690bb4ac0bc7a8b5c86a4167a611bce 100644 (file)
@@ -25,6 +25,9 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+(require 'pcase)
+
 (require 'notmuch-maildir-fcc)
 (require 'notmuch-tag)
 
index 186ac172c3f21175ca14b14d79edec0e1a03cd39..24d2d19e20d4c24e7d77e77312916eab818fcc10 100644 (file)
@@ -21,7 +21,6 @@
 
 ;;; Code:
 
-(require 'cl-lib)
 (require 'widget)
 (require 'wid-edit) ; For `widget-forward'.
 
index 34d6c796d0af0ae021b9254c7e1a2e3562212bfe..6fab5a792ec6b4da7daaacd2ad789653403b49ad 100644 (file)
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl-lib)
-  (require 'pcase))
-
 (require 'notmuch-lib)
 (require 'notmuch-hello)
 
index cbac88593c2fe56c431a455bc545eea39e538d08..6130309ab73aa425387517c9ae2fbcf246946b4b 100644 (file)
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'cl-lib)
+(require 'pcase)
 
 (require 'mm-util)
 (require 'mm-view)
index 9a6365babd3d0a4f617a63a707eb84868b060156..ae8f5140f34d2b2283bc9507b0744c6f30640700 100644 (file)
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 
 (require 'notmuch-lib)
index abeff53a7b87196742b36cdfa9981b15b461b9a9..b90c934af4856c49d6ff7c32a2f7c909f03abf14 100644 (file)
@@ -21,6 +21,9 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+(require 'pcase)
+
 (require 'message)
 (require 'notmuch-tag)
 
index 2e4dc71a8d5a7358e4addf1036a2d169ee6fc2e3..c5b1b4829b0d1f1fcc045f4c1298b1ba97851470 100644 (file)
@@ -21,8 +21,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'message)
 (require 'mm-view)
 (require 'format-spec)
index 294e05445b467ac98504d4810053b270c6b3a074..9749a6be51bd6e2c6577d2d24e3112a014294de4 100644 (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.
index 27925669dad1d316bef63928db2ccecbe1b9986c..ea4444e5d744bb76aaaebe2640e175e2bac52455 100644 (file)
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl-lib)
-  (require 'pcase))
-
 (require 'mm-view)
 (require 'message)
 (require 'mm-decode)
index 3c958dd44f693b4d9d94d9fdd9af68073c084a75..982b372c41b11956d6f289716c07877c3428eed9 100644 (file)
 
 ;;; Code:
 
-(require 'cl-lib)
-(eval-when-compile
-  (require 'pcase))
-
 (require 'crm)
 
 (require 'notmuch-lib)
index 51a43eddc6c67a9ba55030d8ed77291343b31788..95d5f642c0de22bf829bd6ad57d3d4bb620d71af 100644 (file)
@@ -24,8 +24,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'mail-parse)
 
 (require 'notmuch-lib)
index 3436e1fcd8a77e50972e7574e1bf86785b2a7090..d2e87b1b1256f5aaa456b726df8667e13cead700 100644 (file)
@@ -65,8 +65,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
-
 (require 'mm-view)
 (require 'message)