This commit is contained in:
Zelong Kuang
2026-04-02 13:27:43 +11:00
parent 3e88318f79
commit a416bffb54
12 changed files with 104 additions and 56 deletions

View File

@@ -1,10 +1,16 @@
;; -*- lexical-binding: t -*-
(use-package benchmark-init
:demand t
:config
;; To disable collection of benchmark data after init is done.
(add-hook 'emacs-startup-hook 'benchmark-init/deactivate)
(use-package benchmark-init :demand t
:hook (after-init . benchmark-init/deactivate))
(let (
;; 加载的时候临时增大`gc-cons-threshold'以加速启动速度。
(gc-cons-threshold most-positive-fixnum)
;; 清空避免加载远程文件的时候分析文件。
(file-name-handler-alist nil))
(require 'benchmark-init-modes)
(require 'benchmark-init)
(benchmark-init/activate)
)
;; Load some component of large package (org, magit etc.) before complete mount
@@ -153,11 +159,11 @@ If this is a daemon session, load them all immediately instead."
"\\.\\(?:gz\\|gif\\|svg\\|png\\|jpe?g\\|bmp\\|xpm\\)$"
"\\.?ido\\.last$" "\\.revive$" "/G?TAGS$" "/.elfeed/"
"^/tmp/" "^/var/folders/.+$" "^/ssh:" "/persp-confs/"
(lambda (file) (file-in-directory-p file package-user-dir))))
(lambda (file) (file-in-directory-p file package-user-dir)))
recentf-auto-cleanup 'never)
:config
(push (expand-file-name recentf-save-file) recentf-exclude)
(add-to-list 'recentf-filename-handlers #'abbreviate-file-name)
)
(add-to-list 'recentf-filename-handlers #'abbreviate-file-name))
(use-package savehist
:straight nil
@@ -263,6 +269,11 @@ If this is a daemon session, load them all immediately instead."
;; (setq auto-save-file-name-transforms
;; `((".*" ,(concat user-emacs-directory "auto-save/") t)))
(setq tramp-default-method "rpc")
(use-package tramp
:straight (:type built-in))
(use-package tramp-hlo
:config
(tramp-hlo-setup))

View File

@@ -6,7 +6,6 @@
(use-package smartparens
:diminish
:hook (after-init . smartparens-global-mode)
;; :hook (after-init . smartparens-global-strict-mode)
:init (sp-use-paredit-bindings)
:config
;; Autopair quotes more conservatively; if I'm next to a word/before another
@@ -59,7 +58,7 @@
(prog-mode . goto-address-prog-mode)))
(use-package multiple-cursors
:hook after-init
:hook prog-mode
:bind (("C-S-c C-S-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)

View File

@@ -178,10 +178,9 @@
(when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH)
(setcar orig-result command-from-exec-path))
(message "Using emacs-lsp-booster for %s!" orig-result)
(cons "emacs-lsp-booster" orig-result))
(append (list "emacs-lsp-booster" "--") orig-result))
orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)
)

View File

