From a416bffb54e9c275b0521f3e988f5b588ce2b1e1 Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Thu, 2 Apr 2026 13:27:43 +1100 Subject: [PATCH] Update --- .gitignore | 1 + README.org | 3 +- early-init.el | 11 ++++++- init.el | 2 +- lisp/init-better-default.el | 27 ++++++++++++------ lisp/init-edit.el | 3 +- lisp/init-lsp.el | 3 +- lisp/init-ocaml.el | 5 ++-- lisp/init-org.el | 2 +- lisp/init-shell.el | 44 +++++++++++++++++++++++----- lisp/init-ui.el | 57 +++++++++++++++++++------------------ lisp/init-window.el | 2 +- 12 files changed, 104 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index 4c9f33c..a4f2c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ rime .yas-compiled-snippets.el flycheck_*.el tabsession.el +.lsp-session-v1 emacs.desktop history !alias diff --git a/README.org b/README.org index a775ea0..a0e2666 100644 --- a/README.org +++ b/README.org @@ -1,2 +1 @@ -* Basically there is nothing extra you need to do -run M-x my/generate-envvar-file +* Just Pull and run. Enjoy diff --git a/early-init.el b/early-init.el index bf7c794..57b6144 100644 --- a/early-init.el +++ b/early-init.el @@ -17,7 +17,7 @@ (setq use-package-enable-imenu-support t) (setq load-prefer-newer noninteractive) -(setenv "LSP_USE_PLISTS" "true") +(setenv "LSP_USE_PLISTS" "true") ;; Lsp-mode plists ;; PERF: Many elisp file API calls consult `file-name-handler-alist'. ;; Setting it to nil speeds up startup significantly. @@ -34,6 +34,15 @@ ;; Inhibit resizing frame (setq frame-inhibit-implied-resize t) +;; 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-major-mode 'fundamental-mode + initial-scratch-message nil) + ;; Faster to disable these here (before they've been initialized) (push '(menu-bar-lines . 0) default-frame-alist) (push '(tool-bar-lines . 0) default-frame-alist) diff --git a/init.el b/init.el index 077da40..aeb470a 100644 --- a/init.el +++ b/init.el @@ -52,7 +52,7 @@ (require 'init-org) (require 'init-tex) -(require 'init-markdown) +;; (require 'init-markdown) (require 'init-typst) (require 'init-cc) (require 'init-python) diff --git a/lisp/init-better-default.el b/lisp/init-better-default.el index 9af393e..223c741 100644 --- a/lisp/init-better-default.el +++ b/lisp/init-better-default.el @@ -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)) diff --git a/lisp/init-edit.el b/lisp/init-edit.el index f7b5a79..bddd6cc 100644 --- a/lisp/init-edit.el +++ b/lisp/init-edit.el @@ -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) diff --git a/lisp/init-lsp.el b/lisp/init-lsp.el index 134538f..c4a59f2 100644 --- a/lisp/init-lsp.el +++ b/lisp/init-lsp.el @@ -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) - ) diff --git a/lisp/init-ocaml.el b/lisp/init-ocaml.el index e3487db..3b32797 100644 --- a/lisp/init-ocaml.el +++ b/lisp/init-ocaml.el @@ -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) diff --git a/lisp/init-org.el b/lisp/init-org.el index ff9b67f..102d872 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -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) diff --git a/lisp/init-shell.el b/lisp/init-shell.el index 739ad23..0efcb77 100644 --- a/lisp/init-shell.el +++ b/lisp/init-shell.el @@ -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-" . eshell-toggle) + :bind ("C-" . 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 "") (kbd "C-h")))) diff --git a/lisp/init-ui.el b/lisp/init-ui.el index 1b8b320..e9c09eb 100644 --- a/lisp/init-ui.el +++ b/lisp/init-ui.el @@ -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-" . (lambda () (interactive) (doric-themes-load-random 'light))) :bind ("M-" . (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) diff --git a/lisp/init-window.el b/lisp/init-window.el index 674da7c..40eff76 100644 --- a/lisp/init-window.el +++ b/lisp/init-window.el @@ -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 "←")