Skip to content

Commit

Permalink
tweak(core): make minemacs-build-functions a special hook
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 22, 2023
1 parent 819c3cd commit 459981b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 24 deletions.
3 changes: 1 addition & 2 deletions core/me-core-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Useful for keeping track of the enabled theme."

(use-package nerd-icons
:straight t
:init
(+register-build-function! nerd-icons-install-fonts)
:hook (minemacs-build-functions . nerd-icons-install-fonts)
:config
;; Show .m files as matlab/octave files (integral icon)
(setcdr (assoc "m" nerd-icons-extension-icon-alist)
Expand Down
7 changes: 2 additions & 5 deletions core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,14 @@ Load environment variables from the file saved in
Add ROOTS to ignored projects, recentf, etc.
(fn &rest ROOTS)")
(autoload '+register-build-function! "../elisp/+minemacs" "\
Register build function FN to be called at the end of `minemacs-update'.

(fn FN)" nil t)
(autoload 'minemacs-run-build-functions "../elisp/+minemacs" "\
Run all build functions registered with `+register-build-function!'.
Run all build functions in `minemacs-build-functions'.
(fn &optional DONT-ASK-P)" t)
(autoload 'minemacs-update "../elisp/+minemacs" "\
Update MinEmacs packages." t)
(register-definition-prefixes "../elisp/+minemacs" '("+eval-when-idle-" "+hook-once-num" "+resolve-hook-forms" "+setq-hook-fns" "minemacs--build-functions"))
(register-definition-prefixes "../elisp/+minemacs" '("+eval-when-idle-" "+hook-once-num" "+resolve-hook-forms" "+setq-hook-fns"))


;;; Generated autoloads from ../elisp/+primitives.el
Expand Down
4 changes: 4 additions & 0 deletions core/me-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ MinEmacs hooks will be run in this order:
:group 'minemacs-core
:type 'hook)

(defvar minemacs-build-functions nil
"Special hook for build functions that are run after completing package updates.")
(defvaralias 'minemacs-build-functions-hook 'minemacs-build-functions)

;; Setup default fonts (depending on the OS)
(let ((mono-font (cond (os/linux "monospace")
(os/win "Lucida Console")
Expand Down
10 changes: 2 additions & 8 deletions elisp/+minemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,13 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
(with-eval-after-load 'recentf
(add-to-list 'recentf-exclude root))))

(defvar minemacs--build-functions nil
"These functions are run after completing package updates.")

;;;###autoload
(defmacro +register-build-function! (fn)
"Register build function FN to be called at the end of `minemacs-update'."
`(add-to-list 'minemacs--build-functions #',fn))

;;;###autoload
(defun minemacs-run-build-functions (&optional dont-ask-p)
"Run all build functions registered with `+register-build-function!'."
"Run all build functions in `minemacs-build-functions'."
(interactive)
(dolist (fn minemacs--build-functions)
(dolist (fn minemacs-build-functions)
(message "MinEmacs: Running `%s'" fn)
(if dont-ask-p
;; Do not ask before installing
Expand Down
5 changes: 2 additions & 3 deletions modules/me-docs.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
:straight t
:mode ("\\.pdf\\'" . pdf-view-mode)
:magic ("%PDF" . pdf-view-mode)
:hook (minemacs-build-functions . pdf-tools-install)
:custom
(pdf-view-display-size 'fit-page)
(pdf-view-image-relief 2)
(pdf-view-use-scaling t)
:init
(+register-build-function! pdf-tools-install))
(pdf-view-use-scaling t))

(use-package nov
:straight t
Expand Down
2 changes: 1 addition & 1 deletion modules/me-eaf.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

(use-package eaf
:straight (:host github :repo "emacs-eaf/emacs-application-framework" :files (:defaults "*"))
:hook (minemacs-build-functions . eaf-install-and-update)
:init
(+map! "oo" #'eaf-open)
;; Evil integration doesn't work, start `eaf-mode' in `emacs-state'.
(with-eval-after-load 'evil
(evil-set-initial-state 'eaf-mode 'emacs))
(+register-build-function! eaf-install-and-update)
:commands eaf-file-sender-qrcode-in-dired +browse-url-eaf eaf-open-browser
:custom
;; Generic
Expand Down
4 changes: 1 addition & 3 deletions modules/me-prog.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
(use-package treesit-auto
:straight (:host github :repo "renzmann/treesit-auto")
:hook (minemacs-after-startup . global-treesit-auto-mode)
:commands treesit-auto-install-all
:hook (minemacs-build-functions . treesit-auto-install-all)
:custom
(treesit-auto-install 'prompt)
:init
(+register-build-function! treesit-auto-install-all)
:config
;; Install all languages when calling `treesit-auto-install-all'
(setq treesit-language-source-alist (treesit-auto--build-treesit-source-alist)))
Expand Down
4 changes: 2 additions & 2 deletions modules/me-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

(use-package tldr
:straight t
:hook (minemacs-build-functions . tldr-update-docs)
:init
(+map! "ht" #'tldr)
(+register-build-function! tldr-update-docs)
:custom
(tldr-enabled-categories '("common" "linux" "osx")))

(use-package vterm
:straight t
:hook (minemacs-build-functions . vterm-module-compile)
:init
(+map!
"ot" '(nil :wk "vterm")
Expand All @@ -36,7 +37,6 @@
`(" \\*Install vterm\\*"
(display-buffer-no-window)
(allow-no-window . t)))
(+register-build-function! vterm-module-compile)
:custom
(vterm-always-compile-module t)
(vterm-max-scrollback 5000)
Expand Down

0 comments on commit 459981b

Please sign in to comment.