Fix: Fix issue where script only modified source files but Emacs loads from build directory
This commit is contained in:
@@ -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)
|
||||
(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
|
||||
":box (\\([^)]+\\):family \"[^\"]+\"\\([^)]*\\))"
|
||||
":box (\\1\\2)"
|
||||
(regexp-quote old-prop)
|
||||
new-prop
|
||||
content))
|
||||
(setq changes (1+ changes)))
|
||||
(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)
|
||||
(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 "\nDone! Restart Emacs to load fixed themes."))
|
||||
(error "Themes directory not found: %s" themes-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
|
||||
|
||||
@@ -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"))))
|
||||
|
||||
Reference in New Issue
Block a user