From 59b98b00faa2de4d8750f566eb8e5f6eed74a55b Mon Sep 17 00:00:00 2001 From: trogloxene Date: Tue, 31 Mar 2026 08:11:34 +0800 Subject: [PATCH] Fix: Fix issue where script only modified source files but Emacs loads from build directory --- lisp/fix-theme-colors.el | 45 ++++++++++++++++++++++++++++++---------- lisp/init-org.el | 5 ++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lisp/fix-theme-colors.el b/lisp/fix-theme-colors.el index 560d027..2304917 100644 --- a/lisp/fix-theme-colors.el +++ b/lisp/fix-theme-colors.el @@ -1,6 +1,7 @@ #!/usr/bin/env emacs --script ;;; fix-theme-colors.el --- Fix invalid color names and properties in Emacs themes +;; This scipt is AI generated. ;; This script fixes common issues in color-theme files: ;; 1. Space-separated color names (e.g., "deep sky blue" -> "DeepSkyBlue") ;; 2. Invalid color names (e.g., "PaleYellow" -> "LightYellow") @@ -114,6 +115,11 @@ (":line-width -1" . ":line-width 1")) "Fixes for invalid :box properties.") +(defvar theme-fixes-box-family + '((":family \"helv\"" . "") + (":family \"outline-lucida console\"" . "")) + "Remove invalid :family property inside :box.") + (defun fix-theme-file (filepath) "Fix all issues in a single theme file." (message "Processing: %s" filepath) @@ -158,12 +164,15 @@ (setq changes (1+ changes))))) ;; Fix :family inside :box (invalid property) - (when (string-match ":box (\\([^)]+\\):family \"[^\"]+\"\\([^)]*\\))" content) - (setq content (replace-regexp-in-string - ":box (\\([^)]+\\):family \"[^\"]+\"\\([^)]*\\))" - ":box (\\1\\2)" - content)) - (setq changes (1+ changes))) + (dolist (fix theme-fixes-box-family) + (let ((old-prop (car fix)) + (new-prop (cdr fix))) + (when (string-match (regexp-quote old-prop) content) + (setq content (replace-regexp-in-string + (regexp-quote old-prop) + new-prop + content)) + (setq changes (1+ changes))))) (with-temp-file filepath (insert content)) @@ -195,13 +204,27 @@ This function can be called interactively or from Lisp." (let* ((themes-dir (expand-file-name "~/.emacs.d/straight/repos/replace-colorthemes/")) (build-dir (expand-file-name "~/.emacs.d/straight/build/color-theme-modern/"))) + (message "=== Fixing theme files ===\n") + + ;; Fix source files (if (file-directory-p themes-dir) (progn - (fix-all-themes themes-dir) - (when (file-directory-p build-dir) - (remove-compiled-themes build-dir)) - (message "\nDone! Restart Emacs to load fixed themes.")) - (error "Themes directory not found: %s" themes-dir)))) + (message "Processing source files in: %s" themes-dir) + (fix-all-themes themes-dir)) + (message "WARNING: Source themes directory not found: %s" themes-dir)) + + (message "\n") + + ;; Fix build files (these are what Emacs actually loads) + (if (file-directory-p build-dir) + (progn + (message "Processing build files in: %s" build-dir) + (fix-all-themes build-dir) + (remove-compiled-themes build-dir)) + (message "WARNING: Build themes directory not found: %s" build-dir)) + + (message "\n=== Done! ===") + (message "Restart Emacs to load fixed themes."))) ;; When run as a script (--script), execute the function (when noninteractive diff --git a/lisp/init-org.el b/lisp/init-org.el index f5678e0..8c27a87 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -155,9 +155,8 @@ (when *is-windows* (with-eval-after-load 'org - (setq org-agenda-files '("d:/emacs/org/learning-oprg-mode.org" - "d:/emacs/hugo/this-is-my-blog/all-blog.org" - "d:/emacs/my-org-daily/")))) ; agenda文件,目录或文件 + (setq org-agenda-files '("d:/emacs/hugo/this-is-my-blog/all-blog.org" + "d:/emacs/my-org-daily/")))) (when *is-mac* (with-eval-after-load 'org (setq org-agenda-files '("~/org/my-org-daily"))))