Skip to content

Commit

Permalink
fix(use-package): better checking for disabled packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Oct 21, 2023
1 parent 64b6f26 commit 71b2ad6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
8 changes: 7 additions & 1 deletion core/me-use-package-extra.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
(advice-add
'use-package :around
(defun +use-package--check-if-disabled-a (origfn package &rest args)
(unless (+package-disabled-p package)
(when (and (not (+package-disabled-p package))
(or (not (memq :if args))
(and (memq :if args) (eval (plist-get args :if))))
(or (not (memq :when args))
(and (memq :when args) (eval (plist-get args :when))))
(or (not (memq :unless args))
(and (memq :unless args) (not (eval (plist-get args :unless))))))
(add-to-list 'minemacs-configured-packages package t)
(apply origfn package args))))

Expand Down
4 changes: 2 additions & 2 deletions modules/me-biblio.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

;;; Code:

(defconst +zotero-available-p (executable-find "zotero"))

(use-package zotxt
:straight t
:preface
(defconst +zotero-available-p (executable-find "zotero"))
:when +zotero-available-p
:init
(+map-local! :keymaps 'org-mode-map
Expand Down
4 changes: 2 additions & 2 deletions modules/me-debug.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
:straight t
:commands (ipdb realgud:ipdb))

(defconst +objdump-available-p (executable-find "objdump"))

(use-package disaster
:straight t
:preface
(defconst +objdump-available-p (executable-find "objdump"))
:when +objdump-available-p
:init
(+map-local! :keymaps '(c-mode-map c++-mode-map fortran-mode-map)
Expand Down
6 changes: 3 additions & 3 deletions modules/me-docs.el
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
'(:eval (doom-modeline-segment--major-mode))))))))))
(:eval (doom-modeline-segment--major-mode))))))

(defconst +tuntox-available-p (executable-find "tuntox"))
(defconst +stunnel-available-p (executable-find "stunnel"))

(use-package crdt
:straight t
:preface
(defconst +tuntox-available-p (executable-find "tuntox"))
(defconst +stunnel-available-p (executable-find "stunnel"))
:when (or +tuntox-available-p +stunnel-available-p)
:init
(cond (+tuntox-available-p
Expand Down
4 changes: 2 additions & 2 deletions modules/me-media.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
`((,(rx (seq "http" (? ?s) "://" (? "www.") (or "youtube.com" "youtu.be"))) . +browse-url-mpv)
("." . browse-url-default-browser))))

(defconst +mpv-available-p (executable-find +mpv-command))

(use-package empv
:straight (:host github :repo "isamert/empv.el")
:preface
(defconst +mpv-available-p (executable-find +mpv-command))
:when +mpv-available-p
:init
(+map! :infix "o"
Expand Down
8 changes: 4 additions & 4 deletions modules/me-natural-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

;;; Code:

(defconst +aspell-available-p (executable-find "aspell"))

(use-package spell-fu
:straight t
:preface
(defconst +aspell-available-p (executable-find "aspell"))
:when +aspell-available-p
:hook (text-mode . spell-fu-mode)
:hook (spell-fu-mode . +spell-fu--init-excluded-faces-h)
Expand Down Expand Up @@ -166,10 +166,10 @@
(use-package reverso
:straight (:host github :repo "SqrtMinusOne/reverso.el"))

(defconst +sdcv-available-p (executable-find "sdcv"))

(use-package lexic
:straight t
:preface
(defconst +sdcv-available-p (executable-find "sdcv"))
:when +sdcv-available-p
:init
(+map! :infix "s"
Expand Down
4 changes: 2 additions & 2 deletions modules/me-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@
(logview-views-file (concat minemacs-local-dir "logview-views.el"))
(logview-cache-filename (concat minemacs-cache-dir "logview-cache.el")))

(defconst +bitwarden-available-p (executable-find "bw"))

(use-package bitwarden
:straight (:host github :repo "seanfarley/emacs-bitwarden")
:preface
(defconst +bitwarden-available-p (executable-find "bw"))
:when +bitwarden-available-p
:custom
(bitwarden-automatic-unlock
Expand Down
4 changes: 2 additions & 2 deletions modules/me-vc.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@
:init
:mode ("/.dockerignore\\'" . gitignore-mode))

(defconst +repo-available-p (executable-find "repo"))

(use-package repo
:straight t
:preface
(defconst +repo-available-p (executable-find "repo"))
:when +repo-available-p
:init
(+map! "gr" #'repo-status))
Expand Down

0 comments on commit 71b2ad6

Please sign in to comment.