add autoloads

This commit is contained in:
2025-07-06 21:39:24 +02:00
parent 807d0f28f6
commit efa2d5e78e
3 changed files with 133 additions and 11 deletions

View File

@@ -55,25 +55,43 @@ Fallbacks to `user-emacs-directory' if this file is not loaded.")
;; path where settings files are kept
(add-to-list 'load-path (concat config-dir "settings"))
;; add personal elisp lib dir, for manually installed packages
(defun add-to-load-path-with-subdirs (base &optional exclude-list include-list autoloads)
(defun add-to-load-path-with-subdirs (base &optional exclude-list include-list)
"This will add all first level dirs from BASE and exclude the ones in
EXCLUDE-LIST, while for the dirs in INCLUDE-LIST, it will add all the
first level dirs of that dir too.
Example: (add-to-list-with-subdirs \"~/.emacs.d\" '(\".\" \"..\" \"backup\") '(\"vendor\" \"my-lisp\"))"
(add-to-list 'load-path base)
Example: (add-to-load-path-with-subdirs \"~/.emacs.d\" '(\".\" \"..\" \"backup\") '(\"vendor\" \"my-lisp\"))"
(add-to-list 'load-path base t) ;; append so shipped packages are loaded first
(dolist (f (directory-files base))
(let ((name (concat base "/" f)))
(when (and (file-directory-p name)
(not (member f exclude-list)))
(add-to-list 'load-path name)
(when autoloads
(let ((fileal (concat name "/" (file-name-base name) "-autoloads.el"))
(nameal (concat (file-name-base name) "-autoloads")))
(when (file-exists-p fileal)
(require (intern nameal) fileal) )))
(add-to-list 'load-path name t) ;; append so shipped packages are loaded first
(when (member f include-list)
(add-to-load-path-with-subdirs name exclude-list include-list))))))
(add-to-load-path-with-subdirs (concat config-dir "lisp") '("." ".." "0patches") nil t))
(add-to-load-path-with-subdirs (concat config-dir "lisp") '("." ".." "0patches") nil)
;; load autoloads, not combined with function above because we need
;; load-path filled first and then we can load all autoloads, to
;; prevent loading parts from emacs buit-in packages. (for example
;; one custom packages refences to org features but custom org is
;; not yet in the load-path and therefore would load built-in org
;; instead)
(defun load-autoloads (base &optional exclude-list include-list)
"This will load all autoloads from all first level dirs from BASE and
exclude the ones in EXCLUDE-LIST, while for the dirs in INCLUDE-LIST,
it will load all the first level dirs of that dir too.
Example: (load-autoloads \"~/.emacs.d\" '(\".\" \"..\" \"backup\") '(\"vendor\" \"my-lisp\"))"
(dolist (f (directory-files base))
(let ((name (concat base "/" f)))
(when (and (file-directory-p name)
(not (member f exclude-list)))
(let ((fileal (concat name "/" (file-name-base name) "-autoloads.el"))
(nameal (concat (file-name-base name) "-autoloads")))
(when (file-exists-p fileal)
(require (intern nameal) fileal) ))
(when (member f include-list)
(add-to-load-path-with-subdirs-autoloads name exclude-list include-list))))))
(load-autoloads (concat config-dir "lisp") '("." ".." "0patches") nil)
)
;;; Load pre-early-init.el
@@ -440,7 +458,7 @@ startup phase.")
(add-to-list 'initial-frame-alist '(background-color . "#1e1e1e"))
(add-to-list 'initial-frame-alist '(foreground-color . "#b2b2b2"))
(when (display-graphic-p)
(when (featurep 'frame)
;; Custom functions/hooks for persisting/loading frame geometry upon save/load
(defvar my-frame-geometry-file (concat user-cache-directory "frame-geometry.el"))
(defun my-frame-geometry-save ()
@@ -506,6 +524,26 @@ startup phase.")
;;; Load post-early-init.el
;; (load (expand-file-name "post-early-init.el" user-emacs-directory) :no-error :no-message)
;; (setq use-default-font-for-symbols nil)
;; (defvar my-fontset
;; (create-fontset-from-fontset-spec standard-fontset-spec)
;; "Standard fontset for user.")
;; ;;(add-to-list 'default-frame-alist (cons 'font my-fontset))
;; ;;(add-to-list 'initial-frame-alist (cons 'font my-fontset))
;; (set-fontset-font my-fontset 'latin
;; (font-spec :family "NotoSansM Nerd Font Mono")
;; nil 'prepend)
;; (set-fontset-font my-fontset 'unicode
;; (font-spec :family "NotoSansM Nerd Font Mono")
;; nil 'prepend)
;; (dolist (charset '(kana han cjk-misc hangul kanbun bopomofo))
;; (set-fontset-font my-fontset charset
;; (font-spec :family "Noto Sans Mono CJK SC")
;; nil 'prepend))
;; (set-fontset-font my-fontset ?✿ (font-spec :family "Symbols Nerd Font Mono") nil 'prepend)
;; (add-to-list 'default-frame-alist '(font . my-fontset))
(provide 'early-init)