@@ -5,10 +5,9 @@
:straight t
:mode (("\\.ocamlinit\\'" . tuareg-mode))
:config
(setq tuareg-prettify-symbols-full t)
(add-hook 'tuareg-mode-hook (lambda () )))
(setq tuareg-prettify-symbols-full t))
(use-package dune)
;; (use-package dune)
(use-package opam-switch-mode
:hook (tuareg-mode . opam-switch-mode)

View File

@@ -219,7 +219,7 @@ the element after the #+HEADER: tag."
:hook (org-latex-preview-mode . org-latex-preview-center-mode)
:config
;; Higher resolution when using dvipng
(plist-put org-latex-preview-appearance-options :page-width 0.6)
(plist-put org-latex-preview-appearance-options :page-width 1.0)
;; (plist-put org-latex-preview-appearance-options :margin 1)
(plist-put org-latex-preview-appearance-options :scale 2.0)

View File

@@ -2,9 +2,37 @@
(use-package shell
:straight nil
:hook ((comint-output-filter-functions . comint-strip-ctrl-m))
:hook ((shell-mode . my/shell-mode-hook)
(comint-output-filter-functions . comint-strip-ctrl-m))
:init
(setq system-uses-terminfo nil))
(setq system-uses-terminfo nil)
(with-no-warnings
(defun my/shell-simple-send (proc command)
"Various PROC COMMANDs pre-processing before sending to shell."
(cond
;; Checking for clear command and execute it.
((string-match "^[ \t]*clear[ \t]*$" command)
(comint-send-string proc "\n")
(erase-buffer))
;; Checking for man command and execute it.
((string-match "^[ \t]*man[ \t]*" command)
(comint-send-string proc "\n")
(setq command (replace-regexp-in-string "^[ \t]*man[ \t]*" "" command))
(setq command (replace-regexp-in-string "[ \t]+$" "" command))
;;(message (format "command %s command" command))
(funcall 'man command))
;; Send other commands to the default handler.
(t (comint-simple-send proc command))))
(defun my/shell-mode-hook ()
"Shell mode customization."
(local-set-key '[up] 'comint-previous-input)
(local-set-key '[down] 'comint-next-input)
(local-set-key '[(shift tab)] 'comint-next-matching-input-from-input)
(ansi-color-for-comint-mode-on)
(setq comint-input-sender 'my/shell-simple-send))))
;; Emacs command shell
(use-package eshell
@@ -12,10 +40,13 @@
:defines eshell-prompt-function
:bind (:map eshell-mode-map
([remap recenter-top-bottom] . eshell/clear))
:config
(setq eshell-banner-message "")
(with-no-warnings
(defun eshell/clear ()
"Clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)
(eshell-send-input)))
@@ -113,11 +144,9 @@
(advice-add 'gud-filter :around #'my/advice-compilation-filter)
)
(setq eshell-banner-message "")
(use-package eat
:bind ("C-`" . eat-toggle)
:bind ("C-<escape>" . eshell-toggle)
:bind ("C-<escape>" . eat-toggle)
:bind ("C-`" . eshell-toggle)
:hook ((eshell-load . eat-eshell-mode)
(eshell-load . eat-eshell-visual-command-mode))
:straight `(eat :repo "https://codeberg.org/akib/emacs-eat"
@@ -143,7 +172,8 @@
;; Improve latency
(setq process-adaptive-read-buffering t)
(setq tramp-remote-process-environment '("TERM=xterm-256color" "TERMINFO=''" "ENV=''" "TMOUT=0" "LC_CTYPE=''" "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct="))
(with-eval-after-load 'tramp
(setq tramp-remote-process-environment '("TERM=xterm-256color" "TERMINFO=''" "ENV=''" "TMOUT=0" "LC_CTYPE=''" "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct=")))
(when (eq system-type 'darwin)
(define-key eat-semi-char-mode-map (kbd "C-h") #'eat-self-input)
(define-key eat-semi-char-mode-map (kbd "<backspace>") (kbd "C-h"))))

View File

@@ -7,22 +7,13 @@
(use-package diminish)
;; Suppress GUI features
(setq use-file-dialog nil
use-dialog-box nil
inhibit-startup-screen t
inhibit-startup-echo-area-message user-login-name
inhibit-default-init t
initial-scratch-message nil)
(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil)
(setq fast-but-imprecise-scrolling t)
(setq redisplay-skip-fontification-on-input t)
(setq frame-inhibit-implied-resize t
frame-resize-pixelwise t)
(setq frame-resize-pixelwise t)
;; 隐藏 title bar
(add-to-list 'default-frame-alist '(undecorated-round . t))
@@ -46,31 +37,41 @@
:bind ("C-<f5>" . (lambda () (interactive) (doric-themes-load-random 'light)))
:bind ("M-<f5>" . (lambda () (interactive) (doric-themes-load-random 'dark)))
:commands doric-themes-load-random
:init
(defun synchronise-theme ()
(let* ((hour (string-to-number
(substring (current-time-string) 11 13))))
(if (member hour (number-sequence 6 18))
(doric-themes-load-random 'light)
(doric-themes-load-random 'dark))))
:init
(synchronise-theme)
(run-with-timer 3600 3600 'synchronise-theme)
;; :init
;; (defun synchronise-theme ()
;; (let* ((hour (string-to-number
;; (substring (current-time-string) 11 13))))
;; (if (member hour (number-sequence 6 18))
;; (doric-themes-load-random 'light)
;; (doric-themes-load-random 'dark))))
;; (synchronise-theme)
;; (run-with-timer 3600 3600 'synchronise-theme)
)
(use-package auto-dark
:ensure t
;; :custom
;; (auto-dark-themes '((doric-beach) (leuven)))
;; (auto-dark-allow-osascript t)
;; (auto-dark-detection-method nil) ;; dangerous to be set manually
:hook
(auto-dark-dark-mode
. (lambda ()
;; something to execute when dark mode is detected
(doric-themes-load-random 'dark))
)
(auto-dark-light-mode
. (lambda ()
;; something to execute when light mode is detected
(doric-themes-load-random 'light)
))
:hook after-init)
(use-package rainbow-delimiters
:hook ((prog-mode . rainbow-delimiters-mode)
(typst-ts-mode . rainbow-delimiters-mode)
(python-ts-mode . rainbow-delimiters-mode)))
;; (use-package prism
;; :hook (prog-mode . prism-mode)
;; :hook (text-mode . prism-mode)
;; :hook (typst-ts-mode . prism-mode)
;; :hook (python-ts-mode . prism-whitespace-mode)
;; :config
;; (setq prism-parens t))
(use-package rainbow-mode
:hook text-mode
:hook prog-mode)

View File

@@ -49,7 +49,7 @@
("X" ace-delete-other-windows "delete other" :exit t)
("s" ace-swap-window "swap")
("a" ace-select-window "select" :exit t)
("m" toggle-frame-maximized "maximize" :exit t)
("m" maximize-window "maximize" :exit t)
("u" toggle-frame-fullscreen "fullscreen" :exit t))
"Resize"
(("h" shrink-window-horizontally "")