Created
March 14, 2012 11:40
-
-
Save condotti/2035942 to your computer and use it in GitHub Desktop.
color-themeをemacs24のthemeに変換するモノ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(load-library "cl-extra") | |
(defun my-get-face-attributes (face) | |
(reverse | |
(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)) | |
(erase-buffer) | |
(emacs-lisp-mode) | |
(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