2025-12-14 04:51:24 +11:00
|
|
|
;; -*- lexical-binding: t -*-
|
2025-12-14 21:09:42 +11:00
|
|
|
|
2026-04-02 13:27:43 +11:00
|
|
|
(use-package benchmark-init :demand t
|
2026-04-03 15:54:22 +11:00
|
|
|
:hook (elpaca-after-init . benchmark-init/deactivate))
|
2026-03-30 11:49:18 +11:00
|
|
|
|
2026-03-29 19:12:45 +11:00
|
|
|
;; 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)
|
|
|
|
|
|
2026-01-15 01:07:26 +11:00
|
|
|
(when (memq window-system '(mac ns x))
|
|
|
|
|
(use-package exec-path-from-shell
|
2026-03-30 11:49:18 +11:00
|
|
|
:commands exec-path-from-shell-initialize
|
2026-01-15 01:07:26 +11:00
|
|
|
:init
|
2026-03-30 11:49:18 +11:00
|
|
|
(setq exec-path-from-shell-arguments '("-l"))
|
2026-01-15 01:07:26 +11:00
|
|
|
(exec-path-from-shell-initialize)))
|
2025-12-22 13:34:38 +11:00
|
|
|
|
2025-12-17 07:08:46 +11:00
|
|
|
(setq custom-file (expand-file-name "~/.emacs.d/custom.el"))
|
2026-04-03 22:48:09 +11:00
|
|
|
(add-hook 'elpaca-after-init-hook (lambda () (load custom-file 'no-error 'no-message)))
|
2025-12-17 07:08:46 +11:00
|
|
|
|
2026-03-30 11:49:18 +11:00
|
|
|
;; Start server
|
2025-12-20 15:13:13 +11:00
|
|
|
(use-package server
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2026-03-30 11:49:18 +11:00
|
|
|
:hook (emacs-startup . (lambda ()
|
|
|
|
|
(unless server-mode
|
|
|
|
|
(server-mode 1)))))
|
|
|
|
|
|
|
|
|
|
;; Save place
|
|
|
|
|
(use-package saveplace
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2026-04-03 22:48:09 +11:00
|
|
|
:hook (elpaca-after-init . save-place-mode))
|
2025-12-20 15:13:13 +11:00
|
|
|
|
|
|
|
|
(use-package display-line-numbers
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2026-02-05 21:48:27 +11:00
|
|
|
:hook (text-mode . display-line-numbers-mode)
|
|
|
|
|
:hook (prog-mode . display-line-numbers-mode)
|
2025-12-20 15:13:13 +11:00
|
|
|
:config
|
|
|
|
|
(dolist (mode '(erc-mode-hook
|
|
|
|
|
circe-mode-hook
|
|
|
|
|
help-mode-hook
|
|
|
|
|
gud-mode-hook
|
2026-03-24 22:02:04 +11:00
|
|
|
treemacs-mode-hook
|
2026-02-21 08:47:38 +11:00
|
|
|
org-mode-hook
|
2025-12-20 15:13:13 +11:00
|
|
|
vterm-mode-hook))
|
|
|
|
|
(add-hook mode (lambda () (display-line-numbers-mode -1))))
|
|
|
|
|
(setq display-line-numbers-type 'relative)
|
|
|
|
|
)
|
2026-04-02 19:21:30 +11:00
|
|
|
|
2026-04-03 00:22:19 +11:00
|
|
|
;; (use-package del-trailing-white
|
|
|
|
|
;; :ensure nil
|
|
|
|
|
;; :hook ((prog-mode markdown-mode conf-mode) . enable-trailing-whitespace)
|
|
|
|
|
;; :init
|
|
|
|
|
;; (setq-default show-trailing-whitespace nil)
|
|
|
|
|
;; (defun enable-trailing-whitespace ()
|
|
|
|
|
;; "Show trailing spaces and delete on saving."
|
|
|
|
|
;; (setq show-trailing-whitespace t)
|
|
|
|
|
;; (add-hook 'before-save-hook #'delete-trailing-whitespace nil t))
|
|
|
|
|
;; )
|
2026-03-22 20:26:17 +11:00
|
|
|
|
2025-12-20 15:13:13 +11:00
|
|
|
(use-package subword
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2025-12-22 12:30:25 +11:00
|
|
|
:diminish
|
|
|
|
|
:hook (prog-mode minibuffer-setup))
|
2025-12-20 15:13:13 +11:00
|
|
|
|
|
|
|
|
(use-package paren
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2026-04-03 22:48:09 +11:00
|
|
|
:hook (elpaca-after-init . show-paren-mode))
|
2025-12-17 07:08:46 +11:00
|
|
|
|
2026-03-30 11:49:18 +11:00
|
|
|
;; ;; Show trailing whitespace only in prog-mode and text-mode
|
|
|
|
|
;; (add-hook 'prog-mode-hook (lambda () (setq show-trailing-whitespace t)))
|
|
|
|
|
;; (add-hook 'text-mode-hook (lambda () (setq show-trailing-whitespace t)))
|
2026-02-28 01:41:45 +11:00
|
|
|
|
2025-12-20 15:13:13 +11:00
|
|
|
(use-package recentf
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
|
|
|
|
:hook (elpaca-after-init . recentf-mode)
|
2026-03-30 11:49:18 +11:00
|
|
|
:init
|
|
|
|
|
(setq recentf-max-saved-items 500
|
|
|
|
|
recentf-exclude
|
|
|
|
|
'("\\.?cache" ".cask" "url" "COMMIT_EDITMSG\\'" "bookmarks"
|
|
|
|
|
"\\.\\(?:gz\\|gif\\|svg\\|png\\|jpe?g\\|bmp\\|xpm\\)$"
|
|
|
|
|
"\\.?ido\\.last$" "\\.revive$" "/G?TAGS$" "/.elfeed/"
|
2026-04-05 21:31:02 +10:00
|
|
|
"^/tmp/" "^/var/folders/.+$" "^/ssh:" "^/rpc:" "/persp-confs/"
|
|
|
|
|
"^/sshx:" "^/sudo:"
|
2026-04-02 13:27:43 +11:00
|
|
|
(lambda (file) (file-in-directory-p file package-user-dir)))
|
|
|
|
|
recentf-auto-cleanup 'never)
|
2026-03-22 23:57:48 +11:00
|
|
|
:config
|
|
|
|
|
(push (expand-file-name recentf-save-file) recentf-exclude)
|
2026-04-02 13:27:43 +11:00
|
|
|
(add-to-list 'recentf-filename-handlers #'abbreviate-file-name))
|
2026-03-22 23:57:48 +11:00
|
|
|
|
|
|
|
|
(use-package savehist
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure nil
|
2026-04-03 22:48:09 +11:00
|
|
|
:hook (elpaca-after-init . savehist-mode)
|
2026-03-22 23:57:48 +11:00
|
|
|
:init (setq enable-recursive-minibuffers t ; Allow commands in minibuffers
|
|
|
|
|
history-length 1000
|
|
|
|
|
savehist-additional-variables '(mark-ring
|
|
|
|
|
global-mark-ring
|
|
|
|
|
search-ring
|
|
|
|
|
regexp-search-ring
|
|
|
|
|
extended-command-history)
|
|
|
|
|
savehist-autosave-interval 300))
|
2025-12-17 07:08:46 +11:00
|
|
|
|
|
|
|
|
(setq-default cursor-type 'bar)
|
2026-03-30 11:49:18 +11:00
|
|
|
(setq kill-whole-line t)
|
2025-12-14 04:51:24 +11:00
|
|
|
(setq make-backup-files nil)
|
2025-12-14 06:09:17 +11:00
|
|
|
(setq use-short-answers t)
|
2026-04-02 15:31:43 +11:00
|
|
|
(setq frame-title-format
|
|
|
|
|
'((:eval (if (and (boundp 'projectile-mode)
|
|
|
|
|
projectile-mode
|
|
|
|
|
(projectile-project-p))
|
|
|
|
|
(format "[%s] %s" (projectile-project-name) (buffer-name)) ;; Add project name in front when avaliable
|
|
|
|
|
"%b")))) ;; Otherwise buffer name only
|
2025-12-17 07:08:46 +11:00
|
|
|
(setq custom-safe-themes t)
|
2025-12-16 08:23:57 +11:00
|
|
|
|
2025-12-24 05:40:26 +08:00
|
|
|
(add-to-list 'default-frame-alist '(drag-internal-border . 1))
|
|
|
|
|
(add-to-list 'default-frame-alist '(internal-border-width . 5))
|
|
|
|
|
|
2025-12-22 12:44:51 +11:00
|
|
|
(pcase system-type ('darwin (setq insert-directory-program "gls")))
|
2026-02-28 01:41:45 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
(setq-default tab-width 2
|
|
|
|
|
standard-indent 2
|
|
|
|
|
compilation-scroll-output t
|
|
|
|
|
indent-tabs-mode nil)
|
2025-12-21 10:30:07 +11:00
|
|
|
|
2025-12-17 07:08:46 +11:00
|
|
|
(setq ring-bell-function 'ignore)
|
2025-12-16 08:23:57 +11:00
|
|
|
(setq undo-limit 80000000
|
|
|
|
|
password-cache-expiry nil)
|
|
|
|
|
|
2025-12-17 07:08:46 +11:00
|
|
|
(setq-default delete-by-moving-to-trash t
|
2026-03-24 22:02:04 +11:00
|
|
|
x-stretch-cursor t
|
|
|
|
|
window-combination-resize t)
|
2025-12-15 22:42:06 +11:00
|
|
|
|
2025-12-15 05:50:04 +11:00
|
|
|
(define-key global-map (kbd "C-<wheel-up>") nil)
|
|
|
|
|
(define-key global-map (kbd "C-<wheel-down>") nil)
|
|
|
|
|
(global-set-key (kbd "s-a") 'mark-whole-buffer) ;;对应Windows上面的Ctrl-a 全选
|
|
|
|
|
(global-set-key (kbd "s-c") 'kill-ring-save) ;;对应Windows上面的Ctrl-c 复制
|
|
|
|
|
(global-set-key (kbd "s-s") 'save-buffer) ;; 对应Windows上面的Ctrl-s 保存
|
|
|
|
|
(global-set-key (kbd "s-v") 'yank) ;对应Windows上面的Ctrl-v 粘贴
|
|
|
|
|
(global-set-key (kbd "s-z") 'undo) ;对应Windows上面的Ctrol-z 撤销
|
2025-12-14 22:30:26 +11:00
|
|
|
|
|
|
|
|
(setq kill-ring-max 200)
|
|
|
|
|
;; Save clipboard contents into kill-ring before replace them
|
|
|
|
|
(setq save-interprogram-paste-before-kill t)
|
2025-12-15 05:50:04 +11:00
|
|
|
|
2025-12-14 22:30:26 +11:00
|
|
|
;; Kill & Mark things easily
|
|
|
|
|
(use-package easy-kill
|
|
|
|
|
:bind (([remap kill-ring-save] . easy-kill)
|
|
|
|
|
([remap mark-sexp] . easy-mark)))
|
|
|
|
|
|
2026-03-22 23:57:48 +11:00
|
|
|
(use-package browse-kill-ring
|
|
|
|
|
:bind ("C-c k" . browse-kill-ring)
|
2026-04-03 22:48:09 +11:00
|
|
|
:hook (elpaca-after-init . browse-kill-ring-default-keybindings)
|
2026-03-22 23:57:48 +11:00
|
|
|
:init (setq browse-kill-ring-separator "────────────────"
|
|
|
|
|
browse-kill-ring-separator-face 'shadow))
|
|
|
|
|
|
2025-12-14 09:04:11 +11:00
|
|
|
(use-package ultra-scroll
|
|
|
|
|
:init
|
|
|
|
|
(setq scroll-conservatively 3
|
2026-03-24 22:02:04 +11:00
|
|
|
scroll-margin 0)
|
2026-04-03 22:48:09 +11:00
|
|
|
:hook (elpaca-after-init . ultra-scroll-mode))
|
2025-12-22 12:30:25 +11:00
|
|
|
|
|
|
|
|
(use-package helpful
|
|
|
|
|
:bind (([remap describe-function] . helpful-callable)
|
|
|
|
|
([remap describe-command] . helpful-command)
|
|
|
|
|
([remap describe-variable] . helpful-variable)
|
|
|
|
|
([remap describe-key] . helpful-key)
|
|
|
|
|
([remap describe-symbol] . helpful-symbol)
|
|
|
|
|
:map emacs-lisp-mode-map
|
|
|
|
|
("C-c C-d" . helpful-at-point)
|
|
|
|
|
:map lisp-interaction-mode-map
|
|
|
|
|
("C-c C-d" . helpful-at-point)
|
|
|
|
|
:map helpful-mode-map
|
2026-03-22 20:26:17 +11:00
|
|
|
("r" . remove-hook-at-point)
|
|
|
|
|
("q" . kill-current-buffer))
|
2025-12-22 12:30:25 +11:00
|
|
|
:hook (helpful-mode . cursor-sensor-mode) ; for remove-advice button
|
|
|
|
|
:init
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(with-eval-after-load 'apropos
|
|
|
|
|
;; patch apropos buttons to call helpful instead of help
|
|
|
|
|
(dolist (fun-bt '(apropos-function apropos-macro apropos-command))
|
|
|
|
|
(button-type-put
|
|
|
|
|
fun-bt 'action
|
|
|
|
|
(lambda (button)
|
|
|
|
|
(helpful-callable (button-get button 'apropos-symbol)))))
|
|
|
|
|
(dolist (var-bt '(apropos-variable apropos-user-option))
|
|
|
|
|
(button-type-put
|
|
|
|
|
var-bt 'action
|
|
|
|
|
(lambda (button)
|
|
|
|
|
(helpful-variable (button-get button 'apropos-symbol))))))))
|
|
|
|
|
|
2026-03-30 11:49:18 +11:00
|
|
|
(setq delete-by-moving-to-trash t
|
|
|
|
|
inhibit-compacting-font-caches t
|
|
|
|
|
make-backup-files nil)
|
|
|
|
|
|
2026-02-28 19:27:53 +11:00
|
|
|
(setq-default auto-save-default nil)
|
2026-03-29 19:12:45 +11:00
|
|
|
(setq create-lockfiles nil)
|
2026-02-22 23:29:18 +11:00
|
|
|
;; (setq auto-save-file-name-transforms
|
|
|
|
|
;; `((".*" ,(concat user-emacs-directory "auto-save/") t)))
|
2026-02-22 20:02:12 +11:00
|
|
|
|
2026-04-05 21:31:02 +10:00
|
|
|
(use-package tramp
|
|
|
|
|
:config
|
|
|
|
|
(setq tramp-default-method "rpc"))
|
2026-04-02 13:27:43 +11:00
|
|
|
|
2026-03-14 11:42:48 +11:00
|
|
|
(use-package tramp-hlo
|
2026-04-05 21:31:02 +10:00
|
|
|
:hook (elpaca-after-init . tramp-hlo-setup))
|
2026-02-25 22:12:47 +11:00
|
|
|
|
2026-04-05 21:31:02 +10:00
|
|
|
(use-package msgpack)
|
2026-03-14 11:42:48 +11:00
|
|
|
(use-package tramp-rpc
|
2026-04-02 19:21:30 +11:00
|
|
|
:ensure (tramp-rpc :host github :repo "ArthurHeymans/emacs-tramp-rpc")
|
2026-03-14 11:42:48 +11:00
|
|
|
:config
|
|
|
|
|
(tramp-rpc-magit-enable)
|
|
|
|
|
(tramp-rpc-projectile-enable))
|
2026-02-25 22:12:47 +11:00
|
|
|
|
2025-12-14 04:51:24 +11:00
|
|
|
(provide 'init-better-default)
|