From 79f50376dd6c8be902392f25aaa1e7e0ff75d6b2 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 29 Mar 2023 07:50:04 -0700 Subject: Restricting installs and theme loads in fussy.el --- fussy.el | 81 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 31 deletions(-) (limited to 'fussy.el') diff --git a/fussy.el b/fussy.el index 654594d..7049ee2 100644 --- a/fussy.el +++ b/fussy.el @@ -16,7 +16,23 @@ (not (cl-member (cl-first pkg-entry) +excluded-package-names+))))) (defun fussy-themes-packages () - (cl-remove-if-not 'fussy-is-theme-p package-archive-contents)) + "Setting FUSSY-THEME-PACKAGES-TO-LOAD at the command line will +restrict the package installation step to just these +packages. This function checks that FUSSY-THEME-PACKAGES-TO-LOAD +is bound and if it is, returns it, otherwise, it filters all +theme packages from the PACKAGE-ARCHIVE-CONTENTS and returns +those." + (if (boundp 'fussy-theme-packages-to-load) + fussy-theme-packages-to-load + (cl-remove-if-not 'fussy-is-theme-p package-archive-contents))) + +(defun fussy-themes-to-exclude-from-image-generation () + "Setting FUSSY-EXCLUDED-THEMES from the command line will tell +the script not to load those themes. This function simply checks +that the variable is bound and returns its value, a list of +symbols, returning nil if not." + (when (boundp 'fussy-excluded-themes) + fussy-excluded-themes)) (defun fussy-screenshot-svg (filename) "Save a screenshot of the current frame as an SVG image to a file @@ -30,9 +46,10 @@ called filename." (defun install-all-themes () (let ((failed-to-install nil)) (cl-dolist (theme (fussy-themes-packages)) - (condition-case nil - (package-install (cl-first theme)) - (error (push (cl-first theme) failed-to-install)))) + (let ((package-name (if (symbolp theme) theme (cl-first theme)))) + (condition-case nil + (package-install package-name) + (error (push package-name failed-to-install))))) failed-to-install)) (defun locate-theme-package (theme) @@ -59,33 +76,34 @@ the theme came from." (failed-to-install (install-all-themes))) (message "All themes have been loaded") (cl-dolist (theme (custom-available-themes)) - (message (format "Generating for theme: %s" theme)) - (unwind-protect - (when (condition-case nil - (progn (load-theme theme t) - t) - (error (push theme failed-to-load) - (message "... failed to load!") - nil)) - (dolist (file files) - (let* ((theme-package - (locate-theme-package theme)) - (svg-file - (concat - (getenv "HOME") "/" - theme-package "/" - (symbol-name theme) "/" - (file-name-base file) - "." - (file-name-extension file) - ".svg"))) - (make-directory (file-name-directory svg-file) t) - (condition-case nil - (progn - (find-file file) - (delete-other-windows) - (fussy-screenshot-svg svg-file)) - (error (push (cons theme file) failed-to-generate-image))))))) + (unless (member theme (fussy-themes-to-exclude-from-image-generation)) + (message (format "Generating for theme: %s" theme)) + (unwind-protect + (when (condition-case nil + (progn (load-theme theme t) + t) + (error (push theme failed-to-load) + (message "... failed to load!") + nil)) + (dolist (file files) + (let* ((theme-package + (locate-theme-package theme)) + (svg-file + (concat + (getenv "HOME") "/" + theme-package "/" + (symbol-name theme) "/" + (file-name-base file) + "." + (file-name-extension file) + ".svg"))) + (make-directory (file-name-directory svg-file) t) + (condition-case nil + (progn + (find-file file) + (delete-other-windows) + (fussy-screenshot-svg svg-file)) + (error (push (cons theme file) failed-to-generate-image)))))))) (disable-theme theme)) (with-temp-file (concat (getenv "HOME") "/" "errors.el") (insert (prin1-to-string @@ -101,6 +119,7 @@ the theme came from." (package-initialize) (package-refresh-contents) (package-install 'compat) +(require 'compat) (toggle-frame-maximized) (fussy-generate-all-theme-images -- cgit v1.2.3