Emacs: add color theme and change powerline for testing
[dotfiles.git] / emacs / emacs
index 2d5c115..1327aa0 100644 (file)
@@ -1,7 +1,371 @@
+
+(setq debug-on-error t)
+
 (scroll-bar-mode -1)
 (tool-bar-mode -1)
-(add-to-list 'default-frame-alist '(width  . 90))
+(menu-bar-mode -1)
+(add-to-list 'default-frame-alist '(width  . 120))
 (add-to-list 'default-frame-alist '(height . 40))
-(add-to-list 'default-frame-alist '(font . "Source Code Pro for Powerline-12" ))
-(load-theme 'adwaita)
+;(add-to-list 'default-frame-alist '(font . "Source Code Pro for Powerline-12:weight:light" ))
+(add-to-list 'default-frame-alist '(font . "Source Code Pro for Powerline-14" ))
+(load-theme 'tango-dark)
+
+(put 'set-goal-column 'disabled nil)
+(setq vc-follow-symlinks t)
+(setq visible-bell 1)
+(setq ring-bell-function 'ignore)
+(setq resize-mini-windows t)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;http://y.tsutsumi.io/emacs-from-scratch-part-2-package-management.html
+(require 'package)
+(add-to-list 'package-archives
+             '("melpa" . "http://melpa.milkbox.net/packages/") t)
+(package-initialize)
+
+(defvar required-packages
+  '(
+    magit
+    helm
+    ido-ubiquitous
+    yasnippet
+    evil
+    ido-vertical-mode
+    smex
+    color-theme
+    color-theme-sanityinc-tomorrow
+    key-chord
+;    powerline-evil
+    powerline
+    evil-leader
+    flx-ido
+    flx
+    auto-complete
+    fiplr
+    w3m
+    ace-jump-mode
+    el-get
+    color-identifiers-mode
+  ) "a list of packages to ensure are installed at launch.")
+
+(require 'cl)
+(defun packages-installed-p ()
+  (loop for p in required-packages
+        when (not (package-installed-p p)) do (return nil)
+        finally (return t)))
+
+(unless (packages-installed-p)
+  (message "%s" "Emacs is now refreshing its package database...")
+  (package-refresh-contents)
+  (message "%s" " done.")
+  (dolist (p required-packages)
+    (when (not (package-installed-p p))
+      (package-install p))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(setq fiplr-root-markers '(".git" ".svn" "*.DS_Store"))
+(setq fiplr-ignored-globs '((directories (".git" ".svn"))
+                            (files ("*.jpg" "*.png" "*.zip" "*~" "*.o" ".obj" "*.swp" "*.hg" ".pyc" ".*" ))))
+
+
+;(setq mac-right-option-modifier 'control)
+
+(global-set-key (kbd "C-x f") 'fiplr-find-file)
+;;;; ------------------------------------ Ido ---------------------------------------------
+(ido-mode 1)
+(ido-everywhere 1)
+(flx-ido-mode 1)
+(setq ido-use-faces nil)
+(setq ido-enable-flex-matching t)
+(require 'ido-vertical-mode)
+(setq ido-use-faces t)
+(set-face-attribute 'ido-vertical-first-match-face nil
+                   :background "#e5b7c0")
+(set-face-attribute 'ido-vertical-only-match-face nil
+                   :background "#e52b50"
+                   :foreground "white")
+(set-face-attribute 'ido-vertical-match-face nil
+                   :foreground "#b00000")
+(ido-vertical-mode 1)
+
+;; smex
+(require 'smex) 
+(global-set-key (kbd "M-x") 'smex)
+(global-set-key (kbd "M-X") 'smex-major-mode-commands)
+;;;; ----------------------------------------------------------------------------------------
+
+;;;; ---------------------------------- evil ------------------------------------------------
+(global-evil-leader-mode)
+(evil-leader/set-leader ";")
+(evil-leader/set-key "e" 'find-file)
+(evil-leader/set-key "b" 'switch-to-buffer)
+(require 'evil)
+;;Exit insert mode by pressing j and then j quickly
+;(setq key-chord-two-keys-delay 0.5)
+;(key-chord-define evil-normal-state-map "jj" 'evil-force-normal-state)
+(key-chord-define evil-visual-state-map "jj" 'evil-change-to-previous-state)
+(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
+(key-chord-define evil-replace-state-map "jj" 'evil-normal-state)
+(key-chord-mode 1)
+
+;; change mode-line color by evil state
+(lexical-let ((default-color (cons (face-background 'mode-line)
+                                  (face-foreground 'mode-line))))
+  (add-hook 'post-command-hook
+           (lambda ()
+             (let ((color (cond ((minibufferp) default-color)
+                                ((evil-insert-state-p) '("#e80000" . "#ffffff"))
+                                ((evil-emacs-state-p)  '("#444488" . "#ffffff"))
+                                ((buffer-modified-p)   '("#006fa0" . "#ffffff"))
+                                (t default-color))))
+               (set-face-background 'mode-line (car color))
+                          (set-face-foreground 'mode-line (cdr color))))))
+;(evil-mode 1)
+;;(require 'powerline-evil)
+;; TODO: enter emacs mode in eshll rather then evil mode
+;;
+;;;; ---------------------------------- evil ------------------------------------------------
+
+;;;; ------------------------------------ helm ---------------------------------------------
+;;;;;;;;;;; helm configuration https://github.com/emacs-helm/helm http://tuhdo.github.io/helm-intro.html
+;;(require 'helm-config)
+;;(global-set-key (kbd "M-x") 'helm-M-x)
+;;(helm-mode 1)
+;;(setq helm-M-x-fuzzy-match t)
+;;(global-set-key (kbd "C-x b") 'helm-mini)
+;;(setq helm-buffers-fuzzy-matching t
+;;      helm-recentf-fuzzy-match    t)
+;;(global-set-key (kbd "C-x C-f") 'helm-find-files)
+;;(when (executable-find "ack-grep")
+;;  (setq helm-grep-default-command "ack-grep -Hn --no-group --no-color %e %p %f"
+;;        helm-grep-default-recurse-command "ack-grep -H --no-group --no-color %e %p %f"))
+;;(setq helm-ff-skip-boring-files t)
+;;;(require 'helm-config)
+;;;(require 'helm-themes)
+;;;(set-face-attribute 'helm-selection nil :background "#441100")
+;;;; ----------------------------------------------------------------------------------------
+
+;; magit
+;; will get ad-handle-definition:  got redefined
+(require 'magit)
+;(setq magit-auto-revert-mode nil)
+(setq magit-last-seen-setup-instructions "1.4.0")
+
+(require 'auto-complete)
+(auto-complete-mode 1)
+
+
+;;; ---------------------------------------- el-get -----------------------------------------
+;(require 'el-get)
+;(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes")
+
+;(el-get-bundle packages/sm-package-powerline
+;  :url "https://github.com/laynor/emacs-conf.git"
+;  )
+
+
+;;; -----------------------------------------------------------------------------------------
+;(add-to-list 'load-path "~/.emacs.d/test/powerline")
+(require 'powerline)
+
+(add-hook 'emacs-lisp-mode-hook 'color-identifiers-mode)
+(global-font-lock-mode 1)
+(setq my/font-family "Source Code Pro")
+(set-frame-font my/font-family)
+(set-face-attribute 'default nil :font my/font-family :height 120)
+(set-face-font 'default my/font-family)
+
+
+
+;;;;;;;;;;;;;;;; color theme 
+(require 'color-theme)
+(defun org-src-color-blocks-light ()
+  "Colors the block headers and footers to make them stand out more for lighter themes"
+  (interactive)
+  (custom-set-faces
+   '(org-block-begin-line
+    ((t (:underline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
+   '(org-block-background
+     ((t (:background "#FFFFEA"))))
+   '(org-block-end-line
+     ((t (:overline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
+
+   '(mode-line-buffer-id ((t (:foreground "#005000" :bold t))))
+   '(which-func ((t (:foreground "#008000")))))
+
+   ;; Looks like the minibuffer issues are only for v23
+   ; (set-face-foreground 'minibuffer "black")
+   ; (set-face-foreground 'minibuffer-prompt "red")
+)
+
+(defun org-src-color-blocks-dark ()
+  "Colors the block headers and footers to make them stand out more for dark themes"
+  (interactive)
+  (custom-set-faces
+   '(org-block-begin-line
+     ((t (:foreground "#008ED1" :background "#002E41"))))
+   '(org-block-background
+     ((t (:background "#111111"))))
+   '(org-block-end-line
+     ((t (:foreground "#008ED1" :background "#002E41"))))
+
+   '(mode-line-buffer-id ((t (:foreground "black" :bold t))))
+   '(which-func ((t (:foreground "green")))))
+
+   ;; Looks like the minibuffer issues are only for v23
+   ;; (set-face-foreground 'minibuffer "white")
+   ;; (set-face-foreground 'minibuffer-prompt "white")
+)
+
+(deftheme ha/org-theme "Sub-theme to beautify org mode")
+
+
+(defun ha/change-theme (theme org-block-style)
+  "Changes the color scheme and reset the mode line."
+  (funcall theme)
+  (powerline-reset)
+  (funcall org-block-style)
+
+  (let* ((sans-font (cond ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
+                          ((x-list-fonts "Lucida Grande")   '(:font "Lucida Grande"))
+                          ((x-list-fonts "Verdana")         '(:font "Verdana"))
+                          ((x-family-fonts "Sans Serif")    '(:family "Sans Serif"))
+                          (nil (warn "Cannot find a Sans Serif Font.  Install Source Sans Pro."))))
+         (base-font-color  (face-foreground 'default nil 'default))
+         (background-color (face-background 'default nil 'default))
+         (primary-color    (face-foreground 'mode-line nil))
+         (secondary-color  (face-background 'secondary-selection nil 'region))
+         (headline        `(:inherit default :weight bold :foreground ,base-font-color)))
+    (custom-theme-set-faces 'ha/org-theme
+                            `(org-agenda-structure ((t (:inherit default ,@sans-font :height 2.0 :underline nil))))
+                            `(org-level-8 ((t (,@headline ,@sans-font))))
+                            `(org-level-7 ((t (,@headline ,@sans-font))))
+                            `(org-level-6 ((t (,@headline ,@sans-font))))
+                            `(org-level-5 ((t (,@headline ,@sans-font))))
+                            `(org-level-4 ((t (,@headline ,@sans-font :height 1.1))))
+                            `(org-level-3 ((t (,@headline ,@sans-font :height 1.25))))
+                            `(org-level-2 ((t (,@headline ,@sans-font :height 1.5))))
+                            `(org-level-1 ((t (,@headline ,@sans-font :height 1.75))))
+                            `(org-document-title ((t (,@headline ,@sans-font :height 1.5 :underline nil)))))))
+
+
+(if (equal "howard.abrams" user-login-name)
+;(if (equal "peli3" user-login-name)
+  (ha/change-theme 'color-theme-sanityinc-tomorrow-day
+                   'org-src-color-blocks-light)
+  (ha/change-theme 'color-theme-sanityinc-tomorrow-night
+                   'org-src-color-blocks-dark))
+
+
+;(define-sequence 'personal-theme-map "<f9> d" 'ha/change-theme
+;  (list (list "d" 'color-theme-sanityinc-tomorrow-day      'org-src-color-blocks-light)  ; White on Black
+;        (list "l" 'color-theme-sanityinc-tomorrow-eighties 'org-src-color-blocks-dark)   ; Lt. Gray on Gray
+;        (list "m" 'color-theme-sanityinc-tomorrow-bright   'org-src-color-blocks-dark)   ; Bright on Black
+;        (list "n" 'color-theme-sanityinc-tomorrow-night    'org-src-color-blocks-dark))) ; White on Gray
+
+;;;;;;;;; mode line
+(setq which-func-unknown "")
+(which-function-mode 1)
+
+(setq which-func-format
+      `(" "
+        (:propertize which-func-current local-map
+                     (keymap
+                      (mode-line keymap
+                                 (mouse-3 . end-of-defun)
+                                 (mouse-2 . narrow-to-defun)
+                                 (mouse-1 . beginning-of-defun)))
+                     face which-func
+                     mouse-face mode-line-highlight
+                     help-echo "mouse-1: go to beginning\n\
+mouse-2: toggle rest visibility\n\
+mouse-3: go to end")
+        " "))
+
+
+(defun powerline-simpler-vc-mode (s)
+  (if s
+      (replace-regexp-in-string "Git:" "" s)
+    s))
+
+(defun powerline-simpler-minor-display (s)
+  (replace-regexp-in-string
+   (concat " "
+           (mapconcat 'identity '("Undo-Tree" "GitGutter" "Projectile"
+                                  "Abbrev" "ColorIds" "MRev" "ElDoc" "Paredit"
+                                  "+1" "+2" "FlyC" "Fly" ;; ":1/0"
+                                  "Fill" "AC" "FIC") "\\|")) "" s))
+
+(defun powerline-ha-theme ()
+  "A powerline theme that removes many minor-modes that don't serve much purpose on the mode-line."
+  (interactive)
+  (setq-default mode-line-format
+                '("%e"
+                  (:eval
+                   (let*
+                       ((active
+                         (powerline-selected-window-active))
+                        (mode-line
+                         (if active 'mode-line 'mode-line-inactive))
+                        (face1
+                         (if active 'powerline-active1 'powerline-inactive1))
+                        (face2
+                         (if active 'powerline-active2 'powerline-inactive2))
+                        (separator-left
+                         (intern
+                          (format "powerline-%s-%s" powerline-default-separator
+                                  (car powerline-default-separator-dir))))
+                        (separator-right
+                         (intern
+                          (format "powerline-%s-%s" powerline-default-separator
+                                  (cdr powerline-default-separator-dir))))
+                        (lhs
+                         (list
+                          (powerline-raw "%*" nil 'l)
+                          ;; (powerline-buffer-size nil 'l)
+                          (powerline-buffer-id nil 'l)
+                          (powerline-raw " ")
+                          (funcall separator-left mode-line face1)
+                          (powerline-narrow face1 'l)
+                          (powerline-simpler-vc-mode (powerline-vc face1))))
+                        (rhs
+                         (list
+                          (powerline-raw mode-line-misc-info face1 'r)
+                          (powerline-raw global-mode-string face1 'r)
+                          (powerline-raw "%4l" face1 'r)
+                          (powerline-raw ":" face1)
+                          (powerline-raw "%3c" face1 'r)
+                          (funcall separator-right face1 mode-line)
+                          (powerline-raw " ")
+                          (powerline-raw "%6p" nil 'r)
+                          (powerline-hud face2 face1)))
+                        (center
+                         (list
+                          (powerline-raw " " face1)
+                          (funcall separator-left face1 face2)
+                          (when
+                              (boundp 'erc-modified-channels-object)
+                            (powerline-raw erc-modified-channels-object face2 'l))
+                          (powerline-major-mode face2 'l)
+                          (powerline-process face2)
+                          (powerline-raw " :" face2)
+
+                          (powerline-simpler-minor-display (powerline-minor-modes face2 'l))
+
+                          (powerline-raw " " face2)
+                          (funcall separator-right face2 face1))))
+                     (concat
+                      (powerline-render lhs)
+                      (powerline-fill-center face1
+                                             (/
+                                              (powerline-width center)
+                                              2.0))
+                      (powerline-render center)
+                      (powerline-fill face1
+                                      (powerline-width rhs))
+                      (powerline-render rhs)))))))
+
+(powerline-ha-theme)
+
 
+(provide 'init-mode-line)
+(fringe-mode -1)