Refactor solarized-definitions.el for customization
* add macro solarized-with-color-variables * pull solarized-apply-definitions out of create-solarized-theme This makes it easier to customize and test proposed changes to solarized-color-definitions. solarized-with-color-variables allows definition of faces within the same context that is used for solarized-color-definitions. Hence, the changes you test yourself can be directly copied into the official code-base for a PR. They are also easy to maintain in your own Emacs init scripts before merge or if tweaking the official settings. The approach is copied from @bbatsov's themes. For example, setting up additions/customizations goes like this: (defvar my/solarized-extra-definitions (solarized-with-color-variables `(;; cperl (cperl-array-face (,@fg-blue)) (cperl-hash-face (,@fg-blue)) (cperl-nonoverridable-face (,@fg-magenta))))) (solarized-apply-definitions my/solarized-extra-definitions 'solarized)
This commit is contained in:
parent
797229d0d3
commit
a8a1fb0e34
|
@ -157,8 +157,10 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further."
|
|||
(((background light) (type tty) (min-colors 8))
|
||||
,(solarized-face-for-index facespec 5 t)))))
|
||||
|
||||
(defun solarized-color-definitions ()
|
||||
(let ((bold (if solarized-bold 'bold 'unspecified))
|
||||
(defmacro solarized-with-color-variables (&rest body)
|
||||
"`let' bind all colors available for use in `solarized' around BODY."
|
||||
(declare (indent 0))
|
||||
`(let ((bold (if solarized-bold 'bold 'unspecified))
|
||||
(bright-bold (if solarized-bold 'unspecified 'bold))
|
||||
(underline (if solarized-underline t 'unspecified))
|
||||
(opt-under 'unspecified)
|
||||
|
@ -224,9 +226,19 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further."
|
|||
(fmt-revb `(:weight ,bold :inverse-video t))
|
||||
(fmt-revbb `(:weight ,bright-bold :inverse-video t))
|
||||
(fmt-revbbu `(:weight ,bright-bold :underline ,underline :inverse-video t)))
|
||||
,@body)))
|
||||
|
||||
(defun solarized-apply-definitions (definitions theme)
|
||||
"Apply face DEFINITIONS to THEME."
|
||||
(apply 'custom-theme-set-faces
|
||||
theme
|
||||
(mapcar (lambda (face) (apply 'create-face-spec face))
|
||||
definitions)))
|
||||
|
||||
(defun solarized-color-definitions ()
|
||||
(solarized-with-color-variables
|
||||
(eval-after-load 'ansi-color
|
||||
'(setf ansi-color-names-vector [,base02 ,red ,green ,yellow ,blue ,magenta ,cyan ,base00]))
|
||||
(mapcar (lambda (face) (apply 'create-face-spec face))
|
||||
`(;; basic
|
||||
(default (,@fg-base0 ,@bg-back)) ; Normal
|
||||
(cursor (,@fg-base03 ,@bg-base0)) ; Cursor
|
||||
|
@ -777,7 +789,7 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further."
|
|||
(undo-tree-visualizer-unmodified-face (,@fg-cyan))
|
||||
(undo-tree-visualizer-register-face (,@fg-yellow))
|
||||
;; haskell
|
||||
(haskell-keyword-face (,@fg-cyan)))))))
|
||||
(haskell-keyword-face (,@fg-cyan)))))
|
||||
|
||||
;;;###autoload
|
||||
(when (boundp 'custom-theme-load-path)
|
||||
|
@ -787,8 +799,7 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further."
|
|||
(defmacro create-solarized-theme (name description color-definitions)
|
||||
`(progn
|
||||
(deftheme ,name ,description)
|
||||
(apply 'custom-theme-set-faces
|
||||
',name ,color-definitions)
|
||||
(solarized-apply-definitions ,color-definitions ',name)
|
||||
(provide-theme ',name)))
|
||||
|
||||
(provide 'solarized-definitions)
|
||||
|
|
Loading…
Reference in New Issue