From cc0c8c43f24fb2b0d92fb279118b424353189808 Mon Sep 17 00:00:00 2001 From: dantezy Date: Mon, 19 Jan 2026 15:25:36 +0800 Subject: [PATCH 1/5] Refactor for emacs 30 Signed-off-by: dantezy --- init.el | 10 ++++++++++ rc/basic.el | 22 ++++++++-------------- rc/rc-lsp.el | 4 ++-- rc/rc-org.el | 6 +++++- rc/rc-python.el | 45 +++++++++------------------------------------ 5 files changed, 34 insertions(+), 53 deletions(-) diff --git a/init.el b/init.el index 3da1f9a..c100a66 100644 --- a/init.el +++ b/init.el @@ -26,6 +26,16 @@ (package-initialize) +;; Ensure use-package is installed (required for Emacs 30+) +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +;; Configure use-package +(eval-when-compile + (require 'use-package)) +(setq use-package-always-ensure t) ; Make :ensure t default + ;; load config (add-to-list 'load-path "~/.emacs.d/rc") (require 'basic) diff --git a/rc/basic.el b/rc/basic.el index 9a1c223..b8c8bb7 100644 --- a/rc/basic.el +++ b/rc/basic.el @@ -1,5 +1,4 @@ -; Linum and auto pair -(display-line-numbers-mode) +; Auto pair (electric-pair-mode t) (require 'use-package) @@ -25,18 +24,14 @@ (add-hook 'prog-mode-hook #'whitespace-mode) (electric-indent-mode -1) -;; autocomplete -;; auto complete -(use-package auto-complete - :ensure t) -(setq ac-ignore-case nil) -(add-hook 'emacs-lisp-mode-hook (lambda () - (auto-complete-mode t) - (setq ac-sources (append ac-sources '(ac-source-functions))))) +;; Company for auto-completion (modern replacement for auto-complete) (use-package company :ensure t - :init (add-hook 'after-init-hook 'global-company-mode)) -(ac-config-default) + :init + (add-hook 'after-init-hook 'global-company-mode) + :config + (setq company-idle-delay 0.5 + company-minimum-prefix-length 2)) (set-language-environment "UTF-8") @@ -80,8 +75,7 @@ :ensure t) (xclip-mode 1) -;; trim space -(add-hook 'write-file-hooks 'delete-trailing-whitespace nil t) +;; trim space (already handled by before-save-hook above, but keep for compatibility) ;; rss (use-package elfeed diff --git a/rc/rc-lsp.el b/rc/rc-lsp.el index fa83555..9c3bef3 100644 --- a/rc/rc-lsp.el +++ b/rc/rc-lsp.el @@ -6,8 +6,8 @@ (use-package lsp-mode :ensure t :init - ;; Set the prefix key for LSP commands - (setq lsp-keymap-prefix "C-c l") + ;; Set the prefix key for LSP commands (C-c L to avoid conflict with org-store-link) + (setq lsp-keymap-prefix "C-c L") ;; Performance optimizations (setq lsp-idle-delay 0.5) (setq lsp-log-io nil) diff --git a/rc/rc-org.el b/rc/rc-org.el index 57d3b72..4762d1d 100644 --- a/rc/rc-org.el +++ b/rc/rc-org.el @@ -94,7 +94,11 @@ (let ((done (or (not org-state) ;; nil when no TODO list (member org-state org-done-keywords))) (file (buffer-file-name)) - (agenda (funcall (ad-get-orig-definition 'org-agenda-files)) )) + ;; Get original org-agenda-files without advice + (agenda (progn + (advice-remove 'org-agenda-files 'dynamic-agenda-files-advice) + (prog1 (org-agenda-files) + (advice-add 'org-agenda-files :filter-return #'dynamic-agenda-files-advice))))) (unless (member file agenda) (if done (save-excursion diff --git a/rc/rc-python.el b/rc/rc-python.el index 43d87e5..8667989 100644 --- a/rc/rc-python.el +++ b/rc/rc-python.el @@ -28,56 +28,29 @@ ;; Python mode (built-in, no :ensure needed) (use-package python :mode (("\\.py\\'" . python-mode)) - :init - ;; Ensure global font-lock is enabled - (global-font-lock-mode 1) - :config - (setq python-indent-offset 4) - (setq python-indent-guess-indent-offset t) - ;; Ensure font-lock is enabled for Python - (setq font-lock-maximum-decoration t) - ;; Code navigation: M-. (forward) and M-, (backward) - ;; xref is built-in and works with LSP + :custom + (python-indent-offset 4) + (python-indent-guess-indent-offset t) :bind (:map python-mode-map ("M-." . xref-find-definitions) ("M-," . xref-pop-marker-stack) - ("C-c M-." . xref-find-references)) - :hook - ;; Ensure syntax highlighting is enabled - (python-mode . (lambda () - ;; Enable font-lock (syntax highlighting) - (font-lock-mode 1) - (jit-lock-mode 1) - ;; Force fontification of the entire buffer - (font-lock-ensure) - ;; Set font-lock level to maximum for better highlighting - (setq font-lock-maximum-decoration t) - ;; Ensure syntax table is set - (syntax-ppss-flush-cache 0)))) + ("C-c M-." . xref-find-references))) ;; LSP for Python ;; Add Python hook to lsp-mode (configured in rc-lsp.el) (use-package lsp-mode :ensure t :after (python rc-lsp) - :hook (python-mode . (lambda () - ;; Start LSP - (lsp-deferred) - ;; Ensure xref uses LSP backend (lsp-mode should add this automatically, - ;; but we ensure it's there) - (when (boundp 'xref-backend-functions) - (add-to-list 'xref-backend-functions 'lsp-xref-backend t)))) - :config + :hook (python-mode . lsp-deferred) + :custom ;; Configure LSP server (pylsp is recommended) ;; Install: pip install python-lsp-server[all] - (setq lsp-pylsp-server-command '("pylsp")) + (lsp-pylsp-server-command '("pylsp")) ;; Alternative: pyright ;; Install: npm install -g pyright - ;; (setq lsp-python-ms-executable "pyright-langserver") - ;; (setq lsp-python-ms-extra-paths '()) - ;; Ensure xref backend is registered globally - (add-to-list 'xref-backend-functions 'lsp-xref-backend t) + ;; (lsp-python-ms-executable "pyright-langserver") + ;; (lsp-python-ms-extra-paths '()) ) ;; Code folding using hideshow (built-in, no :ensure needed) From 52dd1eb1297e564286fc5eac6dcacd7d42b09301 Mon Sep 17 00:00:00 2001 From: dantezy Date: Mon, 19 Jan 2026 15:50:25 +0800 Subject: [PATCH 2/5] Add project-search Signed-off-by: dantezy --- rc/rc-file-management.el | 27 ++++++++++++++++++++++++++- rc/rc-python.el | 27 ++++----------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/rc/rc-file-management.el b/rc/rc-file-management.el index e9f22e8..0d21cfe 100644 --- a/rc/rc-file-management.el +++ b/rc/rc-file-management.el @@ -1,4 +1,25 @@ -;;; rc-file-management.el --- +;;; rc-file-management.el --- File and project management + +(require 'use-package) + +;; Projectile - Project management (used by treemacs) +(use-package projectile + :ensure t + :config + (projectile-mode +1) + ;; Use ripgrep if available (faster than default grep) + ;; Projectile will automatically detect and use rg if installed + (when (executable-find "rg") + (setq projectile-grep-command "rg --color=never --files-with-matches")) + :bind + (:map global-map + ("C-c p s" . projectile-grep) ; Search keyword in project + ("C-c p f" . projectile-find-file) ; Find file in project + ("C-c p r" . projectile-replace) ; Replace in project + ("C-c p p" . projectile-switch-project) ; Switch project + ("C-c p d" . projectile-find-dir))) ; Find directory in project + +;; Treemacs - File tree explorer (use-package treemacs :ensure t :defer t @@ -10,10 +31,14 @@ ("C-x t C-p" . treemacs-previous-project) ("C-x t C-f" . treemacs-create-file))) +;; Treemacs integration with projectile (use-package treemacs-projectile :after (treemacs projectile) :ensure t) +;; Note: If ripgrep (rg) is installed, projectile will use it automatically +;; Install: brew install ripgrep (macOS) or apt-get install ripgrep (Linux) + (provide 'rc-file-management) ;;; diff --git a/rc/rc-python.el b/rc/rc-python.el index 8667989..f3be9a2 100644 --- a/rc/rc-python.el +++ b/rc/rc-python.el @@ -7,10 +7,10 @@ ;; C-c C-f - Toggle code folding at point ;; C-c C-s - Show all folded code ;; C-c C-h - Hide all foldable code -;; C-c p s - Search (grep) in project +;; Note: Project search is available globally (see rc-file-management.el): +;; C-c p s - Search keyword in project (uses ripgrep if available) ;; C-c p f - Find file in project ;; C-c p r - Replace in project -;; C-c s - Search with ripgrep (if installed) ;; ;; Dependencies to install: ;; 1. LSP server (choose one): @@ -85,27 +85,8 @@ ;; (setq flycheck-python-pylint-use-symbolic-id nil) ) -;; Project-wide search using projectile -;; Projectile is already referenced in rc-file-management.el -(use-package projectile - :ensure t - :after python - :config - (projectile-mode +1) - :bind - (:map python-mode-map - ("C-c p s" . projectile-grep) - ("C-c p f" . projectile-find-file) - ("C-c p r" . projectile-replace))) - -;; Alternative: ripgrep for faster search -;; Install: brew install ripgrep (macOS) or apt-get install ripgrep (Linux) -(use-package ripgrep - :ensure t - :after python - :bind - (:map python-mode-map - ("C-c s" . ripgrep-regexp))) +;; Note: Project-wide search is configured globally in rc-file-management.el +;; Use C-c p s for projectile-grep or C-c s for ripgrep-regexp ;; Company for auto-completion (already installed, but configure for Python) (use-package company From 603c6fcd0795e0d4d28bc6931a4f09c4e63c04f6 Mon Sep 17 00:00:00 2001 From: dantezy Date: Mon, 19 Jan 2026 20:41:11 +0800 Subject: [PATCH 3/5] Update init.el to use user-emacs-directory for load-path and custom file management - Changed load-path to use expand-file-name for better portability. - Updated custom-file path to use user-emacs-directory and added conditional loading if the file exists. --- init.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index c100a66..43b010e 100644 --- a/init.el +++ b/init.el @@ -37,7 +37,7 @@ (setq use-package-always-ensure t) ; Make :ensure t default ;; load config -(add-to-list 'load-path "~/.emacs.d/rc") +(add-to-list 'load-path (expand-file-name "rc" user-emacs-directory)) (require 'basic) (require 'rc-basic) (require 'rc-c) @@ -48,5 +48,7 @@ (require 'rc-wc) (require 'rc-python) -(setq custom-file "~/.emacs.d/custom.el") -(load custom-file) +;; Set custom file and load it if it exists +(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +(when (file-exists-p custom-file) + (load custom-file t)) From 1d946073719c0b6a534db570bfea5714a93d9cd4 Mon Sep 17 00:00:00 2001 From: dantezy Date: Mon, 19 Jan 2026 21:06:52 +0800 Subject: [PATCH 4/5] Update font settings in rc-basic.el to increase size for better readability --- rc/rc-basic.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/rc-basic.el b/rc/rc-basic.el index a3e5cf3..6f5df8b 100644 --- a/rc/rc-basic.el +++ b/rc/rc-basic.el @@ -8,12 +8,12 @@ '(fullscreen . maximized)) (when window-system - (set-frame-font (font-spec :family "Noto Sans Mono" :size 12)) + (set-frame-font (font-spec :family "Noto Sans Mono" :size 18)) (dolist (script '(han cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) script - (font-spec :name "Noto Sans CJK SC" :size 12)))) + (font-spec :name "Noto Sans CJK SC" :size 18)))) (setq-default line-spacing 4) From 61cf7649af3ee914d34ea2c1f587a779735f3945 Mon Sep 17 00:00:00 2001 From: Dantezy Date: Wed, 21 Jan 2026 21:48:15 +0800 Subject: [PATCH 5/5] Update .gitignore Signed-off-by: Dantezy --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f18d18a..9b2da17 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ lspbridge/* projectile-bookmarks.eld tramp .mc-lists* +eln-cache +projects \ No newline at end of file