Major refactor & optimization of how modules load their packages
Now that we are loading package autoloads files (as part of the generated doom-package-autoload-file when running make autoloads), many :commands properties are redundant. In fact, many def-package! blocks are redundant. In some cases, we can do without a config.el file entirely, and can move into the autoloads file or rely entirely on package autoloads. Also, many settings have been moved in their module's autoloads files, which makes them available ASAP; their use no longer depends on module load order. This gained me a modest ~10% boost in startup speed.
This commit is contained in:
parent
6a140209b8
commit
09cb4f6716
93 changed files with 644 additions and 846 deletions
|
@ -114,16 +114,17 @@ Possible values:
|
|||
|
||||
(defun +doom-dashboard|init ()
|
||||
"Initializes Doom's dashboard."
|
||||
(add-hook 'window-configuration-change-hook #'+doom-dashboard|resize)
|
||||
(add-hook 'window-size-change-functions #'+doom-dashboard|resize)
|
||||
(add-hook 'kill-buffer-query-functions #'+doom-dashboard|reload-on-kill)
|
||||
(add-hook 'doom-after-switch-buffer-hook #'+doom-dashboard|reload-on-kill)
|
||||
(unless (daemonp)
|
||||
(add-hook 'after-make-frame-functions #'+doom-dashboard|make-frame))
|
||||
;; `persp-mode' integration: update `default-directory' when switching
|
||||
(add-hook 'persp-created-functions #'+doom-dashboard|record-project)
|
||||
(add-hook 'persp-activated-functions #'+doom-dashboard|detect-project)
|
||||
(add-hook 'persp-before-switch-functions #'+doom-dashboard|record-project)
|
||||
(unless noninteractive
|
||||
(add-hook 'window-configuration-change-hook #'+doom-dashboard|resize)
|
||||
(add-hook 'window-size-change-functions #'+doom-dashboard|resize)
|
||||
(add-hook 'kill-buffer-query-functions #'+doom-dashboard|reload-on-kill)
|
||||
(add-hook 'doom-after-switch-buffer-hook #'+doom-dashboard|reload-on-kill)
|
||||
(unless (daemonp)
|
||||
(add-hook 'after-make-frame-functions #'+doom-dashboard|make-frame))
|
||||
;; `persp-mode' integration: update `default-directory' when switching
|
||||
(add-hook 'persp-created-functions #'+doom-dashboard|record-project)
|
||||
(add-hook 'persp-activated-functions #'+doom-dashboard|detect-project)
|
||||
(add-hook 'persp-before-switch-functions #'+doom-dashboard|record-project))
|
||||
(+doom-dashboard-reload t))
|
||||
|
||||
(defun +doom-dashboard|reload-on-kill ()
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
;; mode-line.
|
||||
|
||||
(def-package! anzu
|
||||
:commands (anzu-mode global-anzu-mode
|
||||
anzu-query-replace anzu-query-replace-regexp
|
||||
anzu-query-replace-at-cursor anzu-replace-at-cursor-thing)
|
||||
:init
|
||||
(add-transient-hook! #'isearch-mode (require 'anzu))
|
||||
:after-call isearch-mode
|
||||
:config
|
||||
(setq anzu-cons-mode-line-p nil
|
||||
anzu-minimum-input-length 1
|
||||
|
@ -35,10 +31,7 @@
|
|||
|
||||
|
||||
(def-package! evil-anzu
|
||||
:defer t
|
||||
:init
|
||||
(add-transient-hook! #'evil-ex-start-search (require 'evil-anzu))
|
||||
(add-transient-hook! #'evil-ex-start-word-search (require 'evil-anzu)))
|
||||
:after-call (evil-ex-start-search evil-ex-start-word-search))
|
||||
|
||||
|
||||
;; fish-style modeline
|
||||
|
|
|
@ -22,10 +22,11 @@
|
|||
|
||||
;; <https://github.com/hlissner/emacs-doom-theme>
|
||||
(def-package! doom-themes
|
||||
:config
|
||||
:defer t
|
||||
:init
|
||||
(unless doom-theme
|
||||
(setq doom-theme 'doom-one))
|
||||
|
||||
:config
|
||||
;; Reload common faces when reloading doom-themes live
|
||||
(defun +doom*reload-common (&rest _) (load "doom-themes-common.el" nil t))
|
||||
(advice-add #'doom//reload-theme :before #'+doom*reload-common)
|
||||
|
@ -41,7 +42,7 @@
|
|||
|
||||
|
||||
(def-package! solaire-mode
|
||||
:commands (solaire-mode turn-on-solaire-mode solaire-mode-swap-bg)
|
||||
:defer t
|
||||
:init
|
||||
(defun +doom|solaire-mode-swap-bg-maybe ()
|
||||
(when-let* ((rule (assq doom-theme +doom-solaire-themes)))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(def-package! evil-goggles
|
||||
:when (featurep! :feature evil)
|
||||
:defer pre-command-hook
|
||||
:after-call pre-command-hook
|
||||
:init
|
||||
(setq evil-goggles-duration 0.05
|
||||
evil-goggles-pulse nil ; too slow
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; ui/nav-flash/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! nav-flash
|
||||
:commands nav-flash-show
|
||||
:defer t
|
||||
:init
|
||||
;; NOTE In :feature lookup `recenter' is hooked to a bunch of jumping
|
||||
;; commands, which will trigger nav-flash.
|
||||
|
|
|
@ -1,5 +1,73 @@
|
|||
;;; ui/popup/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defvar +popup--display-buffer-alist nil)
|
||||
|
||||
;;;###autoload
|
||||
(def-setting! :popup (condition &optional alist parameters)
|
||||
"Register a popup rule.
|
||||
|
||||
CONDITION can be a regexp string or a function. See `display-buffer' for a list
|
||||
of possible entries for ALIST, which tells the display system how to initialize
|
||||
the popup window. PARAMETERS is an alist of window parameters. See
|
||||
`+popup-window-parameters' for a list of custom parameters provided by the popup
|
||||
module.
|
||||
|
||||
ALIST supports one custom parameter: `size', which will resolve to
|
||||
`window-height' or `window-width' depending on `side'."
|
||||
`(progn
|
||||
(+popup-define ,condition ,alist ,parameters)
|
||||
(when (bound-and-true-p +popup-mode)
|
||||
(setq display-buffer-alist +popup--display-buffer-alist))
|
||||
+popup--display-buffer-alist))
|
||||
|
||||
;;;###autoload
|
||||
(def-setting! :popups (&rest rules)
|
||||
"Register multiple popup rules with :popup setting (`doom--set:popup'). For
|
||||
example:
|
||||
|
||||
(set! :popups
|
||||
(\"^ \\*\" '((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
|
||||
(\"^\\*\" '((slot . 1) (vslot . -1)) '((select . t))))"
|
||||
`(progn
|
||||
,@(cl-loop for rule in rules collect `(+popup-define ,@rule))
|
||||
(when (bound-and-true-p +popup-mode)
|
||||
(setq display-buffer-alist +popup--display-buffer-alist))
|
||||
+popup--display-buffer-alist))
|
||||
|
||||
;;;###autoload
|
||||
(defsubst +popup-define (condition &optional alist parameters)
|
||||
"Define a popup rule.
|
||||
|
||||
The buffers of new windows displayed by `pop-to-buffer' and `display-buffer'
|
||||
will be tested against CONDITION, which is either a) a regexp string (which is
|
||||
matched against the buffer's name) or b) a function that takes no arguments and
|
||||
returns a boolean.
|
||||
|
||||
If CONDITION is met, the buffer will be displayed in a popup window with ALIST
|
||||
and window PARAMETERS. See `display-buffer-alist' for details on what ALIST may
|
||||
contain and `+popup-window-parameters' for what window parameters that the popup
|
||||
module supports.
|
||||
|
||||
ALIST also supports the `size' parameter, which will be translated to
|
||||
`window-width' or `window-height' depending on `side'.
|
||||
|
||||
If certain attributes/parameters are omitted, the ones from
|
||||
`+popup-default-alist' and `+popup-default-parameters' will be used."
|
||||
(declare (indent 1))
|
||||
(push (if (eq alist :ignore)
|
||||
(list condition nil)
|
||||
`(,condition
|
||||
(+popup-buffer)
|
||||
,@alist
|
||||
(window-parameters ,@parameters)))
|
||||
+popup--display-buffer-alist))
|
||||
|
||||
|
||||
;;
|
||||
;; Library
|
||||
;;
|
||||
|
||||
(defvar +popup--populate-wparams (not EMACS26+))
|
||||
(defvar +popup--inhibit-transient nil)
|
||||
(defvar +popup--inhibit-select nil)
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
;;; ui/popup/init.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +popup--display-buffer-alist nil)
|
||||
|
||||
(defun +popup-define (condition &optional alist parameters)
|
||||
"Define a popup rule.
|
||||
|
||||
The buffers of new windows displayed by `pop-to-buffer' and `display-buffer'
|
||||
will be tested against CONDITION, which is either a) a regexp string (which is
|
||||
matched against the buffer's name) or b) a function that takes no arguments and
|
||||
returns a boolean.
|
||||
|
||||
If CONDITION is met, the buffer will be displayed in a popup window with ALIST
|
||||
and window PARAMETERS. See `display-buffer-alist' for details on what ALIST may
|
||||
contain and `+popup-window-parameters' for what window parameters that the popup
|
||||
module supports.
|
||||
|
||||
ALIST also supports the `size' parameter, which will be translated to
|
||||
`window-width' or `window-height' depending on `side'.
|
||||
|
||||
If certain attributes/parameters are omitted, the ones from
|
||||
`+popup-default-alist' and `+popup-default-parameters' will be used."
|
||||
(declare (indent 1))
|
||||
(push (if (eq alist :ignore)
|
||||
(list condition nil)
|
||||
`(,condition
|
||||
(+popup-buffer)
|
||||
,@alist
|
||||
(window-parameters ,@parameters)))
|
||||
+popup--display-buffer-alist))
|
||||
|
||||
;;
|
||||
(def-setting! :popup (condition &optional alist parameters)
|
||||
"Register a popup rule.
|
||||
|
||||
CONDITION can be a regexp string or a function. See `display-buffer' for a list
|
||||
of possible entries for ALIST, which tells the display system how to initialize
|
||||
the popup window. PARAMETERS is an alist of window parameters. See
|
||||
`+popup-window-parameters' for a list of custom parameters provided by the popup
|
||||
module.
|
||||
|
||||
ALIST supports one custom parameter: `size', which will resolve to
|
||||
`window-height' or `window-width' depending on `side'."
|
||||
`(progn
|
||||
(+popup-define ,condition ,alist ,parameters)
|
||||
(when (bound-and-true-p +popup-mode)
|
||||
(setq display-buffer-alist +popup--display-buffer-alist))
|
||||
+popup--display-buffer-alist))
|
||||
|
||||
(def-setting! :popups (&rest rules)
|
||||
"Register multiple popup rules with :popup setting (`doom--set:popup'). For
|
||||
example:
|
||||
|
||||
(set! :popups
|
||||
(\"^ \\*\" '((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
|
||||
(\"^\\*\" '((slot . 1) (vslot . -1)) '((select . t))))"
|
||||
`(progn
|
||||
,@(cl-loop for rule in rules collect `(+popup-define ,@rule))
|
||||
(when (bound-and-true-p +popup-mode)
|
||||
(setq display-buffer-alist +popup--display-buffer-alist))
|
||||
+popup--display-buffer-alist))
|
23
modules/ui/unicode/autoload.el
Normal file
23
modules/ui/unicode/autoload.el
Normal file
|
@ -0,0 +1,23 @@
|
|||
;;; ui/unicode/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(add-hook 'doom-post-init-hook #'+unicode|init-fonts)
|
||||
|
||||
;;;###autoload
|
||||
(defun +unicode|init-fonts ()
|
||||
"Set up `unicode-fonts' to eventually run; accomodating the daemon, if
|
||||
necessary."
|
||||
(setq-default bidi-display-reordering t
|
||||
doom-unicode-font nil)
|
||||
(if initial-window-system
|
||||
(+unicode|setup-fonts (selected-frame))
|
||||
(add-hook 'after-make-frame-functions #'+unicode|setup-fonts)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +unicode|setup-fonts (&optional frame)
|
||||
"Initialize `unicode-fonts', if in a GUI session."
|
||||
(when (and frame (display-graphic-p frame))
|
||||
(with-selected-frame frame
|
||||
(require 'unicode-fonts)
|
||||
;; NOTE will impact startup time on first run
|
||||
(unicode-fonts-setup))))
|
|
@ -1,19 +0,0 @@
|
|||
;;; ui/unicode/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(def-package! unicode-fonts
|
||||
:init
|
||||
(setq-default bidi-display-reordering t
|
||||
doom-unicode-font nil)
|
||||
|
||||
(defun +unicode|init-fonts (&optional frame)
|
||||
"Initialize `unicode-fonts', if in a GUI session."
|
||||
(when (and frame (display-graphic-p frame))
|
||||
(with-selected-frame frame
|
||||
(require 'unicode-fonts)
|
||||
;; NOTE will impact startup time on first run
|
||||
(unicode-fonts-setup))))
|
||||
|
||||
(add-hook! 'after-init-hook
|
||||
(if initial-window-system
|
||||
(+unicode|init-fonts (selected-frame))
|
||||
(add-hook 'after-make-frame-functions #'+unicode|init-fonts))))
|
4
modules/ui/vi-tilde-fringe/autoload.el
Normal file
4
modules/ui/vi-tilde-fringe/autoload.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
;;; ui/vi-tilde-fringe/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(add-hook! (prog-mode text-mode conf-mode) #'vi-tilde-fringe-mode)
|
|
@ -1,6 +0,0 @@
|
|||
;;; ui/vi-tilde-fringe/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; indicators for empty lines past EOF
|
||||
(def-package! vi-tilde-fringe
|
||||
:hook ((prog-mode text-mode conf-mode) . vi-tilde-fringe-mode))
|
||||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
(def-package! switch-window
|
||||
:when (featurep! +switch-window)
|
||||
:commands (switch-window switch-window-then-maximize switch-window-then-split-below
|
||||
switch-window-then-split-right switch-window-then-delete
|
||||
switch-window-then-swap-buffer)
|
||||
:defer t
|
||||
:init
|
||||
(define-key global-map [remap other-window] #'switch-window)
|
||||
:config
|
||||
|
@ -14,8 +12,7 @@
|
|||
|
||||
(def-package! ace-window
|
||||
:unless (featurep! +switch-window)
|
||||
:commands (ace-window ace-swap-window ace-delete-window
|
||||
ace-select-window ace-delete-other-windows)
|
||||
:defer t
|
||||
:init
|
||||
(define-key global-map [remap other-window] #'ace-window)
|
||||
:config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue