From dc7c1fa3a08d12da190ce7339822be16b8145b43 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Thu, 1 Jun 2017 10:40:42 -0700 Subject: [PATCH] Remove dash dep - add backgroud flip command --- config/emacs.d/init.el | 43 +++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/config/emacs.d/init.el b/config/emacs.d/init.el index ba88c83..410a7cc 100644 --- a/config/emacs.d/init.el +++ b/config/emacs.d/init.el @@ -87,21 +87,38 @@ ;; Plugins ;; Themes -(use-package dash) -(-each - (-map - (lambda (item) - (format "~/.emacs.d/themes/%s" item)) - (-remove - (lambda (item) (or (string= item ".") (string= item ".."))) - (directory-files ".emacs.d/themes/"))) - (lambda (item) - (add-to-list 'custom-theme-load-path item))) +(defun flip-background () + "Flip the frame and terminal background mode. +useful for alternating between light and dark themes" + (interactive) + (let ((mode (if (or (eq (frame-parameter nil 'background-mode) 'dark) + (eq (terminal-parameter nil 'background-mode) 'dark)) + (setq mode 'light) + (setq mode 'dark)))) + (set-frame-parameter nil 'background-mode mode) + (set-terminal-parameter nil 'background-mode mode) + (dolist (theme custom-enabled-themes) + (enable-theme theme)))) -(load-theme 'solarized t) -(set-frame-parameter nil 'background-mode 'dark) -(enable-theme 'solarized) +(global-set-key (kbd "") 'flip-background) + +;; Load directories in the .emacs.d/themes directory to the load path +;; TODO Only add directories +(mapcar (lambda (item) + (add-to-list 'custom-theme-load-path item)) + (mapcar (lambda (item) + (format "%s/.emacs.d/themes/%s/" (getenv "HOME") item)) + (let (files '()) + (dolist (val + (directory-files (format "%s/.emacs.d/themes/" + (getenv "HOME"))) + files) + (let ((off (string-match "\\." val))) + (unless (and off (eq off 0)) + (setq files (cons val files)))))))) + +(when (load-theme 'solarized t) (flip-background)) ;; End themes