Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(load-library "cl-extra")
(defun my-get-face-attributes (face)
(mapcan '(lambda (a)
(let ((v (face-attribute face a)))
(if (not (or (eq a :inherit) (eq v 'unspecified)))
(list v a))))
(mapcar 'car face-attribute-name-alist))))
(defun my-face-attributes (face)
(let ((attributes (my-get-face-attributes face)))
(if attributes
`'(,face ((t ,attributes))))))
(defun my-make-custom-theme-set-faces (theme)
(let ((faces (remove-if 'null (mapcar 'my-face-attributes (reverse (face-list)))))
(preamble `(custom-theme-set-faces ',theme)))
(append preamble faces)))
(defun my-dump-theme (theme description)
"Converts a color theme into a theme of emacs 24 or later."
(interactive "sName of the theme: \nsDescription: ")
(let ((buffer-name (concat theme "-theme.el")))
(switch-to-buffer (get-buffer-create buffer-name))
(insert ";;; " buffer-name " --- " description "\n\n")
(insert "(deftheme " theme "\n")
(insert " \"" description "\")\n")
(cl-prettyprint (my-make-custom-theme-set-faces (intern theme)))
(insert "\n\n(provide-theme '" theme ")\n\n")
(insert ";;; " buffer-name " ends here\n")
(indent-region (point-min) (point-max))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.