diff options
-rw-r--r-- | fussy.asd | 17 | ||||
-rw-r--r-- | fussy.el | 77 | ||||
-rw-r--r-- | fussy.lisp | 32 | ||||
-rw-r--r-- | package.lisp | 4 |
4 files changed, 130 insertions, 0 deletions
diff --git a/fussy.asd b/fussy.asd new file mode 100644 index 0000000..8c7b6fe --- /dev/null +++ b/fussy.asd @@ -0,0 +1,17 @@ +;;;; fussy.asd + +(asdf:defsystem #:fussy + :description "Describe fussy here" + :author "Your Name <your.name@example.com>" + :license "Specify license here" + :version "0.0.1" + :serial t + :depends-on (#:hyperquirks + #:bknr.datastore + #:lazybones + #:dexador + #:spinneret + #:lass + #:parenscript) + :components ((:file "package") + (:file "fussy"))) diff --git a/fussy.el b/fussy.el new file mode 100644 index 0000000..91882bc --- /dev/null +++ b/fussy.el @@ -0,0 +1,77 @@ +(require 'cl-lib) +(require 'package) + +(defun fussy-is-theme-p (pkg-entry) + (cl-search "-theme" (symbol-name (cl-first pkg-entry)) + :test 'char-equal)) + +(defun fussy-themes-packages () + (cl-remove-if-not 'fussy-is-theme-p package-archive-contents)) + +(defun fussy-screenshot-svg (filename) + "Save a screenshot of the current frame as an SVG image. +Saves to a temp file and puts the filename in the kill ring." + (let* ((tmpfile (make-temp-file "Emacs" nil ".svg")) + (data (x-export-frames nil 'svg))) + (with-temp-file tmpfile + (insert data)) + (copy-file tmpfile filename t))) + +(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)))) + failed-to-install)) + +(defun fussy-generate-all-theme-images (&rest files) + (let ((failed-to-load nil) + (failed-to-generate-image nil) + (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 ((svg-file + (concat + (getenv "HOME") "/" + (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 + (list :load-errors failed-to-load + :generation-errors failed-to-generate-image + :install-errors failed-to-install)))) + (message "FINISHED GENERATING THEME IMAGES"))) + +(add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/") t) + +(package-initialize) +(package-refresh-contents) + + + +(fussy-generate-all-theme-images + "/home/colin/projects/LearnCPP/chapter1/hello_world/hello.cpp" + "/home/colin/projects/fussy/fussy.el" + "/home/colin/projects/INACTIVE/nsa/nsa.py") diff --git a/fussy.lisp b/fussy.lisp new file mode 100644 index 0000000..9173e0a --- /dev/null +++ b/fussy.lisp @@ -0,0 +1,32 @@ +;;;; fussy.lisp + +(in-package #:fussy) + +(defvar +default-emacs-package-archive+ + "https://melpa.org/packages/archive-contents") + +(defun emacs-reader-readtable () + (let ((*readtable* (copy-readtable nil))) + (labels ((bracket-reader (stream char) + (declare (ignorable char)) + (read-delimited-list #\] stream))) + (set-macro-character #\[ #'bracket-reader) + (set-macro-character #\] (get-macro-character #\) nil)) + *readtable*))) + + +(defun fetch-emacs-archive (&optional (archive +default-emacs-package-archive+)) + (multiple-value-bind (stream status) (dexador:get archive :want-stream t) + (when (= 200 status) + (let ((*readtable* (emacs-reader-readtable))) + (read stream))))) + +(defun package-name-mentions (str) + (lambda (package) + (when (consp package) + (let ((string-name + (symbol-name (first package)))) + (search str string-name :test #'char-equal))))) + +(defun find-themes (archive-contents) + (remove-if-not (package-name-mentions "-theme") archive-contents)) diff --git a/package.lisp b/package.lisp new file mode 100644 index 0000000..e90672d --- /dev/null +++ b/package.lisp @@ -0,0 +1,4 @@ +;;;; package.lisp + +(defpackage #:fussy + (:use #:cl)) |