Make theming sane!

This commit is contained in:
Ivan Malison 2015-08-16 14:44:25 -07:00
parent ecd2d32035
commit 420ae97e38

View File

@ -2002,88 +2002,42 @@ window is active in the perspective."
;; Themes ;; Themes
;; ============================================================================= ;; =============================================================================
(defvar-if-non-existent imalison:dark-themes '(solarized-dark)) (defvar imalison:my-theme 'material)
(defvar-if-non-existent imalison:light-themes '(solarized-light))
(defvar-if-non-existent imalison:terminal-themes '(solarized-light monokai))
(defvar-if-non-existent imalison:fonts '("Source Code Pro-14"))
(defvar imalison:fonts '("Monaco for Powerline-12"))
(unless (boundp 'current-theme) (defvar current-theme))
(setq current-theme nil)
(defun random-choice (choices) (defun random-choice (choices)
(nth (random (length choices)) choices)) (nth (random (length choices)) choices))
(defun get-appropriate-theme () (defun imalison:remove-fringe-and-hl-line-mode (&rest stuff)
(if t ;; (display-graphic-p) why doesn't this work at frame startup?
(let ((hour
(string-to-number (format-time-string "%H"))))
(if (or (< hour 8) (> hour 16))
(random-choice imalison:dark-themes) (random-choice imalison:light-themes)))
(random-choice imalison:terminal-themes)))
(defun set-theme ()
(interactive) (interactive)
(let ((appropriate-theme (get-appropriate-theme)))
(if (eq appropriate-theme current-theme)
nil
(progn
(disable-and-load-theme appropriate-theme t)
(setq current-theme appropriate-theme)))))
(defun disable-all-themes ()
(interactive)
(mapcar
(lambda (theme) (unless (s-contains? "smart-mode" (symbol-name theme))
(disable-theme theme))) custom-enabled-themes))
(defun disable-and-load-theme (theme &optional no-confirm no-enable)
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapcar 'symbol-name
(custom-available-themes))))
nil nil))
(disable-all-themes)
(load-theme theme no-confirm no-enable)
(set-my-font-for-frame nil))
(defun set-my-font-for-frame (&optional frame)
(interactive (list nil))
(condition-case exp
(set-frame-font (random-choice imalison:fonts) nil t)
('error (package-refresh-contents)
(set-frame-font "Source Code Pro-14" nil t) nil)))
(defun remove-fringe-and-hl-line-mode (&rest stuff)
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(set-fringe-mode 0) (set-fringe-mode 0)
(setq linum-format 'dynamic) (defvar-setq linum-format 'dynamic)
(setq left-margin-width 0) (setq left-margin-width 0)
(setq hl-line-mode nil) (defvar-setq hl-line-mode nil))
(set-my-font-for-frame nil))
(if (emacs24_4-p) (when t
(advice-add 'load-theme :after #'remove-fringe-and-hl-line-mode) (if (emacs24_4-p)
(defadvice load-theme (after name activate) (advice-add 'load-theme :after #'imalison:remove-fringe-and-hl-line-mode)
(remove-fringe-and-hl-line-mode))) (defadvice load-theme (after name activate)
(imalison:remove-fringe-and-hl-line-mode))))
;; This is needed because you can't set the font or theme at daemon start-up.
(add-hook 'after-make-frame-functions
(lambda (frame)
(set-theme)
(remove-fringe-and-hl-line-mode)
(set-my-font-for-frame)))
(add-to-list 'default-frame-alist
`(font . ,(random-choice imalison:fonts)))
(when (file-exists-p custom-after-file) (load custom-after-file)) (when (file-exists-p custom-after-file) (load custom-after-file))
(defvar-if-non-existent imalison:time-of-day-based-theme nil) (defun imalison:appearance (&optional frame)
;; enable to set theme based on time of day. (interactive)
(if imalison:time-of-day-based-theme (run-at-time "00:00" 3600 'set-theme)) (message "called set appearance")
(if (display-graphic-p)
(progn
(set-face-attribute 'default nil :font "Source Code Pro")
(set-face-attribute 'default nil :height 135)))
(load-theme imalison-my-theme t)
(imalison:remove-fringe-and-hl-line-mode))
;; This is needed because you can't set the font or theme at daemon start-up.
(add-hook 'after-make-frame-functions 'imalison:appearance)
;; (add-hook 'after-init-hook 'imalison:appearance)
;; Local Variables: ;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc) ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)