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
|
#!/usr/bin/env emacs --script
|
||||||
;;; fix-theme-colors.el --- Fix invalid color names and properties in Emacs themes
|
;;; 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:
|
;; This script fixes common issues in color-theme files:
|
||||||
;; 1. Space-separated color names (e.g., "deep sky blue" -> "DeepSkyBlue")
|
;; 1. Space-separated color names (e.g., "deep sky blue" -> "DeepSkyBlue")
|
||||||
;; 2. Invalid color names (e.g., "PaleYellow" -> "LightYellow")
|
;; 2. Invalid color names (e.g., "PaleYellow" -> "LightYellow")
|
||||||
@@ -114,6 +115,11 @@
|
|||||||
(":line-width -1" . ":line-width 1"))
|
(":line-width -1" . ":line-width 1"))
|
||||||
"Fixes for invalid :box properties.")
|
"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)
|
(defun fix-theme-file (filepath)
|
||||||
"Fix all issues in a single theme file."
|
"Fix all issues in a single theme file."
|
||||||
(message "Processing: %s" filepath)
|
(message "Processing: %s" filepath)
|
||||||
@@ -158,12 +164,15 @@
|
|||||||
(setq changes (1+ changes)))))
|
(setq changes (1+ changes)))))
|
||||||
|
|
||||||
;; Fix :family inside :box (invalid property)
|
;; Fix :family inside :box (invalid property)
|
||||||
(when (string-match ":box (\\([^)]+\\):family \"[^\"]+\"\\([^)]*\\))" content)
|
(dolist (fix theme-fixes-box-family)
|
||||||
(setq content (replace-regexp-in-string
|
(let ((old-prop (car fix))
|
||||||
":box (\\([^)]+\\):family \"[^\"]+\"\\([^)]*\\))"
|
(new-prop (cdr fix)))
|
||||||
":box (\\1\\2)"
|
(when (string-match (regexp-quote old-prop) content)
|
||||||
content))
|
(setq content (replace-regexp-in-string
|
||||||
(setq changes (1+ changes)))
|
(regexp-quote old-prop)
|
||||||
|
new-prop
|
||||||
|
content))
|
||||||
|
(setq changes (1+ changes)))))
|
||||||
|
|
||||||
(with-temp-file filepath
|
(with-temp-file filepath
|
||||||
(insert content))
|
(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/"))
|
(let* ((themes-dir (expand-file-name "~/.emacs.d/straight/repos/replace-colorthemes/"))
|
||||||
(build-dir (expand-file-name "~/.emacs.d/straight/build/color-theme-modern/")))
|
(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)
|
(if (file-directory-p themes-dir)
|
||||||
(progn
|
(progn
|
||||||
(fix-all-themes themes-dir)
|
(message "Processing source files in: %s" themes-dir)
|
||||||
(when (file-directory-p build-dir)
|
(fix-all-themes themes-dir))
|
||||||
(remove-compiled-themes build-dir))
|
(message "WARNING: Source themes directory not found: %s" themes-dir))
|
||||||
(message "\nDone! Restart Emacs to load fixed themes."))
|
|
||||||
(error "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 run as a script (--script), execute the function
|
||||||
(when noninteractive
|
(when noninteractive
|
||||||
|
|||||||
@@ -155,9 +155,8 @@
|
|||||||
|
|
||||||
(when *is-windows*
|
(when *is-windows*
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(setq org-agenda-files '("d:/emacs/org/learning-oprg-mode.org"
|
(setq org-agenda-files '("d:/emacs/hugo/this-is-my-blog/all-blog.org"
|
||||||
"d:/emacs/hugo/this-is-my-blog/all-blog.org"
|
"d:/emacs/my-org-daily/"))))
|
||||||
"d:/emacs/my-org-daily/")))) ; agenda文件,目录或文件
|
|
||||||
(when *is-mac*
|
(when *is-mac*
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(setq org-agenda-files '("~/org/my-org-daily"))))
|
(setq org-agenda-files '("~/org/my-org-daily"))))
|
||||||
|
|||||||
Reference in New Issue
Block a user