Created
May 2, 2015 09:09
-
-
Save hgiddens/bda91ac3b4c598db50fa to your computer and use it in GitHub Desktop.
Solarized Emacs stuff That Works On My Machine (TM)
This file contains hidden or 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
| ;;; Solarized configuration is a total clusterfuck, but on the other hand | |
| ;;; I've somehow got the bastard playing nicely with NS frames, TTY frames, | |
| ;;; and both NS /and/ TTY clients of both. | |
| ;;; | |
| ;;; - solarized-broken-srgb is always false as we're using the new sRGB in master. | |
| ;;; - solarized-assume-solarized-terminal is also set to t. This is a new customisation | |
| ;;; variable I introduced that tells Solarized to use the window system RGB codes for | |
| ;;; terminal faces, assuming that they'll be mapped to the correct Solarized colours. | |
| ;;; This should be trivial to hack into solarized-color-definitions, when index is set change | |
| ;;; (cond window-system ... | |
| ;;; to | |
| ;;; (cond (or window-system solarized-assume-solarized-terminal) ... | |
| ;;; Note I'm using a fork from and old version of emacs-color-theme-solarized so maybe there's | |
| ;;; something like this built in now? | |
| ;;; | |
| ;;; We load the definitions so we have the Solarized colours in scope. | |
| ;;; We eagerly initialise NS windowing, having first advised it so that it's safe to | |
| ;;; call multiple times. This is required to be able to call xw-color-values. | |
| ;;; We set xterm-standard-colors based on the sRGB Solarized colours (second column). | |
| ;;; We only force refresh the colours if we already have a TTY frame, though (the file | |
| ;;; containing xterm-register-default-colors is lazy loaded). | |
| ;;; We eagerly load both themes to avoid the “loading themes runs code” warning (also, | |
| ;;; enable-theme has better interactive completion than load-theme). | |
| ;;; Don't enable the theme until after init so we don't get asked questions while | |
| ;;; the face is lime on light blue. | |
| (let ((theme-root "~/Source/oss/emacs-color-theme-solarized")) | |
| (when (file-directory-p theme-root) | |
| (add-to-list 'custom-theme-load-path theme-root) | |
| (setf solarized-broken-srgb nil | |
| solarized-assume-solarized-terminal t) | |
| (require 'solarized-definitions (expand-file-name "solarized-definitions.el" theme-root)) | |
| (defadvice ns-initialize-window-system (around make-ns-initialize-window-system-repeatable activate) | |
| (unless ns-initialized | |
| ad-do-it)) | |
| (ns-initialize-window-system) | |
| (cl-labels ((find-solarized-term-colour (colour) | |
| (cl-second (cl-find colour solarized-colors :key #'cl-fifth :test #'equal))) | |
| (parse-terminal-colour (colour) | |
| (mapcar (lambda (channel) | |
| (round (/ channel 256.0))) | |
| (xw-color-values colour)))) | |
| (setq xterm-standard-colors | |
| (cl-loop for color in '("black" "red" "green" "yellow" "blue" "magenta" "cyan" "white") | |
| for color-num from 0 | |
| as color-value = (find-solarized-term-colour color) | |
| as bright-color = (concat "bright" color) | |
| as bright-color-num = (+ color-num 8) | |
| as bright-color-value = (find-solarized-term-colour bright-color) | |
| collect (list color color-num (parse-terminal-colour color-value)) into colours | |
| collect (list bright-color bright-color-num (parse-terminal-colour bright-color-value)) into colours | |
| finally return (cl-sort colours #'< :key #'cl-second))) | |
| (when (fboundp 'xterm-register-default-colors) | |
| ;; xterm doesn't provide anything so we can't use `eval-after-load'. | |
| (xterm-register-default-colors))) | |
| (load-theme 'solarized-dark t t) | |
| (load-theme 'solarized-light t t) | |
| (add-hook 'after-init-hook (lambda () (enable-theme 'solarized-light)) t) | |
| (global-set-key [f1] (lambda () | |
| (interactive) | |
| (cond | |
| ((memq 'solarized-light custom-enabled-themes) | |
| (disable-theme 'solarized-light) | |
| (enable-theme 'solarized-dark)) | |
| ((memq 'solarized-dark custom-enabled-themes) | |
| (disable-theme 'solarized-dark) | |
| (enable-theme 'solarized-light)) | |
| (:otherwise (message "No solarized theme enabled."))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment