Skip to content

Commit

Permalink
feat(core): disable individual modules packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 6, 2023
1 parent 0e4c53d commit 4b91dc0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/me-bootstrap.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@
;; Defer loading packages by default, use `:demand' to force loading a package
use-package-always-defer t)

;; HACK: This advice around `use-package' checks if a package is disabled
;; `minemacs-disabled-packages' before calling `use-package'. This can come
;; handy if the user wants to enable some module while excluding some packages
;; from it.
(advice-add
'use-package :around
(defun +use-package--check-if-disabled-a (origfn package &rest args)
(unless (memq package minemacs-disabled-packages)
(apply origfn package args))))

;; The previous advice will be removed after loading MinEmacs packages to avoid
;; messing with the user configuration (for example, if the user manually
;; install a disabled package).
(add-hook
'minemacs-after-loading-modules-hook
(defun +use-package--remove-check-if-disabled-advice-h ()
(advice-remove 'use-package '+use-package--check-if-disabled-a)))

(provide 'me-bootstrap)

Expand Down
5 changes: 5 additions & 0 deletions core/me-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ Compiled from the `system-configuration-features'.")
:group 'minemacs-ui
:type 'symbol)

(defcustom minemacs-disabled-packages '()
"List of packages to be disabled when loading MinEmacs modules.
This can be useful if you want to enable a module but you don't want a package
of being enabled.")

(defcustom minemacs-after-loading-modules-hook nil
"This hook will be run after loading MinEmacs modules.
It is used internally to remove the `+use-package--check-if-disabled-a' advice
Expand Down

0 comments on commit 4b91dc0

Please sign in to comment.