Reframed with straight.el

This commit is contained in:
Zelong Kuang
2026-03-29 19:12:45 +11:00
parent 6b017648ef
commit e1374b0e88
31 changed files with 366 additions and 1077 deletions

View File

@@ -1,11 +1,88 @@
;; -*- lexical-binding: t -*-
;; Load some component of large package (org, magit etc.) before complete mount
(defvar elemacs-incremental-packages '(t)
"A list of packages to load incrementally after startup. Any large packages
here may cause noticeable pauses, so it's recommended you break them up into
sub-packages. For example, `org' is comprised of many packages, and can be
broken up into:
(elemacs-load-packages-incrementally
'(calendar find-func format-spec org-macs org-compat
org-faces org-entities org-list org-pcomplete org-src
org-footnote org-macro ob org org-clock org-agenda
org-capture))
This is already done by the lang/org module, however.
If you want to disable incremental loading altogether, either remove
`doom-load-packages-incrementally-h' from `emacs-startup-hook' or set
`doom-incremental-first-idle-timer' to nil. Incremental loading does not occur
in daemon sessions (they are loaded immediately at startup).")
(defvar elemacs-incremental-first-idle-timer 2.0
"How long (in idle seconds) until incremental loading starts.
Set this to nil to disable incremental loading.")
(defvar elemacs-incremental-idle-timer 0.75
"How long (in idle seconds) in between incrementally loading packages.")
(defvar elemacs-incremental-load-immediately (daemonp)
"If non-nil, load all incrementally deferred packages immediately at startup.")
(defun elemacs-load-packages-incrementally (packages &optional now)
"Registers PACKAGES to be loaded incrementally.
If NOW is non-nil, load PACKAGES incrementally, in `doom-incremental-idle-timer'
intervals."
(if (not now)
(setq elemacs-incremental-packages (append elemacs-incremental-packages packages ))
(while packages
(let* ((gc-cons-threshold most-positive-fixnum)
(req (pop packages)))
(unless (featurep req)
(message "Incrementally loading %s" req)
(condition-case-unless-debug e
(or (while-no-input
;; If `default-directory' is a directory that doesn't exist
;; or is unreadable, Emacs throws up file-missing errors, so
;; we set it to a directory we know exists and is readable.
(let ((default-directory user-emacs-directory)
(inhibit-message t)
file-name-handler-alist)
(require req nil t))
t)
(push req packages))
(error
(message "Failed to load %S package incrementally, because: %s"
req e)))
(if (not packages)
(message "Finished incremental loading")
(run-with-idle-timer elemacs-incremental-idle-timer
nil #'elemacs-load-packages-incrementally
packages t)
(setq packages nil)))))))
(defun elemacs-load-packages-incrementally-h ()
"Begin incrementally loading packages in `elemacs-incremental-packages'.
If this is a daemon session, load them all immediately instead."
(if elemacs-incremental-load-immediately
(mapc #'require (cdr elemacs-incremental-packages))
(when (numberp elemacs-incremental-first-idle-timer)
(run-with-idle-timer elemacs-incremental-first-idle-timer
nil #'elemacs-load-packages-incrementally
(cdr elemacs-incremental-packages) t))))
(add-hook 'emacs-startup-hook #'elemacs-load-packages-incrementally-h)
(use-package benchmark-init
:ensure t
:demand t
:config
;; To disable collection of benchmark data after init is done.
(add-hook 'elpaca-after-init-hook 'benchmark-init/deactivate))
(add-hook 'after-init-hook 'benchmark-init/deactivate))
(when (memq window-system '(mac ns x))
(use-package exec-path-from-shell
@@ -13,11 +90,11 @@
(exec-path-from-shell-initialize)))
(setq custom-file (expand-file-name "~/.emacs.d/custom.el"))
(add-hook 'elpaca-after-init-hook (lambda () (load custom-file 'no-error 'no-message)))
(add-hook 'after-init-hook (lambda () (load custom-file 'no-error 'no-message)))
(use-package server
:ensure nil
:hook (elpaca-after-init . server-mode))
:hook (after-init . server-mode))
(use-package display-line-numbers
:ensure nil
@@ -35,10 +112,6 @@
(setq display-line-numbers-type 'relative)
)
;; (use-package delete-trailing
;; :ensure nil
;; :hook (text-mode delete-trailing-whitespace-mode)
;; :hook (prog-mode delete-trailing-whitespace-mode))
(add-hook 'prog-mode #'delete-trailing-whitespace-mode)
(add-hook 'text-mode #'delete-trailing-whitespace-mode)
@@ -49,7 +122,7 @@
(use-package paren
:ensure nil
:hook (elpaca-after-init . show-paren-mode))
:hook (after-init . show-paren-mode))
;; Show trailing whitespace only in prog-mode and text-mode
(add-hook 'prog-mode-hook (lambda () (setq show-trailing-whitespace t)))
@@ -57,7 +130,7 @@
(use-package recentf
:ensure nil
:hook (elpaca-after-init . recentf-mode)
:hook (after-init . recentf-mode)
:custom
(recentf-max-saved-items 500)
(recentf-exclude
@@ -67,13 +140,14 @@
"^/tmp/" "^/var/folders/.+$" "^/ssh:" "/persp-confs/"
(lambda (file) (file-in-directory-p file package-user-dir))))
:config
(elemacs-load-packages-incrementally '(easymenu tree-widget timer))
(push (expand-file-name recentf-save-file) recentf-exclude)
(add-to-list 'recentf-filename-handlers #'abbreviate-file-name)
)
(use-package savehist
:ensure nil
:hook (elpaca-after-init . savehist-mode)
:hook (after-init . savehist-mode)
:init (setq enable-recursive-minibuffers t ; Allow commands in minibuffers
history-length 1000
savehist-additional-variables '(mark-ring
@@ -126,7 +200,7 @@
(use-package browse-kill-ring
:bind ("C-c k" . browse-kill-ring)
:hook (elpaca-after-init . browse-kill-ring-default-keybindings)
:hook (after-init . browse-kill-ring-default-keybindings)
:init (setq browse-kill-ring-separator "────────────────"
browse-kill-ring-separator-face 'shadow))
@@ -134,7 +208,7 @@
:init
(setq scroll-conservatively 3
scroll-margin 0)
:hook (elpaca-after-init . ultra-scroll-mode))
:hook (after-init . ultra-scroll-mode))
(use-package helpful
:bind (([remap describe-function] . helpful-callable)
@@ -166,6 +240,7 @@
(helpful-variable (button-get button 'apropos-symbol))))))))
(setq-default auto-save-default nil)
(setq create-lockfiles nil)
;; (setq auto-save-file-name-transforms
;; `((".*" ,(concat user-emacs-directory "auto-save/") t)))
@@ -174,7 +249,7 @@
(tramp-hlo-setup))
(use-package tramp-rpc
:ensure (tramp-rpc :host github :repo "ArthurHeymans/emacs-tramp-rpc")
:straight (tramp-rpc :host github :repo "ArthurHeymans/emacs-tramp-rpc")
:config
(tramp-rpc-magit-enable)
(tramp-rpc-projectile-enable))