From 715167bec8450b0992561726e15a59de0a224fb0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 Jun 2018 13:05:40 +0200 Subject: [PATCH] Add ability to mark modules as obsolete or moved Better way to communicate to users that modules have moved without breaking their config. --- core/core-modules.el | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/core/core-modules.el b/core/core-modules.el index 3bd05ccd6..0485f1f77 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -10,6 +10,15 @@ (list (expand-file-name "modules/" doom-private-dir) doom-modules-dir) "A list of module root directories. Order determines priority.") +(defconst doom-obsolete-modules () + "An alist of deprecated modules, mapping deprecated modules to an optional new +location (which will create an alias). Each CAR and CDR is a (CATEGORY . +MODULE). E.g. + + ((:emacs . electric-indent) . (:emacs . electric)) + +A warning will be put out if these deprecated modules are used.") + (defvar doom--current-module nil) @@ -248,18 +257,25 @@ to least)." (cond ((keywordp m) (setq category m)) ((not category) (error "No module category specified for %s" m)) ((let* ((module (if (listp m) (car m) m)) - (flags (if (listp m) (cdr m))) - (path (doom-module-locate-path category module))) - (if (not path) - (message "Couldn't find the %s %s module" category module) - (let ((key (cons category module))) - (doom-module-set category module :flags flags :path path) - (push `(let ((doom--current-module ',key)) - (load! "init" ,path t)) - init-forms) - (push `(let ((doom--current-module ',key)) - (load! "config" ,path t)) - config-forms))))))) + (flags (if (listp m) (cdr m)))) + (when-let* ((new (assoc (cons category module) doom-obsolete-modules))) + (if-let* ((newkey (cdr new))) + (message "Warning: the %s module has been moved to %s" + (list category module) + (list (setq category (car newkey)) + (setq module (cdr newkey)))) + (message "Warning: the %s module is deprecated" key))) + (let ((path (doom-module-locate-path category module))) + (if (not path) + (message "Couldn't find the %s %s module" category module) + (let ((key (cons category module))) + (doom-module-set category module :flags flags :path path) + (push `(let ((doom--current-module ',key)) + (load! "init" ,path t)) + init-forms) + (push `(let ((doom--current-module ',key)) + (load! "config" ,path t)) + config-forms)))))))) `(let (file-name-handler-alist) (setq doom-modules ',doom-modules) ,@(nreverse init-forms)