├── README.org ├── .cache ├── .gitmodules ├── .projectile ├── .travis.yml ├── Makefile ├── .gitignore ├── local-lisp └── coldnew-fonts-setup.el ├── theme ├── coldnew-theme-day-theme.el ├── coldnew-theme-night-theme.el ├── coldnew-modeline-config.el ├── coldnew-theme-old.el └── coldnew-theme.el ├── spacemacs.d └── init.el └── init.org /README.org: -------------------------------------------------------------------------------- 1 | init.org -------------------------------------------------------------------------------- /.cache: -------------------------------------------------------------------------------- 1 | modules/spacemacs/.cache -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | 2 | [submodule "spacemacs"] 3 | path = modules/spacemacs 4 | url = https://github.com/syl20bnr/spacemacs.git 5 | -------------------------------------------------------------------------------- /.projectile: -------------------------------------------------------------------------------- 1 | -/semanticdb 2 | -/url 3 | -/edts 4 | -/elpa 5 | -/.cache 6 | -ac-comphist.dat 7 | -.emacs.desktop 8 | -.emacs.desktop.lock 9 | -.smex-items 10 | -*.elc -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: emacs-lisp 2 | sudo: true 3 | env: 4 | matrix: 5 | - EMACS=emacs24 EMACS_PPA=ppa:cassou/emacs 6 | - EMACS=emacs-snapshot EMACS_PPA=ppa:ubuntu-elisp/ppa 7 | global: 8 | secure: YcMrnDekniVjfY1kQeGmuGIHQRFQM5Kf64HURs2QhGNqoIePfDIHOCfWh4HI3fhdYQLHy/+sLpr6RUEF4iVoDi5XrjsPq7faVhE+NmHWFoWG8eLMjxm1krK1WC2c17lczQKArIkQnA/zILxg4okD4WvCYOBRcOGlIKpQEV7yKBg= 9 | notifications: 10 | email: false 11 | branches: 12 | only: 13 | - master 14 | - v2 15 | before_install: 16 | - sudo add-apt-repository -y "$EMACS_PPA" 17 | - sudo apt-get update -qq 18 | - sudo apt-get install --force-yes -qq "$EMACS" 19 | - sudo apt-get install --force-yes -qq "${EMACS}-el" || true # OK to fail 20 | - curl -fsSkL https://raw.github.com/cask/cask/master/go | python 21 | - export PATH="${HOME}/.cask/bin:$PATH" 22 | install: 23 | - '"$EMACS" --version' 24 | script: 25 | - make clean 26 | - make bootstrap 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EMACS ?= emacs 2 | CASK ?= cask 3 | 4 | all: compile 5 | 6 | test: clean 7 | ${MAKE} all 8 | 9 | bootstrap: 10 | ${MAKE} clean 11 | ${MAKE} init.el 12 | ${CASK} install 13 | 14 | Cask: 15 | ${RM} Cask 16 | ${MAKE} init.el 17 | 18 | clean: 19 | $(RM) init.el Cask 20 | $(RM) *.elc 21 | $(RM) */*.elc 22 | 23 | # Use emacs to generate init.el from init.org 24 | # we first tangle the org-mode file to init.el~ the rename it. 25 | # this can make use use async task to create another init.el after save. 26 | init.el: 27 | ${EMACS} -Q -batch \ 28 | --eval "(require 'org)" \ 29 | --eval '(setq org-confirm-babel-evaluate nil)' \ 30 | --eval '(setq org-confirm-execute-src-block nil)' \ 31 | --eval '(if (file-exists-p "init.el~") (delete-file "init.el~" nil))' \ 32 | --eval '(org-babel-tangle-file "init.org" "init.el~")' \ 33 | --eval '(rename-file "init.el~" "init.el" t)' 34 | 35 | compile: init.el 36 | ${CASK} exec ${EMACS} -Q -batch \ 37 | --eval '(setq byte-compile-error-on-warn nil)' \ 38 | --eval '(byte-recompile-directory (expand-file-name (getenv "PWD")) 0)' 39 | 40 | .PHONY: all bootstrap init.el test unit compile 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # -*- mode: gitignore; -*- 2 | *~ 3 | \#*\# 4 | /.emacs.desktop 5 | /.emacs.desktop.lock 6 | *.elc 7 | auto-save-list 8 | tramp 9 | .\#* 10 | 11 | # Org-mode 12 | .org-id-locations 13 | *_archive 14 | 15 | # flymake-mode 16 | *_flymake.* 17 | 18 | # eshell files 19 | /eshell/history 20 | /eshell/lastdir 21 | 22 | # elpa packages 23 | /elpa/ 24 | 25 | # reftex files 26 | *.rel 27 | 28 | # AUCTeX auto folder 29 | /auto/ 30 | 31 | # cask packages 32 | .cask/ 33 | 34 | auto-save-list/ 35 | elpa/ 36 | ac-comphist.dat 37 | eproject.lst 38 | .smex-items 39 | \#* 40 | .places 41 | eshell/history 42 | .emacs.desktop 43 | .emacs.desktop.lock 44 | eshell/alias 45 | eshell/lastdir 46 | /url/cookies 47 | my-org/ 48 | org-files/ 49 | semanticdb/ 50 | edts/ 51 | .recentf 52 | .recentf~ 53 | projectile.cache 54 | projectile-bookmarks.eld 55 | tramp 56 | elnode/ 57 | var/ 58 | crown/ 59 | *.stackdump 60 | bookmarks 61 | /.my-keybindings.el.swp 62 | .DS_Store 63 | tmp/ 64 | /history 65 | .python-environments/ 66 | server/ 67 | *~ 68 | *.elc 69 | *.pyc 70 | /*.zip 71 | *.db 72 | python-*-docs-html 73 | 74 | /games/ 75 | 76 | /init.el* 77 | .cask/ 78 | .sx/ 79 | request/ 80 | .litable-lists.el 81 | modules/spacemacs/srecode-map.el* 82 | TODO.org 83 | network-security.data 84 | .c2/ 85 | Cask 86 | -------------------------------------------------------------------------------- /local-lisp/coldnew-fonts-setup.el: -------------------------------------------------------------------------------- 1 | (defvar emacs-english-font "Monaco" 2 | "the font name of English.") 3 | 4 | (defvar emacs-cjk-font "Hiragino Sans GB W3" 5 | "The font name for CJK.") 6 | 7 | (defvar emacs-font-size-pair '(15 . 18) 8 | "Default font size pair for (english . chinese)") 9 | 10 | (defvar emacs-font-size-pair-list 11 | '(( 5 . 6) (10 . 12) 12 | (13 . 16) (15 . 18) (17 . 20) 13 | (19 . 22) (20 . 24) (21 . 26) 14 | (24 . 28) (26 . 32) (28 . 34) 15 | (30 . 36) (34 . 40) (36 . 44)) 16 | "This list is used to store matching (english . chinese) font-size.") 17 | 18 | (defun font-exist-p (fontname) 19 | "Test if this font is exist or not. 20 | This function only work on GUI mode, on terminal it just 21 | return nil since you can't set font for emacs on it." 22 | (if (or (not fontname) (string= fontname "") (not (display-graphic-p))) 23 | nil 24 | (if (not (x-list-fonts fontname)) 25 | nil t))) 26 | 27 | (defun set-font (english chinese size-pair) 28 | "Setup emacs English and Chinese font on x window-system." 29 | 30 | (if (font-exist-p english) 31 | (set-frame-font (format "%s:pixelsize=%d" english (car size-pair)) t)) 32 | 33 | (if (font-exist-p chinese) 34 | (dolist (charset '(kana han cjk-misc bopomofo)) 35 | (set-fontset-font (frame-parameter nil 'font) charset 36 | (font-spec :family chinese :size (cdr size-pair)))))) 37 | 38 | ;; Setup font size based on emacs-font-size-pair 39 | (set-font emacs-english-font emacs-cjk-font emacs-font-size-pair) 40 | 41 | (defun emacs-step-font-size (step) 42 | "Increase/Decrease emacs's font size." 43 | (let ((scale-steps emacs-font-size-pair-list)) 44 | (if (< step 0) (setq scale-steps (reverse scale-steps))) 45 | (setq emacs-font-size-pair 46 | (or (cadr (member emacs-font-size-pair scale-steps)) 47 | emacs-font-size-pair)) 48 | (when emacs-font-size-pair 49 | (message "emacs font size set to %.1f" (car emacs-font-size-pair)) 50 | (set-font emacs-english-font emacs-cjk-font emacs-font-size-pair)))) 51 | 52 | (defun increase-emacs-font-size () 53 | "Decrease emacs's font-size acording emacs-font-size-pair-list." 54 | (interactive) (emacs-step-font-size 1)) 55 | 56 | (defun decrease-emacs-font-size () 57 | "Increase emacs's font-size acording emacs-font-size-pair-list." 58 | (interactive) (emacs-step-font-size -1)) 59 | 60 | (global-set-key (kbd "C-=") 'increase-emacs-font-size) 61 | (global-set-key (kbd "C--") 'decrease-emacs-font-size) 62 | 63 | (provide 'coldnew-fonts-setup) 64 | -------------------------------------------------------------------------------- /theme/coldnew-theme-day-theme.el: -------------------------------------------------------------------------------- 1 | ;;; coldnew-theme-day-theme.el --- coldnew's emacs color-theme day version. 2 | 3 | ;; Copyright (C) 2015 Yen-Chin, Lee. 4 | 5 | ;; Author: coldnew 6 | ;; Kyewords: themes 7 | ;; Version: 0.1 8 | ;; X-Original-Version: 0.1 9 | ;; Package-Requires: ((emacs "24.1")) 10 | 11 | ;; This file is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This file is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;;; Code: 27 | (require 'coldnew-theme) 28 | 29 | (deftheme coldnew-theme-day 30 | "coldnew's day theme") 31 | 32 | (add-to-list 33 | 'coldnew-theme-colors 34 | '(day 35 | . 36 | (;; name sRGB 256 37 | (background "#FAFAFA" "#FAFAFA") 38 | (foreground "#212121" "#212121") 39 | (comment "#607d8b" "#607d8b") 40 | (current-line "#ECEFF1" "#dadada") 41 | 42 | (red "#B71C1C" "#B71C1C") 43 | (orange "#FF5722" "#FF5722") 44 | (yellow "#FFA000" "#FFA000") 45 | (green "#558b2f" "#558b2f") 46 | (aqua "#00796b" "#00796b") 47 | (cyan "#aadddd" "#aadddd") 48 | (blue "#2196f3" "#2196f3") 49 | (magenta "#4527A0" "#4527A0") 50 | (black "#2a2a2a" "#2a2a2a") 51 | (white "#ffffff" "#ffffff") 52 | 53 | ;; extra color 54 | (base03 "#202020" "#202020") 55 | (base02 "#292929" "#292929") 56 | (base01 "#5f5f5f" "#5f5f5f") 57 | (base00 "#999999" "#999999") 58 | (base0 "#cccccc" "#cccccc") 59 | (base1 "#aaaaaa" "#aaaaaa") 60 | (base2 "#e9e2cb" "#e9e2cb") 61 | (base3 "#fcf4dc" "#fcf4dc") 62 | 63 | ;; other 64 | (cursor "#0B0B0E") 65 | (current-line "#efefef") 66 | (selection "#d6d6d6") 67 | (highlight "#CAE682") 68 | ;; (comment "#8e908c") 69 | 70 | ;; rainbow delimiters 71 | (rainbow-1 "#e91e63" "#e91e63") 72 | (rainbow-2 "#1565C0" "#1565C0") 73 | (rainbow-3 "#EF6C00" "#EF6C00") 74 | (rainbow-4 "#B388FF" "#B388FF") 75 | (rainbow-5 "#76FF03" "#76FF03") 76 | (rainbow-6 "#26A69A" "#26A69A") 77 | (rainbow-7 "#B71C1C" "#B71C1C") 78 | (rainbow-8 "#795548" "#795548") 79 | (rainbow-9 "#827717" "#827717") 80 | ))) 81 | 82 | (coldnew-theme--with-colors 83 | 'day 84 | (apply 'custom-theme-set-faces 'coldnew-theme-day 85 | (coldnew-theme--face-specs)) 86 | (custom-theme-set-variables 87 | 'coldnew-theme-day 88 | `(ansi-color-names-vector (vector ,foreground ,red ,green ,yellow ,blue ,magenta ,cyan ,background)) 89 | '(ansi-color-faces-vector [default bold shadow italic underline bold bold-italic bold]))) 90 | 91 | ;; FIXME: need to rewrite 92 | 93 | ;; ;;;###autoload 94 | ;; (defun coldnew-theme-day () 95 | ;; (interactive) 96 | ;; (coldnew-theme--load-theme 'day)) 97 | 98 | (provide 'coldnew-theme-day-theme) 99 | ;;; coldnew-theme-day-theme.el ends here 100 | -------------------------------------------------------------------------------- /theme/coldnew-theme-night-theme.el: -------------------------------------------------------------------------------- 1 | ;;; coldnew-theme-night-theme.el --- coldnew's emacs color-theme night version. 2 | 3 | ;; Copyright (C) 2015 Yen-Chin, Lee. 4 | 5 | ;; Author: coldnew 6 | ;; Kyewords: themes 7 | ;; Version: 0.1 8 | ;; X-Original-Version: 0.1 9 | ;; Package-Requires: ((emacs "24.1")) 10 | 11 | ;; This file is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This file is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;;; Code: 27 | (require 'coldnew-theme) 28 | 29 | (deftheme coldnew-theme-night 30 | "coldnew's night theme") 31 | 32 | (add-to-list 33 | 'coldnew-theme-colors 34 | '(night 35 | . (;; name sRGB 256 36 | (background "#202020" "#202020") 37 | (far-background "#1c1f26" "#121212") 38 | (foreground "#c6cccc" "#c6cccc") 39 | (cursor "#00c8c8" "#00c8c8") 40 | (current-line "#2a2a2a" "#2a2a2a") 41 | (selection "#3b3f41" "#3b3f41") 42 | (highlight "#CAE682" "#CAE682") 43 | 44 | ;; font-lock 45 | (buildin "#ccaaff" "#ccaaff") 46 | (constant "#ccaaff" "#ccaaff") 47 | (comment "#9ac" "#9ac") 48 | (comment-delimiter "#5f5f5f" "#5f5f5f") 49 | (doc "#97abc6" "#97abc6") 50 | (function-name "#aaccff" "#aaccff") 51 | (keyword "#aaffaa" "#aaffaa") 52 | (type "#fff59d" "#fff59d") 53 | (variable-name "#aaccff" "#aaccff") 54 | (string "#aadddd" "#aadddd") 55 | 56 | ;; extra color 57 | (base03 "#202020" "#202020") 58 | (base02 "#292929" "#292929") 59 | (base01 "#5f5f5f" "#5f5f5f") 60 | (base00 "#999999" "#999999") 61 | (base0 "#cccccc" "#cccccc") 62 | (base1 "#aaaaaa" "#aaaaaa") 63 | (base2 "#e9e2cb" "#e9e2cb") 64 | (base3 "#fcf4dc" "#fcf4dc") 65 | 66 | ;; terminal color 67 | (red "#ff3333" "#ff3333") 68 | (yellow "#fff59d" "#fff59d") 69 | (orange "#ff8888" "#ff8888") 70 | (green "#aaffaa" "#aaffaa") 71 | (blue "#aaccff" "#aaccff") 72 | (magenta "#ccaaff" "#ccaaff") 73 | (cyan "#aadddd" "#aadddd") 74 | (white "#ffffff" "#ffffff") 75 | (black "#2a2a2a" "#2a2a2a") 76 | (aqua "#81d4fa" "#81d4fa") 77 | 78 | ;; rainbow delimiters 79 | (rainbow-1 "#aadddd" "#aadddd") 80 | (rainbow-2 "#81d4fa" "#81d4fa") 81 | (rainbow-3 "#aaccff" "#aaccff") 82 | (rainbow-4 "#aaeecc" "#aaeecc") 83 | (rainbow-5 "#ccaaff" "#ccaaff") 84 | (rainbow-6 "#fff59d" "#fff59d") 85 | (rainbow-7 "#ff8888" "#ff8888") 86 | (rainbow-8 "#795548" "#795548") 87 | (rainbow-9 "#827717" "#827717") 88 | ))) 89 | 90 | (coldnew-theme--with-colors 91 | 'night 92 | (apply 'custom-theme-set-faces 'coldnew-theme-night 93 | (coldnew-theme--face-specs)) 94 | (custom-theme-set-variables 95 | 'coldnew-theme-night 96 | `(ansi-color-names-vector (vector ,foreground ,red ,green ,yellow ,blue ,magenta ,cyan ,background)) 97 | '(ansi-color-faces-vector [default bold shadow italic underline bold bold-italic bold]))) 98 | 99 | ;;;###autoload 100 | (defun coldnew-theme-night () 101 | (interactive) 102 | (coldnew-theme--load-theme 'night)) 103 | 104 | (provide 'coldnew-theme-night-theme) 105 | ;;; coldnew-theme-night-theme.el ends here. 106 | -------------------------------------------------------------------------------- /theme/coldnew-modeline-config.el: -------------------------------------------------------------------------------- 1 | ;;; coldnew-modeline-config.el --- coldnew's modeline-config theme. 2 | 3 | ;; Copyright (C) 2015 Yen-Chin, Lee. 4 | 5 | ;; Author: coldnew 6 | ;; Kyewords: themes 7 | ;; Version: 0.1 8 | ;; X-Original-Version: 0.1 9 | ;; Package-Requires: ((emacs "24.1")) 10 | 11 | ;; This file is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This file is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;;; Code: 27 | 28 | (require 'powerline) 29 | (require 'powerline-evil) 30 | 31 | 32 | (defun coldnew/mode-line-prepare-left () 33 | (let* ((active (powerline-selected-window-active)) 34 | (mode-line (if active 'mode-line 'mode-line-inactive)) 35 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 36 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 37 | (separator-left (intern (format "powerline-%s-%s" 38 | powerline-default-separator 39 | (car powerline-default-separator-dir)))) 40 | (separator-right (intern (format "powerline-%s-%s" 41 | powerline-default-separator 42 | (cdr powerline-default-separator-dir))))) 43 | (append 44 | ;; Evil-state indicator 45 | (let ((evil-face (powerline-evil-face))) 46 | (append (if evil-mode 47 | (list (funcall separator-right face2 evil-face) 48 | (powerline-raw " " evil-face) 49 | (powerline-raw (powerline-evil-tag) evil-face 'l) 50 | (powerline-raw " " evil-face) 51 | (funcall separator-left evil-face mode-line))) 52 | 53 | (list (powerline-minor-modes face2 'l) 54 | (powerline-raw " " face2) 55 | (funcall separator-right face2 face1))) 56 | (list (powerline-raw (powerline-evil-tag) evil-face) 57 | (funcall separator-left evil-face mode-line))) 58 | (list 59 | ;; Buffer state indicator 60 | (cond (buffer-read-only 61 | (propertize "RO" 'face 'mode-line-read-only-face)) 62 | ((buffer-modified-p) 63 | (propertize "**" 'face 'mode-line-modified-face)) 64 | (t "--")) 65 | 66 | (powerline-buffer-id nil 'l) 67 | (powerline-raw " ") 68 | (funcall separator-left mode-line face1) 69 | 70 | ;; major mode 71 | (funcall separator-left face1 mode-line ) 72 | (powerline-raw " " mode-line) 73 | (powerline-major-mode mode-line 'l) 74 | (powerline-raw " " mode-line) 75 | (funcall separator-left mode-line face1) 76 | 77 | ;; VC 78 | (powerline-vc face1) 79 | (powerline-raw " " face1 '1) 80 | (funcall separator-left face1 face2) 81 | )))) 82 | 83 | 84 | (defun coldnew/mode-line-prepare-right () 85 | (let* ((active (powerline-selected-window-active)) 86 | (mode-line (if active 'mode-line 'mode-line-inactive)) 87 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 88 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 89 | (separator-left (intern (format "powerline-%s-%s" 90 | powerline-default-separator 91 | (car powerline-default-separator-dir)))) 92 | (separator-right (intern (format "powerline-%s-%s" 93 | powerline-default-separator 94 | (cdr powerline-default-separator-dir))))) 95 | (append 96 | (list 97 | (powerline-process face2) 98 | (funcall separator-right face2 face1) 99 | (when (boundp 'erc-modified-channels-object) 100 | (powerline-raw erc-modified-channels-object face2 'l)) 101 | (powerline-raw "%4l" face1 'r) 102 | (powerline-raw ":" face1) 103 | (powerline-raw "%3c" face1 'r) 104 | (funcall separator-right face1 mode-line) 105 | (powerline-raw " ") 106 | (powerline-raw "%6p" nil 'r) 107 | (powerline-buffer-size nil 'r) 108 | (powerline-hud face2 face1)) 109 | ))) 110 | 111 | (defun coldnew/mode-line-prepare () 112 | (let* ((active (powerline-selected-window-active)) 113 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 114 | (lhs (coldnew/mode-line-prepare-left)) 115 | (rhs (coldnew/mode-line-prepare-right))) 116 | (concat (powerline-render lhs) 117 | (powerline-fill face2 (powerline-width rhs)) 118 | (powerline-render rhs)))) 119 | 120 | ;; Setup my mode-line 121 | 122 | (setq powerline-default-separator 'arrow) 123 | 124 | (setq mode-line-format 125 | '("%e" (:eval (coldnew/mode-line-prepare)))) 126 | 127 | (defun spacemacs/mode-line-prepare () 128 | "Overwrite spacemacs's mode-line-prepare so I can use my own modeline." 129 | (coldnew/mode-line-prepare)) 130 | 131 | 132 | (provide 'coldnew-modeline-config) 133 | ;;; coldnew-modeline-config.el ends here. 134 | -------------------------------------------------------------------------------- /spacemacs.d/init.el: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | ;; This file is loaded by Spacemacs at startup. 3 | ;; It must be stored in your home directory. 4 | 5 | (defun dotspacemacs/layers () 6 | "Configuration Layers declaration. 7 | You should not put any user code in this function besides modifying the variable 8 | values." 9 | (setq-default 10 | ;; Base distribution to use. This is a layer contained in the directory 11 | ;; `+distribution'. For now available distributions are `spacemacs-base' 12 | ;; or `spacemacs'. (default 'spacemacs) 13 | dotspacemacs-distribution 'spacemacs 14 | ;; List of additional paths where to look for configuration layers. 15 | ;; Paths must have a trailing slash (i.e. `~/.mycontribs/') 16 | dotspacemacs-configuration-layer-path '() 17 | ;; List of configuration layers to load. If it is the symbol `all' instead 18 | ;; of a list then all discovered layers will be installed. 19 | dotspacemacs-configuration-layers 20 | '( 21 | ;; ---------------------------------------------------------------- 22 | ;; Example of useful layers you may want to use right away. 23 | ;; Uncomment some layer names and press (Vim style) or 24 | ;; (Emacs style) to install them. 25 | ;; ---------------------------------------------------------------- 26 | auto-completion 27 | better-defaults 28 | emacs-lisp 29 | git 30 | github 31 | markdown 32 | clojure 33 | elixir 34 | go 35 | html 36 | java 37 | ocaml 38 | racket 39 | scala 40 | ruby 41 | yaml 42 | ;; org 43 | ;; (shell :variables 44 | ;; shell-default-height 30 45 | ;; shell-default-position 'bottom) 46 | ;; spell-checking 47 | cscope 48 | semantic 49 | syntax-checking 50 | version-control 51 | c-c++ 52 | ) 53 | ;; List of additional packages that will be installed without being 54 | ;; wrapped in a layer. If you need some configuration for these 55 | ;; packages then consider to create a layer, you can also put the 56 | ;; configuration in `dotspacemacs/config'. 57 | dotspacemacs-additional-packages '() 58 | ;; A list of packages and/or extensions that will not be install and loaded. 59 | dotspacemacs-excluded-packages '() 60 | ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that 61 | ;; are declared in a layer which is not a member of 62 | ;; the list `dotspacemacs-configuration-layers'. (default t) 63 | dotspacemacs-delete-orphan-packages t)) 64 | 65 | (defun dotspacemacs/init () 66 | "Initialization function. 67 | This function is called at the very startup of Spacemacs initialization 68 | before layers configuration. 69 | You should not put any user code in there besides modifying the variable 70 | values." 71 | ;; This setq-default sexp is an exhaustive list of all the supported 72 | ;; spacemacs settings. 73 | (setq-default 74 | ;; One of `vim', `emacs' or `hybrid'. Evil is always enabled but if the 75 | ;; variable is `emacs' then the `holy-mode' is enabled at startup. `hybrid' 76 | ;; uses emacs key bindings for vim's insert mode, but otherwise leaves evil 77 | ;; unchanged. (default 'vim) 78 | dotspacemacs-editing-style 'vim 79 | ;; If non nil output loading progress in `*Messages*' buffer. (default nil) 80 | dotspacemacs-verbose-loading nil 81 | ;; Specify the startup banner. Default value is `official', it displays 82 | ;; the official spacemacs logo. An integer value is the index of text 83 | ;; banner, `random' chooses a random text banner in `core/banners' 84 | ;; directory. A string value must be a path to an image format supported 85 | ;; by your Emacs build. 86 | ;; If the value is nil then no banner is displayed. (default 'official) 87 | dotspacemacs-startup-banner 'official 88 | ;; List of items to show in the startup buffer. If nil it is disabled. 89 | ;; Possible values are: `recents' `bookmarks' `projects'. 90 | ;; (default '(recents projects)) 91 | dotspacemacs-startup-lists '(recents projects) 92 | ;; List of themes, the first of the list is loaded when spacemacs starts. 93 | ;; Press T n to cycle to the next theme in the list (works great 94 | ;; with 2 themes variants, one dark and one light) 95 | dotspacemacs-themes '(spacemacs-dark 96 | spacemacs-light 97 | solarized-light 98 | solarized-dark 99 | leuven 100 | monokai 101 | zenburn) 102 | ;; If non nil the cursor color matches the state color. 103 | dotspacemacs-colorize-cursor-according-to-state t 104 | ;; Default font. `powerline-scale' allows to quickly tweak the mode-line 105 | ;; size to make separators look not too crappy. 106 | dotspacemacs-default-font '("Source Code Pro" 107 | :size 13 108 | :weight normal 109 | :width normal 110 | :powerline-scale 1.1) 111 | ;; The leader key 112 | dotspacemacs-leader-key "SPC" 113 | ;; The leader key accessible in `emacs state' and `insert state' 114 | ;; (default "M-m") 115 | dotspacemacs-emacs-leader-key "M-m" 116 | ;; Major mode leader key is a shortcut key which is the equivalent of 117 | ;; pressing ` m`. Set it to `nil` to disable it. (default ",") 118 | dotspacemacs-major-mode-leader-key "," 119 | ;; Major mode leader key accessible in `emacs state' and `insert state'. 120 | ;; (default "C-M-m) 121 | dotspacemacs-major-mode-emacs-leader-key "C-M-m" 122 | ;; The command key used for Evil commands (ex-commands) and 123 | ;; Emacs commands (M-x). 124 | ;; By default the command key is `:' so ex-commands are executed like in Vim 125 | ;; with `:' and Emacs commands are executed with ` :'. 126 | dotspacemacs-command-key ":" 127 | ;; If non nil `Y' is remapped to `y$'. (default t) 128 | dotspacemacs-remap-Y-to-y$ t 129 | ;; Location where to auto-save files. Possible values are `original' to 130 | ;; auto-save the file in-place, `cache' to auto-save the file to another 131 | ;; file stored in the cache directory and `nil' to disable auto-saving. 132 | ;; (default 'cache) 133 | dotspacemacs-auto-save-file-location 'cache 134 | ;; If non nil then `ido' replaces `helm' for some commands. For now only 135 | ;; `find-files' (SPC f f), `find-spacemacs-file' (SPC f e s), and 136 | ;; `find-contrib-file' (SPC f e c) are replaced. (default nil) 137 | dotspacemacs-use-ido nil 138 | ;; If non nil, `helm' will try to miminimize the space it uses. (default nil) 139 | dotspacemacs-helm-resize nil 140 | ;; if non nil, the helm header is hidden when there is only one source. 141 | ;; (default nil) 142 | dotspacemacs-helm-no-header nil 143 | ;; define the position to display `helm', options are `bottom', `top', 144 | ;; `left', or `right'. (default 'bottom) 145 | dotspacemacs-helm-position 'bottom 146 | ;; If non nil the paste micro-state is enabled. When enabled pressing `p` 147 | ;; several times cycle between the kill ring content. (default nil) 148 | dotspacemacs-enable-paste-micro-state nil 149 | ;; Which-key delay in seconds. The which-key buffer is the popup listing 150 | ;; the commands bound to the current keystroke sequence. (default 0.4) 151 | dotspacemacs-which-key-delay 0.4 152 | ;; Which-key frame position. Possible values are `right', `bottom' and 153 | ;; `right-then-bottom'. right-then-bottom tries to display the frame to the 154 | ;; right; if there is insufficient space it displays it at the bottom. 155 | ;; (default 'bottom) 156 | dotspacemacs-which-key-position 'bottom 157 | ;; If non nil a progress bar is displayed when spacemacs is loading. This 158 | ;; may increase the boot time on some systems and emacs builds, set it to 159 | ;; nil to boost the loading time. (default t) 160 | dotspacemacs-loading-progress-bar nil 161 | ;; If non nil the frame is fullscreen when Emacs starts up. (default nil) 162 | ;; (Emacs 24.4+ only) 163 | dotspacemacs-fullscreen-at-startup nil 164 | ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen. 165 | ;; Use to disable fullscreen animations in OSX. (default nil) 166 | dotspacemacs-fullscreen-use-non-native nil 167 | ;; If non nil the frame is maximized when Emacs starts up. 168 | ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. 169 | ;; (default nil) (Emacs 24.4+ only) 170 | dotspacemacs-maximized-at-startup nil 171 | ;; A value from the range (0..100), in increasing opacity, which describes 172 | ;; the transparency level of a frame when it's active or selected. 173 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 174 | dotspacemacs-active-transparency 90 175 | ;; A value from the range (0..100), in increasing opacity, which describes 176 | ;; the transparency level of a frame when it's inactive or deselected. 177 | ;; Transparency can be toggled through `toggle-transparency'. (default 90) 178 | dotspacemacs-inactive-transparency 90 179 | ;; If non nil unicode symbols are displayed in the mode line. (default t) 180 | dotspacemacs-mode-line-unicode-symbols t 181 | ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth 182 | ;; scrolling overrides the default behavior of Emacs which recenters the 183 | ;; point when it reaches the top or bottom of the screen. (default t) 184 | dotspacemacs-smooth-scrolling t 185 | ;; If non-nil smartparens-strict-mode will be enabled in programming modes. 186 | ;; (default nil) 187 | dotspacemacs-smartparens-strict-mode nil 188 | ;; Select a scope to highlight delimiters. Possible values are `any', 189 | ;; `current', `all' or `nil'. Default is `all' (highlight any scope and 190 | ;; emphasis the current one). (default 'all) 191 | dotspacemacs-highlight-delimiters 'all 192 | ;; If non nil advises quit functions to keep server open when quitting. 193 | ;; (default nil) 194 | dotspacemacs-persistent-server nil 195 | ;; List of search tool executable names. Spacemacs uses the first installed 196 | ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'. 197 | ;; (default '("ag" "pt" "ack" "grep")) 198 | dotspacemacs-search-tools '("ag" "pt" "ack" "grep") 199 | ;; The default package repository used if no explicit repository has been 200 | ;; specified with an installed package. 201 | ;; Not used for now. (default nil) 202 | dotspacemacs-default-package-repository nil 203 | )) 204 | 205 | (defun dotspacemacs/user-init () 206 | "Initialization function for user code. 207 | It is called immediately after `dotspacemacs/init'. You are free to put any 208 | user code." 209 | ) 210 | 211 | (defun dotspacemacs/user-config () 212 | "Configuration function for user code. 213 | This function is called at the very end of Spacemacs initialization after 214 | layers configuration. You are free to put any user code." 215 | ) 216 | -------------------------------------------------------------------------------- /theme/coldnew-theme-old.el: -------------------------------------------------------------------------------- 1 | ;;; coldnew-moe-theme.el --- coldnew's emacs color-theme based on moe-theme. 2 | 3 | ;;; Commentary: 4 | ;; 5 | 6 | ;; 256-color charts 7 | ;; http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html 8 | 9 | (require 'powerline) 10 | (require 'powerline-evil) 11 | 12 | (defface mode-line-read-only-face 13 | '((t (:foreground "#C82829" :bold t))) 14 | "face for mode-name-string in modeline." 15 | :group 'mode-line) 16 | 17 | (defface mode-line-modified-face 18 | '((t (:inherit 'font-lock-function-name-face :bolt t))) 19 | "face for mode-name-string in modeline." 20 | :group'mode-lin) 21 | 22 | (defface mode-line-mode-name-face 23 | '((t (:inherit font-lock-keyword-face))) 24 | "face for mode-name-string in modeline." 25 | :group 'mode-line) 26 | 27 | (defface font-lock-escape-char-face 28 | '((((class color)) (:foreground "seagreen2"))) 29 | "highlight c escapes char like vim" 30 | :group 'font-lock-faces) 31 | 32 | (defconst coldnew-theme-colors 33 | '((night . ((background "#0b0b0b") 34 | (foreground "#dcdcdc") 35 | (cursor "#C2C2C2") 36 | (current-line "#2a2a2a") 37 | (selection "#444444") 38 | (highlight "#CAE682") 39 | (comment "#5d9ae4") 40 | (red "#E52210") 41 | (orange "#e65c00") 42 | (yellow "#f0c674") 43 | (green "#95e454") 44 | (aqua "#5d9ae4") 45 | (blue "#4d85ff") 46 | (purple "#AD7fA8") 47 | )) 48 | (day . ((background "#ffffff") 49 | (foreground "#1c1c1c") 50 | (cursor "#0B0B0E") 51 | (current-line "#efefef") 52 | (selection "#d6d6d6") 53 | (highlight "#CAE682") 54 | (comment "#8e908c") 55 | (red "#c82829") 56 | (orange "#f5871f") 57 | (yellow "#eab700") 58 | (green "#829c00") 59 | (aqua "#3e999f") 60 | (blue "#4271ae") 61 | (purple "#8959a8") 62 | )) 63 | )) 64 | 65 | (defun coldnew-theme--build-colors-alist (mode) 66 | (mapcar (lambda (x) (list (symbol-name (car x)) (cadr x))) 67 | (cdr (assoc (cadr `,mode) coldnew-theme-colors)))) 68 | 69 | (defmacro coldnew-theme--with-colors (mode &rest body) 70 | "`let' bind all colors defined in `coldnew-theme-colors' around BODY. 71 | Also bind `class' to ((class color) (min-colors 89))." 72 | (declare (indent 0)) 73 | `(let ((class '((class color) (min-colors 89))) 74 | ,@(mapcar (lambda (cons) 75 | (list (intern (car cons)) (cadr cons))) 76 | (coldnew-theme--build-colors-alist mode))) 77 | ,@body)) 78 | 79 | (defmacro coldnew-theme--face-specs () 80 | (quote 81 | `( 82 | ;; Ensure sufficient contrast on low-color terminals. 83 | (default ((((class color) (min-colors 4096)) 84 | (:foreground ,foreground :background ,background)) 85 | (((class color) (min-colors 256)) 86 | (:foreground ,foreground :background ,background)) 87 | (,class 88 | (:foreground ,foreground :background ,background)))) 89 | 90 | (bold ((,class (:weight bold)))) 91 | (bold-italic ((,class (:slant italic :weight bold)))) 92 | (underline ((,class (:underline t)))) 93 | (italic ((,class (:slant italic)))) 94 | (shadow ((,class (:foreground ,comment)))) 95 | (success ((,class (:foreground ,green)))) 96 | (error ((,class (:foreground ,red)))) 97 | (warning ((,class (:foreground ,orange)))) 98 | (outline-4 ((,class (:slant normal :foreground ,comment)))) 99 | 100 | ;; Font locks 101 | (font-lock-builtin-face ((t (:foreground "#4BC98A")))) 102 | (font-lock-comment-face ((t (:foreground ,comment :italic t)))) 103 | (font-lock-constant-face ((t (:foreground "#E53F3F" :bold t)))) 104 | (font-lock-function-name-face ((t (:foreground "#AD7FA8" :italic t :bold t)))) 105 | (font-lock-keyword-face ((t (:foreground "#FFC125")))) 106 | (font-lock-string-face ((t (:foreground "#95E454" :italic t)))) 107 | (font-lock-type-face ((t (:foreground "#CAE682")))) 108 | (font-lock-variable-name-face ((t (:foreground "#4BC98A")))) 109 | (font-lock-warning-face ((t (:foreground "#E91303" :bold t)))) 110 | (font-lock-doc-face ((t (:foreground "#40AAFA")))) 111 | 112 | ;; Auto Complete 113 | (ac-candidate-face ((t (:background ,selection :foreground ,foreground)))) 114 | (ac-selection-face ((t (:background ,highlight :foreground ,background)))) 115 | 116 | ;; Company 117 | (company-tooltip ((t (:background ,selection :foreground ,foreground)))) 118 | (company-tooltip-selection ((t (:background ,highlight :foreground ,background)))) 119 | 120 | ;; Elscreen 121 | (elscreen-tab-background-face ((t (:background ,background)))) 122 | (elscreen-tab-control-face ((t (:foreground ,foreground :background "black" 123 | :weight extra-bold)))) 124 | (elscreen-tab-current-screen-face ((t (:background "#250628" :foreground "Gray90" 125 | :bold t)))) 126 | (elscreen-tab-other-screen-face ((t (:background "#1D1D1F" :foreground "Gray85" 127 | :bold t)))) 128 | ;; Evil 129 | (evil-state-normal-face ((t :foreground ,purple :bold t))) 130 | (evil-state-insert-face ((t :foreground ,red :bold t))) 131 | (evil-state-visual-face ((t :foreground ,blue :bold t))) 132 | (evil-state-emacs-face ((t :foreground ,green :bold t))) 133 | 134 | ;; Flymake 135 | (flymake-warnline ((,class (:underline ,orange :background ,background)))) 136 | (flymake-errline ((,class (:underline ,red :background ,background)))) 137 | 138 | ;; Clojure errors 139 | (clojure-test-failure-face ((,class (:background nil :inherit flymake-warnline)))) 140 | (clojure-test-error-face ((,class (:background nil :inherit flymake-errline)))) 141 | (clojure-test-success-face ((,class (:background nil :foreground nil :underline ,green)))) 142 | 143 | ;; For Brian Carper's extended clojure syntax table 144 | (clojure-keyword ((,class (:foreground ,yellow)))) 145 | (clojure-parens ((,class (:foreground ,foreground)))) 146 | (clojure-braces ((,class (:foreground ,green)))) 147 | (clojure-brackets ((,class (:foreground ,yellow)))) 148 | (clojure-double-quote ((,class (:foreground ,aqua :background nil)))) 149 | (clojure-special ((,class (:foreground ,blue)))) 150 | (clojure-java-call ((,class (:foreground ,purple)))) 151 | 152 | ;; Rainbow-delimiters 153 | (rainbow-delimiters-depth-1-face ((,class (:foreground ,purple)))) 154 | (rainbow-delimiters-depth-2-face ((,class (:foreground ,blue)))) 155 | (rainbow-delimiters-depth-3-face ((,class (:foreground ,aqua)))) 156 | (rainbow-delimiters-depth-4-face ((,class (:foreground ,green)))) 157 | (rainbow-delimiters-depth-5-face ((,class (:foreground ,yellow)))) 158 | (rainbow-delimiters-depth-6-face ((,class (:foreground ,orange)))) 159 | (rainbow-delimiters-depth-7-face ((,class (:foreground ,red)))) 160 | (rainbow-delimiters-depth-8-face ((,class (:foreground ,comment)))) 161 | (rainbow-delimiters-depth-9-face ((,class (:foreground ,foreground)))) 162 | (rainbow-delimiters-unmatched-face ((,class (:foreground ,red)))) 163 | 164 | ;; MMM-mode 165 | (mmm-code-submode-face ((,class (:background ,current-line)))) 166 | (mmm-comment-submode-face ((,class (:inherit font-lock-comment-face)))) 167 | (mmm-output-submode-face ((,class (:background ,current-line)))) 168 | 169 | ;; Search 170 | (match ((,class (:foreground ,blue :background ,background :inverse-video t)))) 171 | (isearch ((,class (:foreground ,yellow :background ,background :inverse-video t)))) 172 | (isearch-lazy-highlight-face ((,class (:foreground ,aqua :background ,background :inverse-video t)))) 173 | (isearch-fail ((,class (:background ,background :inherit font-lock-warning-face :inverse-video t)))) 174 | 175 | ;; IDO 176 | (ido-first-match ((,class (:foreground ,yellow :weight bold)))) 177 | (ido-only-match ((,class (:foreground ,orange :weight bold)))) 178 | (ido-virtual ((,class (:foreground ,comment)))) 179 | (ido-incomplete-regexp ((,class (:foreground ,red :bold t)))) 180 | (ido-subdir ((,class (:foreground ,aqua :bold t)))) 181 | (ido-virtual ((,class (:foreground ,purple)))) 182 | 183 | ;; which-function 184 | (which-func ((,class (:foreground ,blue :background nil :weight bold)))) 185 | 186 | ;; Emacs interface 187 | (cursor ((,class (:background ,cursor)))) 188 | (fringe ((,class (:background ,current-line)))) 189 | (linum ((,class (:foreground ,cursor :background ,background)))) 190 | (hl-line ((,class (:background ,selection)))) 191 | ;; (border ((,class (:background ,current-line)))) 192 | ;; (border-glyph ((,class (nil)))) 193 | (highlight ((,class (:foreground ,current-line :background ,green)))) 194 | (link ((,class (:foreground ,blue)))) 195 | (link-visited ((,class (:foreground ,purple)))) 196 | (gui-element ((,class (:background ,current-line :foreground ,foreground)))) 197 | 198 | ;; mode-line 199 | (mode-line ((,class (:background ,background :foreground "#b1c3d4" 200 | :box (:line-width 2 :color "#B184CB"))))) 201 | (mode-line-inactive ((,class (:background ,current-line :foreground "#7b8793" 202 | :box (:line-width 2 :color "#565968"))))) 203 | (mode-line-buffer-id ((,class (:foreground ,foreground :background nil)))) 204 | (mode-line-emphasis ((,class (:foreground ,foreground :slant italic)))) 205 | (mode-line-highlight ((,class (:foreground ,purple :box nil :weight bold)))) 206 | 207 | (minibuffer-prompt ((,class (:foreground ,red :bold t)))) 208 | (region ((,class (:background ,selection)))) 209 | (secondary-selection ((,class (:background ,current-line)))) 210 | 211 | ;; (header-line ((,class (:inherit mode-line :foreground ,purple :background nil)))) 212 | 213 | (trailing-whitespace ((,class (:background ,red :foreground ,yellow)))) 214 | (whitespace-empty ((,class (:foreground ,red :background ,yellow)))) 215 | (whitespace-hspace ((,class (:background ,selection :foreground ,comment)))) 216 | (whitespace-indentation ((,class (:background ,yellow :foreground ,red)))) 217 | (whitespace-line ((,class (:background ,current-line :foreground ,purple)))) 218 | (whitespace-newline ((,class (:foreground ,comment)))) 219 | (whitespace-space ((,class (:background ,current-line :foreground ,comment)))) 220 | (whitespace-space-after-tab ((,class (:background ,yellow :foreground ,red)))) 221 | (whitespace-space-before-tab ((,class (:background ,orange :foreground ,red)))) 222 | (whitespace-tab ((,class (:background ,selection :foreground ,comment)))) 223 | (whitespace-trailing ((,class (:background ,red :foreground ,yellow)))) 224 | 225 | ;; Parenthesis matching (built-in) 226 | (show-paren-match ((,class (:background ,blue :foreground ,current-line)))) 227 | (show-paren-mismatch ((,class (:background ,orange :foreground ,current-line)))) 228 | 229 | ;; Parenthesis matching (mic-paren) 230 | (paren-face-match ((,class (:foreground nil :background nil :inherit show-paren-match)))) 231 | (paren-face-mismatch ((,class (:foreground nil :background nil :inherit show-paren-mismatch)))) 232 | (paren-face-no-match ((,class (:foreground nil :background nil :inherit show-paren-mismatch)))) 233 | 234 | ;; Parenthesis dimming (parenface) 235 | (paren-face ((,class (:foreground ,comment :background nil)))) 236 | 237 | (sh-heredoc ((,class (:foreground nil :inherit font-lock-string-face :weight normal)))) 238 | (sh-quoted-exec ((,class (:foreground nil :inherit font-lock-preprocessor-face)))) 239 | (slime-highlight-edits-face ((,class (:weight bold)))) 240 | (slime-repl-input-face ((,class (:weight normal :underline nil)))) 241 | (slime-repl-prompt-face ((,class (:underline nil :weight bold :foreground ,purple)))) 242 | (slime-repl-result-face ((,class (:foreground ,green)))) 243 | (slime-repl-output-face ((,class (:foreground ,blue :background ,background)))) 244 | 245 | (csv-separator-face ((,class (:foreground ,orange)))) 246 | 247 | (diff-added ((,class (:foreground ,green)))) 248 | (diff-changed ((,class (:foreground ,yellow)))) 249 | (diff-removed ((,class (:foreground ,red)))) 250 | (diff-header ((,class (:background ,current-line)))) 251 | (diff-file-header ((,class (:background ,selection)))) 252 | (diff-hunk-header ((,class (:foreground ,yellow :italic t)))) 253 | (diff-context ((,class (:foreground ,foreground)))) 254 | 255 | (ediff-even-diff-A ((,class (:foreground nil :background nil :inverse-video t)))) 256 | (ediff-even-diff-B ((,class (:foreground nil :background nil :inverse-video t)))) 257 | (ediff-odd-diff-A ((,class (:foreground ,comment :background nil :inverse-video t)))) 258 | (ediff-odd-diff-B ((,class (:foreground ,comment :background nil :inverse-video t)))) 259 | 260 | (eldoc-highlight-function-argument ((,class (:foreground ,green :weight bold)))) 261 | 262 | ;; undo-tree 263 | (undo-tree-visualizer-default-face ((,class (:foreground ,foreground)))) 264 | (undo-tree-visualizer-current-face ((,class (:foreground ,green :weight bold)))) 265 | (undo-tree-visualizer-active-branch-face ((,class (:foreground ,red)))) 266 | (undo-tree-visualizer-register-face ((,class (:foreground ,yellow)))) 267 | 268 | ;; auctex 269 | (font-latex-bold-face ((,class (:foreground ,green)))) 270 | (font-latex-doctex-documentation-face ((,class (:background ,current-line)))) 271 | (font-latex-italic-face ((,class (:foreground ,green)))) 272 | (font-latex-math-face ((,class (:foreground ,orange)))) 273 | (font-latex-sectioning-0-face ((,class (:foreground ,yellow)))) 274 | (font-latex-sectioning-1-face ((,class (:foreground ,yellow)))) 275 | (font-latex-sectioning-2-face ((,class (:foreground ,yellow)))) 276 | (font-latex-sectioning-3-face ((,class (:foreground ,yellow)))) 277 | (font-latex-sectioning-4-face ((,class (:foreground ,yellow)))) 278 | (font-latex-sectioning-5-face ((,class (:foreground ,yellow)))) 279 | (font-latex-sedate-face ((,class (:foreground ,aqua)))) 280 | (font-latex-string-face ((,class (:foreground ,yellow)))) 281 | (font-latex-verbatim-face ((,class (:foreground ,orange)))) 282 | (font-latex-warning-face ((,class (:foreground ,red)))) 283 | 284 | ;; dired+ 285 | (diredp-compressed-file-suffix ((,class (:foreground ,blue)))) 286 | (diredp-dir-heading ((,class (:foreground nil :background nil :inherit heading)))) 287 | (diredp-dir-priv ((,class (:foreground ,aqua :background nil)))) 288 | (diredp-exec-priv ((,class (:foreground ,blue :background nil)))) 289 | (diredp-executable-tag ((,class (:foreground ,red :background nil)))) 290 | (diredp-file-name ((,class (:foreground ,yellow)))) 291 | (diredp-file-suffix ((,class (:foreground ,green)))) 292 | (diredp-flag-mark-line ((,class (:background nil :inherit highlight)))) 293 | (diredp-ignored-file-name ((,class (:foreground ,comment)))) 294 | (diredp-link-priv ((,class (:background nil :foreground ,purple)))) 295 | (diredp-mode-line-flagged ((,class (:foreground ,red)))) 296 | (diredp-mode-line-marked ((,class (:foreground ,green)))) 297 | (diredp-no-priv ((,class (:background nil)))) 298 | (diredp-number ((,class (:foreground ,yellow)))) 299 | (diredp-other-priv ((,class (:background nil :foreground ,purple)))) 300 | (diredp-rare-priv ((,class (:foreground ,red :background nil)))) 301 | (diredp-read-priv ((,class (:foreground ,green :background nil)))) 302 | (diredp-symlink ((,class (:foreground ,purple)))) 303 | (diredp-write-priv ((,class (:foreground ,yellow :background nil)))) 304 | 305 | ;; Magit 306 | (magit-branch ((,class (:foreground ,green)))) 307 | (magit-header ((,class (:inherit nil :weight bold)))) 308 | (magit-item-highlight ((,class (:background ,background)))) 309 | (magit-log-graph ((,class (:foreground ,comment)))) 310 | (magit-log-sha1 ((,class (:foreground ,orange)))) 311 | (magit-log-head-label-bisect-bad ((,class (:foreground ,red)))) 312 | (magit-log-head-label-bisect-good ((,class (:foreground ,green)))) 313 | (magit-log-head-label-default ((,class (:foreground ,yellow :box nil :weight bold)))) 314 | (magit-log-head-label-local ((,class (:foreground ,blue)))) 315 | (magit-log-head-label-remote ((,class (:foreground ,green)))) 316 | (magit-log-head-label-tags ((,class (:foreground ,aqua :box nil :weight bold)))) 317 | (magit-section-title ((,class (:inherit diff-hunk-header)))) 318 | 319 | ;; git-gutter 320 | (git-gutter-fr:modified ((,class (:foreground ,yellow)))) 321 | (git-gutter-fr:added ((,class (:inherit diff-added)))) 322 | (git-gutter-fr:deleted ((,class (:inherit diff-removed)))) 323 | 324 | (link ((t (:foreground "dodger blue" :underline t)))) 325 | (widget-button ((,class (:underline t)))) 326 | (widget-field ((,class (:background ,current-line :box (:line-width 1 :color ,foreground))))) 327 | 328 | ;; Compilation (most faces politely inherit from 'success, 'error, 'warning etc.) 329 | (compilation-column-number ((,class (:foreground ,yellow)))) 330 | (compilation-line-number ((,class (:foreground ,yellow)))) 331 | (compilation-message-face ((,class (:foreground ,blue)))) 332 | (compilation-mode-line-exit ((,class (:foreground ,green)))) 333 | (compilation-mode-line-fail ((,class (:foreground ,red)))) 334 | (compilation-mode-line-run ((,class (:foreground ,blue)))) 335 | 336 | ;; Grep 337 | (grep-context-face ((,class (:foreground ,comment)))) 338 | (grep-error-face ((,class (:foreground ,red :weight bold :underline t)))) 339 | (grep-hit-face ((,class (:foreground ,blue)))) 340 | (grep-match-face ((,class (:foreground nil :background nil :inherit match)))) 341 | 342 | (regex-tool-matched-face ((,class (:foreground nil :background nil :inherit match)))) 343 | 344 | ;; mark-multiple 345 | (mm/master-face ((,class (:inherit region :foreground nil :background nil)))) 346 | (mm/mirror-face ((,class (:inherit region :foreground nil :background nil)))) 347 | 348 | (org-agenda-structure ((,class (:foreground ,purple)))) 349 | (org-agenda-date ((,class (:foreground ,blue :underline nil)))) 350 | (org-agenda-done ((,class (:foreground ,green)))) 351 | (org-agenda-dimmed-todo-face ((,class (:foreground ,comment)))) 352 | (org-block ((,class (:foreground ,yellow)))) 353 | (org-code ((,class (:foreground ,yellow)))) 354 | (org-column ((,class (:background ,current-line)))) 355 | (org-column-title ((,class (:inherit org-column :weight bold :underline t)))) 356 | (org-date ((,class (:foreground ,purple :underline t :bold t)))) 357 | (org-agenda-date-weekend ((t (:bold t :foreground ,orange :weight bold)))) 358 | (org-document-info ((,class (:foreground ,aqua)))) 359 | (org-document-info-keyword ((,class (:foreground ,green)))) 360 | (org-document-title ((,class (:weight bold :foreground ,orange :height 1.44)))) 361 | (org-ellipsis ((,class (:foreground ,comment)))) 362 | (org-footnote ((,class (:foreground ,aqua)))) 363 | (org-formula ((,class (:foreground ,red)))) 364 | ;;(org-hide ((,class (:foreground ,current-line)))) 365 | (org-hide ((t (:foreground "#0B0B0E")))) 366 | (org-scheduled ((,class (:foreground ,green)))) 367 | (org-scheduled-previously ((,class (:foreground ,orange)))) 368 | (org-scheduled-today ((,class (:foreground ,green)))) 369 | (org-special-keyword ((,class (:foreground ,orange)))) 370 | ;;(org-table ((,class (:foreground ,purple)))) 371 | (org-todo ((,class (:foreground ,red :bold t)))) 372 | (org-done ((t (:foreground "#4BC98A" :bold t)))) 373 | (org-link ((t (:inherit link)))) 374 | (org-upcoming-deadline ((,class (:foreground ,orange)))) 375 | (org-warning ((,class (:weight bold :foreground ,red)))) 376 | (org-level-1 ((t (:foreground "#8AC6F2" :bold t)))) 377 | (org-level-2 ((t (:foreground "#ee9a49")))) 378 | (org-level-3 ((t (:foreground "#ff83fa")))) 379 | (org-level-4 ((t (:foreground "#efe500")))) 380 | (org-level-5 ((t (:foreground "#ff4040")))) 381 | (org-level-6 ((t (:foreground "#afe04e")))) 382 | (org-level-7 ((t (:foreground "#0A4C64")))) 383 | 384 | 385 | (markdown-url-face ((,class (:inherit link)))) 386 | (markdown-link-face ((,class (:foreground ,blue :underline t)))) 387 | 388 | (hl-sexp-face ((,class (:background ,current-line)))) 389 | (highlight-80+ ((,class (:background ,current-line)))) 390 | 391 | ;; Python-specific overrides 392 | (py-builtins-face ((,class (:foreground ,orange :weight normal)))) 393 | 394 | ;; js2-mode 395 | (js2-warning-face ((,class (:underline ,orange)))) 396 | (js2-error-face ((,class (:foreground nil :underline ,red)))) 397 | (js2-external-variable-face ((,class (:foreground ,purple)))) 398 | (js2-function-param-face ((,class (:foreground ,blue)))) 399 | (js2-instance-member-face ((,class (:foreground ,blue)))) 400 | (js2-private-function-call-face ((,class (:foreground ,red)))) 401 | 402 | ;; js3-mode 403 | (js3-warning-face ((,class (:underline ,orange)))) 404 | (js3-error-face ((,class (:foreground nil :underline ,red)))) 405 | (js3-external-variable-face ((,class (:foreground ,purple)))) 406 | (js3-function-param-face ((,class (:foreground ,blue)))) 407 | (js3-jsdoc-tag-face ((,class (:foreground ,orange)))) 408 | (js3-jsdoc-type-face ((,class (:foreground ,aqua)))) 409 | (js3-jsdoc-value-face ((,class (:foreground ,yellow)))) 410 | (js3-jsdoc-html-tag-name-face ((,class (:foreground ,blue)))) 411 | (js3-jsdoc-html-tag-delimiter-face ((,class (:foreground ,green)))) 412 | (js3-instance-member-face ((,class (:foreground ,blue)))) 413 | (js3-private-function-call-face ((,class (:foreground ,red)))) 414 | 415 | ;; nxml 416 | (nxml-name-face ((,class (:foreground unspecified :inherit font-lock-constant-face)))) 417 | (nxml-attribute-local-name-face ((,class (:foreground unspecified :inherit font-lock-variable-name-face)))) 418 | (nxml-ref-face ((,class (:foreground unspecified :inherit font-lock-preprocessor-face)))) 419 | (nxml-delimiter-face ((,class (:foreground unspecified :inherit font-lock-keyword-face)))) 420 | (nxml-delimited-data-face ((,class (:foreground unspecified :inherit font-lock-string-face)))) 421 | (rng-error-face ((,class (:underline ,red)))) 422 | 423 | ;; RHTML 424 | (erb-delim-face ((,class (:background ,current-line)))) 425 | (erb-exec-face ((,class (:background ,current-line :weight bold)))) 426 | (erb-exec-delim-face ((,class (:background ,current-line)))) 427 | (erb-out-face ((,class (:background ,current-line :weight bold)))) 428 | (erb-out-delim-face ((,class (:background ,current-line)))) 429 | (erb-comment-face ((,class (:background ,current-line :weight bold :slant italic)))) 430 | (erb-comment-delim-face ((,class (:background ,current-line)))) 431 | 432 | ;; Message-mode 433 | (message-header-other ((,class (:foreground nil :background nil :weight normal)))) 434 | (message-header-subject ((,class (:inherit message-header-other :weight bold :foreground ,yellow)))) 435 | (message-header-to ((,class (:inherit message-header-other :weight bold :foreground ,orange)))) 436 | (message-header-cc ((,class (:inherit message-header-to :foreground nil)))) 437 | (message-header-name ((,class (:foreground ,blue :background nil)))) 438 | (message-header-newsgroups ((,class (:foreground ,aqua :background nil :slant normal)))) 439 | (message-separator ((,class (:foreground ,purple)))) 440 | 441 | ;; Jabber 442 | (jabber-chat-prompt-local ((,class (:foreground ,yellow)))) 443 | (jabber-chat-prompt-foreign ((,class (:foreground ,orange)))) 444 | (jabber-chat-prompt-system ((,class (:foreground ,yellow :weight bold)))) 445 | (jabber-chat-text-local ((,class (:foreground ,yellow)))) 446 | (jabber-chat-text-foreign ((,class (:foreground ,orange)))) 447 | (jabber-chat-text-error ((,class (:foreground ,red)))) 448 | 449 | (jabber-roster-user-online ((,class (:foreground ,green)))) 450 | (jabber-roster-user-xa ((,class :foreground ,comment))) 451 | (jabber-roster-user-dnd ((,class :foreground ,yellow))) 452 | (jabber-roster-user-away ((,class (:foreground ,orange)))) 453 | (jabber-roster-user-chatty ((,class (:foreground ,purple)))) 454 | (jabber-roster-user-error ((,class (:foreground ,red)))) 455 | (jabber-roster-user-offline ((,class (:foreground ,comment)))) 456 | 457 | (jabber-rare-time-face ((,class (:foreground ,comment)))) 458 | (jabber-activity-face ((,class (:foreground ,purple)))) 459 | (jabber-activity-personal-face ((,class (:foreground ,aqua)))) 460 | 461 | ;; Gnus 462 | (gnus-cite-1 ((,class (:inherit outline-1 :foreground nil)))) 463 | (gnus-cite-2 ((,class (:inherit outline-2 :foreground nil)))) 464 | (gnus-cite-3 ((,class (:inherit outline-3 :foreground nil)))) 465 | (gnus-cite-4 ((,class (:inherit outline-4 :foreground nil)))) 466 | (gnus-cite-5 ((,class (:inherit outline-5 :foreground nil)))) 467 | (gnus-cite-6 ((,class (:inherit outline-6 :foreground nil)))) 468 | (gnus-cite-7 ((,class (:inherit outline-7 :foreground nil)))) 469 | (gnus-cite-8 ((,class (:inherit outline-8 :foreground nil)))) 470 | ;; there are several more -cite- faces... 471 | (gnus-header-content ((,class (:inherit message-header-other)))) 472 | (gnus-header-subject ((,class (:inherit message-header-subject)))) 473 | (gnus-header-from ((,class (:inherit message-header-other-face :weight bold :foreground ,orange)))) 474 | 475 | (gnus-header-name ((,class (:inherit message-header-name)))) 476 | (gnus-button ((,class (:inherit link :foreground nil)))) 477 | (gnus-signature ((,class (:inherit font-lock-comment-face)))) 478 | 479 | (gnus-summary-normal-unread ((,class (:foreground ,blue :weight normal)))) 480 | (gnus-summary-normal-read ((,class (:foreground ,foreground :weight normal)))) 481 | (gnus-summary-normal-ancient ((,class (:foreground ,aqua :weight normal)))) 482 | (gnus-summary-normal-ticked ((,class (:foreground ,orange :weight normal)))) 483 | (gnus-summary-low-unread ((,class (:foreground ,comment :weight normal)))) 484 | (gnus-summary-low-read ((,class (:foreground ,comment :weight normal)))) 485 | (gnus-summary-low-ancient ((,class (:foreground ,comment :weight normal)))) 486 | (gnus-summary-high-unread ((,class (:foreground ,yellow :weight normal)))) 487 | (gnus-summary-high-read ((,class (:foreground ,green :weight normal)))) 488 | (gnus-summary-high-ancient ((,class (:foreground ,green :weight normal)))) 489 | (gnus-summary-high-ticked ((,class (:foreground ,orange :weight normal)))) 490 | (gnus-summary-cancelled ((,class (:foreground ,red :background nil :weight normal)))) 491 | 492 | (gnus-group-mail-low ((,class (:foreground ,comment)))) 493 | (gnus-group-mail-low-empty ((,class (:foreground ,comment)))) 494 | (gnus-group-mail-1 ((,class (:foreground nil :weight normal :inherit outline-1)))) 495 | (gnus-group-mail-2 ((,class (:foreground nil :weight normal :inherit outline-2)))) 496 | (gnus-group-mail-3 ((,class (:foreground nil :weight normal :inherit outline-3)))) 497 | (gnus-group-mail-4 ((,class (:foreground nil :weight normal :inherit outline-4)))) 498 | (gnus-group-mail-5 ((,class (:foreground nil :weight normal :inherit outline-5)))) 499 | (gnus-group-mail-6 ((,class (:foreground nil :weight normal :inherit outline-6)))) 500 | (gnus-group-mail-1-empty ((,class (:inherit gnus-group-mail-1 :foreground ,comment)))) 501 | (gnus-group-mail-2-empty ((,class (:inherit gnus-group-mail-2 :foreground ,comment)))) 502 | (gnus-group-mail-3-empty ((,class (:inherit gnus-group-mail-3 :foreground ,comment)))) 503 | (gnus-group-mail-4-empty ((,class (:inherit gnus-group-mail-4 :foreground ,comment)))) 504 | (gnus-group-mail-5-empty ((,class (:inherit gnus-group-mail-5 :foreground ,comment)))) 505 | (gnus-group-mail-6-empty ((,class (:inherit gnus-group-mail-6 :foreground ,comment)))) 506 | (gnus-group-news-1 ((,class (:foreground nil :weight normal :inherit outline-5)))) 507 | (gnus-group-news-2 ((,class (:foreground nil :weight normal :inherit outline-6)))) 508 | (gnus-group-news-3 ((,class (:foreground nil :weight normal :inherit outline-7)))) 509 | (gnus-group-news-4 ((,class (:foreground nil :weight normal :inherit outline-8)))) 510 | (gnus-group-news-5 ((,class (:foreground nil :weight normal :inherit outline-1)))) 511 | (gnus-group-news-6 ((,class (:foreground nil :weight normal :inherit outline-2)))) 512 | (gnus-group-news-1-empty ((,class (:inherit gnus-group-news-1 :foreground ,comment)))) 513 | (gnus-group-news-2-empty ((,class (:inherit gnus-group-news-2 :foreground ,comment)))) 514 | (gnus-group-news-3-empty ((,class (:inherit gnus-group-news-3 :foreground ,comment)))) 515 | (gnus-group-news-4-empty ((,class (:inherit gnus-group-news-4 :foreground ,comment)))) 516 | (gnus-group-news-5-empty ((,class (:inherit gnus-group-news-5 :foreground ,comment)))) 517 | (gnus-group-news-6-empty ((,class (:inherit gnus-group-news-6 :foreground ,comment)))) 518 | 519 | ;; erc 520 | (erc-direct-msg-face ((,class (:foreground ,orange)))) 521 | (erc-error-face ((,class (:foreground ,red)))) 522 | (erc-header-face ((,class (:foreground ,foreground :background ,selection)))) 523 | (erc-input-face ((,class (:foreground ,green)))) 524 | (erc-keyword-face ((,class (:foreground ,yellow)))) 525 | (erc-current-nick-face ((,class (:foreground ,green)))) 526 | (erc-my-nick-face ((,class (:foreground ,green)))) 527 | (erc-nick-default-face ((,class (:weight normal :foreground ,purple)))) 528 | (erc-nick-msg-face ((,class (:weight normal :foreground ,yellow)))) 529 | (erc-notice-face ((,class (:foreground ,comment)))) 530 | (erc-pal-face ((,class (:foreground ,orange)))) 531 | (erc-prompt-face ((,class (:foreground ,blue)))) 532 | (erc-timestamp-face ((,class (:foreground ,aqua)))) 533 | 534 | ;; woman 535 | (woman-italic-face ((t (:slant italic :weight bold)))) 536 | (woman-unknown ((t (:foreground ,red :weight bold)))) 537 | (woman-addition ((t (:foreground ,aqua)))) 538 | (woman-bold ((t (:inherit bold :foreground ,blue)))) 539 | 540 | ;; smartparens-mode 541 | (sp-pair-overlay-face ((t (:forground ,foreground :background ,current-line)))) 542 | 543 | (custom-variable-tag ((,class (:foreground ,blue)))) 544 | (custom-group-tag ((,class (:foreground ,blue)))) 545 | (custom-state ((,class (:foreground ,green)))) 546 | 547 | ))) 548 | 549 | (defun coldnew-theme--theme-name (mode) 550 | (intern (format "coldnew-theme-%s" (symbol-name mode)))) 551 | 552 | (defmacro coldnew-theme--define-theme (mode) 553 | "Define a theme for the coldnew variant `MODE'." 554 | (let ((name (coldnew-theme--theme-name mode)) 555 | (doc (format "coldnew's personal color theme (%s version)" mode))) 556 | `(progn 557 | (deftheme ,name ,doc) 558 | (put ',name 'theme-immediate t) 559 | (message (format "%s : %s" (symbol-name ',name) ,doc)) 560 | (coldnew-theme--with-colors 561 | ',mode 562 | (apply 'custom-theme-set-faces ',name 563 | (coldnew-theme--face-specs)) 564 | (custom-theme-set-variables 565 | ',name 566 | ;; `(fci-rule-color ,current-line) 567 | `(ansi-color-names-vector (vector ,foreground ,red ,green ,yellow ,blue ,purple ,aqua ,background)) 568 | '(ansi-color-faces-vector [default bold shadow italic underline bold bold-italic bold]))) 569 | (provide-theme ',name)))) 570 | 571 | (defun coldnew-theme--load-theme (mode) 572 | (if (fboundp 'load-theme) 573 | (let ((name (coldnew-theme--theme-name mode))) 574 | (if (> emacs-major-version 23) 575 | (load-theme name t) 576 | (load-theme name))) 577 | ;; not support for older emace. 578 | (error "emacs should support load-theme to make coldnew-theme work."))) 579 | 580 | ;;;; Mode-line 581 | 582 | (defun coldnew/mode-line-prepare-left () 583 | (let* ((active (powerline-selected-window-active)) 584 | (mode-line (if active 'mode-line 'mode-line-inactive)) 585 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 586 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 587 | (separator-left (intern (format "powerline-%s-%s" 588 | powerline-default-separator 589 | (car powerline-default-separator-dir)))) 590 | (separator-right (intern (format "powerline-%s-%s" 591 | powerline-default-separator 592 | (cdr powerline-default-separator-dir))))) 593 | (append 594 | ;; Evil-state indicator 595 | (let ((evil-face (powerline-evil-face))) 596 | (append (if evil-mode 597 | (list (funcall separator-right face2 evil-face) 598 | (powerline-raw " " evil-face) 599 | (powerline-raw (powerline-evil-tag) evil-face 'l) 600 | (powerline-raw " " evil-face) 601 | (funcall separator-left evil-face mode-line))) 602 | 603 | (list (powerline-minor-modes face2 'l) 604 | (powerline-raw " " face2) 605 | (funcall separator-right face2 face1))) 606 | (list (powerline-raw (powerline-evil-tag) evil-face) 607 | (funcall separator-left evil-face mode-line))) 608 | (list 609 | ;; Buffer state indicator 610 | (cond (buffer-read-only 611 | (propertize "RO" 'face 'mode-line-read-only-face)) 612 | ((buffer-modified-p) 613 | (propertize "**" 'face 'mode-line-modified-face)) 614 | (t "--")) 615 | 616 | (powerline-buffer-id nil 'l) 617 | (powerline-raw " ") 618 | (funcall separator-left mode-line face1) 619 | 620 | ;; major mode 621 | (funcall separator-left face1 mode-line ) 622 | (powerline-raw " " mode-line) 623 | (powerline-major-mode mode-line 'l) 624 | (powerline-raw " " mode-line) 625 | (funcall separator-left mode-line face1) 626 | 627 | ;; VC 628 | (powerline-vc face1) 629 | (powerline-raw " " face1 '1) 630 | (funcall separator-left face1 face2) 631 | )))) 632 | 633 | 634 | (defun coldnew/mode-line-prepare-right () 635 | (let* ((active (powerline-selected-window-active)) 636 | (mode-line (if active 'mode-line 'mode-line-inactive)) 637 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 638 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 639 | (separator-left (intern (format "powerline-%s-%s" 640 | powerline-default-separator 641 | (car powerline-default-separator-dir)))) 642 | (separator-right (intern (format "powerline-%s-%s" 643 | powerline-default-separator 644 | (cdr powerline-default-separator-dir))))) 645 | (append 646 | (list 647 | (powerline-process face2) 648 | (funcall separator-right face2 face1) 649 | (when (boundp 'erc-modified-channels-object) 650 | (powerline-raw erc-modified-channels-object face2 'l)) 651 | (powerline-raw "%4l" face1 'r) 652 | (powerline-raw ":" face1) 653 | (powerline-raw "%3c" face1 'r) 654 | (funcall separator-right face1 mode-line) 655 | (powerline-raw " ") 656 | (powerline-raw "%6p" nil 'r) 657 | (powerline-buffer-size nil 'r) 658 | (powerline-hud face2 face1)) 659 | ))) 660 | 661 | (defun coldnew/mode-line-prepare () 662 | (let* ((active (powerline-selected-window-active)) 663 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 664 | (lhs (coldnew/mode-line-prepare-left)) 665 | (rhs (coldnew/mode-line-prepare-right))) 666 | (concat (powerline-render lhs) 667 | (powerline-fill face2 (powerline-width rhs)) 668 | (powerline-render rhs)))) 669 | 670 | ;; Setup my mode-line 671 | 672 | (setq powerline-default-separator 'arrow) 673 | 674 | (setq mode-line-format 675 | '("%e" (:eval (coldnew/mode-line-prepare)))) 676 | 677 | (defun spacemacs/mode-line-prepare () 678 | "Overwrite spacemacs's mode-line-prepare so I can use my own modeline." 679 | (coldnew/mode-line-prepare)) 680 | 681 | ;;;###autoload 682 | (when (boundp 'custom-theme-load-path) 683 | (add-to-list 'custom-theme-load-path 684 | (file-name-as-directory (file-name-directory (or load-file-name (buffer-file-name)))))) 685 | 686 | ;;;###autoload 687 | (defun coldnew-theme-night () 688 | (interactive) 689 | (coldnew-theme--load-theme 'night)) 690 | 691 | ;;;###autoload 692 | (defun coldnew-theme-day () 693 | (interactive) 694 | (coldnew-theme--load-theme 'day)) 695 | 696 | ;; (provide 'coldnew-theme) 697 | 698 | ;; Local Variables: 699 | ;; byte-compile-warnings: (not cl-functions) 700 | ;; End: 701 | 702 | ;;; coldnew-theme.el ends here 703 | -------------------------------------------------------------------------------- /theme/coldnew-theme.el: -------------------------------------------------------------------------------- 1 | ;;; coldnew-theme.el --- coldnew's emacs color-theme. 2 | ;; 3 | ;; Copyright (C) 2011-2015 Yen-Chin, Lee 4 | ;; Author: coldnew 5 | ;; Kyewords: themes 6 | ;; Version: 0.1 7 | ;; X-Original-Version: 0.1 8 | ;; Package-Requires: ((emacs "24.1")) 9 | 10 | ;; This file is free software: you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation, either version 3 of the License, or 13 | ;; (at your option) any later version. 14 | 15 | ;; This file is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with GNU Emacs. If not, see . 22 | 23 | ;;; Commentary: 24 | ;; 25 | ;; This theme is based on following theme file: 26 | ;; https://github.com/bbatsov/solarized-emacs 27 | ;; https://github.com/sjrmanning/noctilux-theme 28 | ;; https://github.com/cpaulik/emacs-material-theme 29 | ;; 30 | ;; 31 | ;; 256-color charts 32 | ;; http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html 33 | 34 | ;;; Code: 35 | 36 | (require 'noflet) 37 | 38 | ;; NOTE: 39 | ;; This vairable is filled by other file. 40 | (defvar coldnew-theme-colors 41 | '( ) 42 | "This is a table of all the colors used by the coldnew color 43 | theme. Each column is a different set, one of which will be 44 | chosen based on term capabilities, etc.") 45 | 46 | (defun coldnew-theme--build-colors-alist (mode) 47 | ;; (mapcar (lambda (x) (list (symbol-name (car x)) (nth 1 (cdr x)))) 48 | (noflet ((find-color (color) 49 | ;; 1: window system , 2: terminal 50 | (let* ((index (if window-system 1 2))) 51 | (nth index color)))) 52 | (mapcar (lambda (x) (list (symbol-name (car x)) (find-color x))) 53 | (cdr (assoc (cadr `,mode) coldnew-theme-colors))))) 54 | 55 | (defmacro coldnew-theme--with-colors (mode &rest body) 56 | "`let' bind all colors defined in `coldnew-theme-colors' around BODY. 57 | Also bind `class' to ((class color) (min-colors 89))." 58 | (declare (indent 0)) 59 | `(let ((class '((class color) (min-colors 89))) 60 | ,@(mapcar (lambda (cons) 61 | (list (intern (car cons)) (cadr cons))) 62 | (coldnew-theme--build-colors-alist mode))) 63 | ,@body)) 64 | 65 | (defmacro coldnew-theme--face-specs () 66 | (quote 67 | `(;; Ensure sufficient contrast on low-color terminals. 68 | (default ((((class color) (min-colors 4096)) 69 | (:foreground ,foreground :background ,background)) 70 | (((class color) (min-colors 256)) 71 | (:foreground ,foreground :background ,background)) 72 | (,class 73 | (:foreground ,foreground :background ,background)))) 74 | ;; Basic 75 | (bold ((t (:weight bold)))) 76 | (bold-italic ((t (:weight bold :slant italic)))) 77 | (cursor ((t (:foreground ,base0 :background ,white)))) 78 | (error ((t (:foreground ,red :bold t)))) 79 | (italic ((t (:slant italic)))) 80 | (shadow ((t (:foreground ,comment)))) 81 | (success ((t (:foreground ,green)))) 82 | (underline ((t (:underline t)))) 83 | (warning ((t (:foreground ,orange)))) 84 | 85 | ;; font-lock 86 | (font-lock-builtin-face ((t (:foreground ,buildin)))) 87 | (font-lock-constant-face ((t (:foreground ,magenta)))) 88 | (font-lock-comment-face ((t (:foreground ,comment :slant italic)))) 89 | (font-lock-comment-delimiter-face ((t (:foreground ,comment-delimiter :slant italic)))) 90 | (font-lock-doc-face ((t (:foreground ,doc :slant italic)))) 91 | (font-lock-function-name-face ((t (:foreground ,function-name)))) 92 | (font-lock-keyword-face ((t (:foreground ,keyword)))) 93 | (font-lock-type-face ((t (:foreground ,type)))) 94 | (font-lock-variable-name-face ((t (:foreground ,variable-name)))) 95 | (font-lock-string-face ((t (:foreground ,string)))) 96 | 97 | (font-lock-exit-face ((t (:foreground ,red)))) 98 | (font-lock-negation-char-face ((t (:foreground ,red)))) 99 | (font-lock-other-emphasized-face ((t (:foreground ,magenta :weight bold)))) 100 | (font-lock-other-type-face ((t (:foreground ,blue :slant italic)))) 101 | (font-lock-preprocessor-face ((t (:foreground ,orange)))) 102 | (font-lock-reference-face ((t (:foreground ,cyan)))) 103 | (font-lock-regexp-grouping-backslash ((t (:foreground ,yellow)))) 104 | (font-lock-regexp-grouping-construct ((t (:foreground ,orange)))) 105 | (font-lock-special-keyword-face ((t (:foreground ,red)))) 106 | (font-lock-warning-face ((t (:foreground ,red :weight bold)))) 107 | 108 | ;; rainbow-delimiters 109 | (rainbow-delimiters-depth-1-face ((t (:foreground ,rainbow-1)))) 110 | (rainbow-delimiters-depth-2-face ((t (:foreground ,rainbow-2)))) 111 | (rainbow-delimiters-depth-3-face ((t (:foreground ,rainbow-3)))) 112 | (rainbow-delimiters-depth-4-face ((t (:foreground ,rainbow-4)))) 113 | (rainbow-delimiters-depth-5-face ((t (:foreground ,rainbow-5)))) 114 | (rainbow-delimiters-depth-6-face ((t (:foreground ,rainbow-6)))) 115 | (rainbow-delimiters-depth-7-face ((t (:foreground ,rainbow-7)))) 116 | (rainbow-delimiters-depth-8-face ((t (:foreground ,rainbow-8)))) 117 | (rainbow-delimiters-depth-9-face ((t (:foreground ,rainbow-9)))) 118 | (rainbow-delimiters-unmatched-face ((t (:inherit error)))) 119 | 120 | ;; link 121 | (link ((t (:foreground ,magenta :underline t)))) 122 | 123 | ;; region 124 | (region ((,class (:background ,selection)))) 125 | 126 | ;; minibuffer 127 | (minibuffer-prompt ((t (:foreground ,cyan :weight bold)))) 128 | 129 | ;; modeline 130 | (mode-line ((t (:foreground ,base0 :background ,base02 :weight bold :box nil)))) 131 | (mode-line-inactive ((t (:foreground ,base01 :background ,base03 :weight bold :box nil)))) 132 | 133 | ;; comint 134 | (comint-highlight-prompt ((t (:foreground ,blue)))) 135 | 136 | ;; compilation 137 | (compilation-info ((t (:foreground ,green :weight bold)))) 138 | (compilation-warning ((t (:foreground ,orange :weight bold)))) 139 | 140 | ;; smartparens-mode 141 | (sp-pair-overlay-face ((t (:forground ,foreground :background ,current-line)))) 142 | 143 | ;; custom 144 | (custom-button 145 | ((t (:foreground ,base1 :background ,base02 146 | :box (:line-width 2 :style released-button))))) 147 | (custom-button-mouse 148 | ((t (:foreground ,base1 :background ,base02 :inherit custom-button)))) 149 | (custom-button-pressed 150 | ((t (:foreground ,base1 :background ,base02 151 | :box (:line-width 2 :style pressed-button) 152 | :inherit custom-button-mouse)))) 153 | (custom-changed ((t (:foreground ,blue :background ,base3)))) 154 | (custom-comment ((t (:foreground ,base1 :background ,base02)))) 155 | (custom-comment-tag ((t (:foreground ,base1 :background ,base02)))) 156 | (custom-documentation ((t (:inherit default)))) 157 | (custom-group-tag ((t (:foreground ,base1)))) 158 | (custom-group-tag-1 ((t (:foreground ,base1 :weight bold)))) 159 | (custom-invalid ((t (:foreground ,red :background ,base3)))) 160 | (custom-link ((t (:foreground ,magenta)))) 161 | (custom-state ((t (:foreground ,green)))) 162 | (custom-variable-tag ((t (:foreground ,base1)))) 163 | 164 | ;; emacs-wiki 165 | (emacs-wiki-bad-link-face ((t (:foreground ,red)))) 166 | (emacs-wiki-link-face ((t (:foreground ,blue :underline t)))) 167 | (emacs-wiki-verbatim-face ((t (:foreground ,base00 :underline t)))) 168 | 169 | ;; diff-mode 170 | (diff-added ((t (:foreground ,green :weight bold)))) 171 | (diff-changed ((t (:foreground ,yellow :weight bold)))) 172 | (diff-removed ((t (:foreground ,red :weight bold)))) 173 | (diff-refine-change ((t (:foreground ,blue :background ,base03 :weight bold)))) 174 | (diff-file-header ((t (:background ,base03)))) 175 | (diff-header ((t (:foreground ,base1 :background ,base03)))) 176 | 177 | ;; ido 178 | (ido-only-match ((t (:foreground ,green)))) 179 | (ido-subdir ((t (:foreground ,blue)))) 180 | (ido-first-match ((t (:foreground ,green :weight bold)))) 181 | 182 | ;; helm 183 | (helm-M-x-key ((t (:foreground ,magenta)))) 184 | (helm-buffer-directory ((t (:foreground, yellow :weight bold)))) 185 | (helm-buffer-file ((t (:foreground ,base0)))) 186 | (helm-buffer-not-saved ((t (:foreground ,red :slant italic )))) 187 | (helm-buffer-process ((t (:foregorund ,blue)))) 188 | (helm-buffer-saved-out ((t (:foreground ,cyan)))) 189 | (helm-buffer-size ((t (:foreground ,magenta)))) 190 | (helm-candidate-number ((t (:foreground ,red :background ,base02 :weight bold)))) 191 | (helm-header-line-left-margin ((t (:foreground ,red)))) 192 | (helm-ff-directory ((t (:foreground ,blue :weight bold)))) 193 | (helm-ff-dotted-directory ((t (:foreground ,red)))) 194 | (helm-ff-executable ((t (:foreground ,base0 :weight bold)))) 195 | (helm-ff-file ((t (:foreground ,base0)))) 196 | (helm-ff-invalid-symlink ((t (:foreground ,red :background ,base02 :underline t)))) 197 | (helm-ff-prefix ((t (:foreground ,yellow :weight bold)))) 198 | (helm-ff-symlink ((t (:foreground ,blue :background ,base02 :weight bold)))) 199 | (helm-match ((t (:foreground ,red :underline t)))) 200 | (helm-selection ((t (:foreground ,green :background ,base01)))) 201 | (helm-source-header ((t (:foreground ,cyan :weight bold )))) 202 | (helm-visible-mark ((t (:foreground ,blue :background ,base02)))) 203 | 204 | ;; mmm-mode 205 | (mmm-code-submode-face ((,class (:background ,current-line)))) 206 | (mmm-comment-submode-face ((,class (:inherit font-lock-comment-face)))) 207 | (mmm-output-submode-face ((,class (:background ,current-line)))) 208 | 209 | ;; info 210 | (info-xref ((t (:foreground ,blue :underline t)))) 211 | (info-xref-visited ((t (:foreground ,magenta :inherit info-xref)))) 212 | 213 | ;; outline 214 | (outline-1 ((t (:foreground ,blue)))) 215 | (outline-2 ((t (:foreground ,cyan)))) 216 | (outline-3 ((t (:foreground ,yellow)))) 217 | (outline-4 ((t (:foreground ,red)))) 218 | (outline-5 ((t (:foreground ,base0)))) 219 | (outline-6 ((t (:foreground ,base01)))) 220 | (outline-7 ((t (:foreground ,orange)))) 221 | (outline-8 ((t (:foreground ,magenta)))) 222 | 223 | ;; hl-line 224 | (hl-line ((t (:background ,selection :underline nil)))) 225 | 226 | ;; highlight 227 | (highlight ((,class (:foreground ,current-line :background ,highlight)))) 228 | 229 | ;; fringe 230 | ;; (fringe ((t (:background ,current-line)))) 231 | (fringe ((t (:foreground ,base01 :background ,base02)))) 232 | 233 | ;; header 234 | (header-line ((t (:foreground ,base0 :background ,base02 :weight bold)))) 235 | 236 | ;; linum 237 | (linum ((t (:foreground ,base01 :background ,base02)))) 238 | 239 | ;; org 240 | (org-level-1 ((t (:inherit outline-1 :bold t)))) 241 | (org-level-2 ((t (:inherit outline-2)))) 242 | (org-level-3 ((t (:inherit outline-3)))) 243 | (org-level-4 ((t (:inherit outline-4)))) 244 | (org-level-5 ((t (:inherit outline-5)))) 245 | (org-level-6 ((t (:inherit outline-6)))) 246 | (org-level-7 ((t (:inherit outline-7)))) 247 | (org-level-8 ((t (:inherit outline-8)))) 248 | (org-level-9 ((t (:inherit outline-9)))) 249 | (org-block ((,class (:foreground ,green :background ,far-background)))) 250 | (org-block-background ((,t (:background ,far-background)))) 251 | 252 | (org-hide ((t (:foreground ,base03)))) 253 | (org-link ((t (:inherit link)))) 254 | ;; (org-todo ((t (:foreground ,base03 :background ,red :weight bold)))) 255 | (org-todo ((t (:foreground ,red :bold t)))) 256 | (org-done ((t (:foreground ,green :weight bold)))) 257 | (org-todo-kwd-face ((t (:foreground ,red :background ,base03)))) 258 | (org-done-kwd-face ((t (:foreground ,green :background ,base03)))) 259 | (org-project-kwd-face ((t (:foreground ,magenta :background ,base03)))) 260 | (org-waiting-kwd-face ((t (:foreground ,orange :background ,base03)))) 261 | (org-someday-kwd-face ((t (:foreground ,blue :background ,base03)))) 262 | (org-started-kwd-face ((t (:foreground ,yellow :background ,base03)))) 263 | (org-cancelled-kwd-face ((t (:foreground ,green :background ,base03)))) 264 | (org-delegated-kwd-face ((t (:foreground ,cyan :background ,base03)))) 265 | 266 | ;; table 267 | (table-cell ((t (:foreground ,base0 :background ,base03)))) 268 | 269 | ;; speedbar 270 | (speedbar-button-face ((t (:foreground ,base1)))) 271 | (speedbar-directory-face ((t (:foreground ,orange)))) 272 | (speedbar-file-face ((t (:foreground ,green)))) 273 | (speedbar-highlight-face ((t (:background ,base02)))) 274 | (speedbar-selected-face ((t (:foreground ,yellow :underline t)))) 275 | (speedbar-separator-face ((t (:inherit default)))) 276 | (speedbar-tag-face ((t (:foreground ,blue)))) 277 | 278 | ;; show-paren 279 | (show-paren-match ((t (:foreground ,cyan :background ,base02 :weight bold :underline t)))) 280 | (show-paren-mismatch ((t (:inherit error)))) 281 | 282 | ;; bm visual bookmarks 283 | (bm-fringe-face ((t (:foreground ,base03 :background ,orange)))) 284 | (bm-fringe-persistent-face ((t (:foreground ,base03 :background ,blue)))) 285 | 286 | ;; Flymake 287 | (flymake-errline ((t (:underline (:color ,red :style wave) :inherit default)))) ; ErrorMsg 288 | (flymake-warnline ((t (:underline (:color ,orange :style wave) :inherit default)))) ; WarningMsg 289 | 290 | ;; column-marker 291 | (column-marker-1 ((t (:background ,base01)))) 292 | (column-marker-2 ((t (:background ,cyan)))) 293 | (column-marker-3 ((t (:background ,magenta)))) 294 | 295 | ;; jabber 296 | (jabber-activity-face ((t (:foreground ,red :weight bold)))) 297 | (jabber-activity-personal-face ((t (:foreground ,blue :weight bold)))) 298 | (jabber-chat-error ((t (:foreground ,red :weight bold)))) 299 | (jabber-chat-prompt-foreign ((t (:foreground ,red :weight bold)))) 300 | (jabber-chat-prompt-local ((t (:foreground ,blue :weight bold)))) 301 | (jabber-chat-prompt-system ((t (:foreground ,green :weight bold)))) 302 | (jabber-chat-text-foreign ((t (:foreground ,base1)))) 303 | (jabber-chat-text-local ((t (:foreground ,base0)))) 304 | (jabber-chat-rare-time-face ((t (:foreground ,green :underline t)))) 305 | (jabber-roster-user-away ((t (:foreground ,green :slant italic)))) 306 | (jabber-roster-user-chatty ((t (:foreground ,orange :weight bold)))) 307 | (jabber-roster-user-dnd ((t (:foreground ,red :slant italic)))) 308 | (jabber-roster-user-error ((t (:foregournd ,red :weight light :slant italic)))) 309 | (jabber-roster-user-offline ((t (:foreground ,base01)))) 310 | (jabber-roster-user-online ((t (:foreground ,blue :weight bold )))) 311 | (jabber-roster-user-xa ((t (:foreground ,magenta :slant italic)))) 312 | 313 | ;; git-gutter 314 | (git-gutter:modified ((t (:foreground ,magenta)))) 315 | (git-gutter:added ((t (:foreground ,green)))) 316 | (git-gutter:deleted ((t (:foreground ,red)))) 317 | 318 | ;; gnus 319 | (gnus-cite-1 ((t (:foreground ,blue)))) 320 | (gnus-cite-2 ((t (:foreground ,cyan)))) 321 | (gnus-cite-3 ((t (:foreground ,yellow)))) 322 | (gnus-cite-4 ((t (:foreground ,red)))) 323 | (gnus-cite-5 ((t (:foreground ,orange)))) 324 | (gnus-cite-6 ((t (:foreground ,magenta)))) 325 | (gnus-cite-7 ((t (:foreground ,green)))) 326 | (gnus-cite-8 ((t (:foreground ,magenta)))) 327 | (gnus-cite-9 ((t (:foreground ,base00)))) 328 | (gnus-cite-10 ((t (:foreground ,base01)))) 329 | (gnus-cite-11 ((t (:foreground ,base02)))) 330 | (gnus-group-mail-1 ((t (:foreground ,base3 :weight bold)))) 331 | (gnus-group-mail-1-empty ((t (:foreground ,base3)))) 332 | (gnus-group-mail-2 ((t (:foreground ,base2 :weight bold)))) 333 | (gnus-group-mail-2-empty ((t (:foreground ,base2)))) 334 | (gnus-group-mail-3 ((t (:foreground ,magenta :weight bold)))) 335 | (gnus-group-mail-3-empty ((t (:foreground ,magenta)))) 336 | (gnus-group-mail-low ((t (:foreground ,base00 :weight bold)))) 337 | (gnus-group-mail-low-empty ((t (:foreground ,base00)))) 338 | (gnus-group-news-1 ((t (:foreground ,base1 :weight bold)))) 339 | (gnus-group-news-1-empty ((t (:foreground ,base1)))) 340 | (gnus-group-news-2 ((t (:foreground ,blue :weight bold)))) 341 | (gnus-group-news-2-empty ((t (:foreground ,blue)))) 342 | (gnus-group-news-low ((t (:foreground ,magenta :weight bold)))) 343 | (gnus-group-news-low-empty ((t (:foreground ,magenta)))) 344 | (gnus-emphasis-highlight-words ((t (:foreground ,yellow)))) 345 | (gnus-header-content ((t (:foreground ,base01)))) ; hdrdefault 346 | (gnus-header-from ((t (:foreground ,base00)))) ; header ^From 347 | (gnus-header-name ((t (:foregrund ,base01)))) ; hdrdefault 348 | (gnus-header-newsgroups ((t (:foreground ,base02)))) 349 | (gnus-header-subject ((t (:foreground ,blue)))) 350 | (gnus-server-agent ((t (:foreground ,base3 :weight bold)))) 351 | (gnus-server-closed ((t (:foreground ,base1 :slant italic)))) 352 | (gnus-server-denied ((t (:foreground ,base2 :weight bold)))) 353 | 354 | (gnus-server-offline ((t (:foreground ,green :weight bold)))) 355 | (gnus-server-opened ((t (:foreground ,cyan :weight bold)))) 356 | (gnus-signature ((t (:foreground ,base01)))) 357 | (gnus-splash ((t (:foreground ,base2)))) 358 | (gnus-summary-cancelled ((t (:foreground ,red)))) 359 | (gnus-summary-high-ancient ((t (:weight bold :inherit gnus-summary-normal-ancient)))) 360 | (gnus-summary-high-read ((t (:weight bold :inherit gnus-summary-normal-read)))) 361 | (gnus-summary-high-ticked ((t (:weight bold :inherit gnus-summary-normal-ticked)))) 362 | (gnus-summary-high-undownloaded ((t (:weight bold :inherit gnus-summary-normal-undownloaded)))) 363 | (gnus-summary-high-unread ((t (:weight bold :inherit gnus-summary-normal-unread)))) 364 | (gnus-summary-low-ancient ((t (:slant italic :inherit gnus-summary-normal-ancient)))) 365 | (gnus-summary-low-read ((t (:slant italic :inherit gnus-summary-normal-ancient)))) 366 | (gnus-summary-low-unread ((t (:slant italic :inherit gnus-summary-normal-unread)))) 367 | (gnus-summary-low-ticked ((t (:slant italic :inherit gnus-summary-normal-ancient)))) 368 | (gnus-summary-low-undownloaded ((t (:slant italic :inherit gnus-summary-normal-ancient)))) 369 | (gnus-summary-normal-ancient ((t (:foreground ,blue)))) 370 | (gnus-summary-normal-read ((t (:foreground ,base01)))) 371 | (gnus-summary-normal-ticked ((t (:foreground ,red)))) 372 | (gnus-summary-normal-undownloaded ((t (:foreground ,base2)))) 373 | (gnus-summary-normal-unread ((t (:foreground ,blue)))) 374 | (gnus-summary-selected ((t (:foreground ,base03 :background ,yellow)))) 375 | 376 | ;; magit 377 | (magit-bisect-bad ((t (:foreground ,red)))) 378 | (magit-bisect-good ((t (:foreground ,green)))) 379 | (magit-biset-skip ((t (:foreground ,blue)))) 380 | (magit-branch-current ((t (:foreground ,green)))) 381 | (magit-branch-local ((t (:foreground ,cyan)))) 382 | (magit-branch-remote ((t (:foreground ,yellow)))) 383 | (magit-cherry-equivalent ((t (:foreground ,base0)))) 384 | (magit-cherry-unmatched ((t (:foreground ,orange)))) 385 | (magit-dimmed ((t (:foregrund ,base01 :slant italic)))) 386 | (magit-hash ((t (:foreground ,base2)))) 387 | (magit-header-line ((t (:foreground ,blue :weight bold)))) 388 | (magit-log-author ((t (:foregrund ,cyan)))) 389 | (magit-log-date ((t (:foreground ,blue)))) 390 | (magit-log-graph ((t (:foreground ,base01)))) 391 | (magit-process-ng ((t (:foreground ,red :weight bold)))) 392 | (magit-process-ok ((t (:foreground ,green :weight bold)))) 393 | (magit-refname ((t (:foreground ,magenta)))) 394 | (magit-section-heading ((t (:foreground ,cyan :weight bold)))) 395 | (magit-siganture-unmatched ((t (:foreground ,magenta)))) 396 | (magit-siganture-untrusted ((t (:foreground ,magenta)))) 397 | (magit-signature-bad ((t (:foreground ,red)))) 398 | (magit-signature-good ((t (:foreground ,green)))) 399 | (magit-tag ((t (:foreground ,orange)))) 400 | 401 | ;; message 402 | (message-mml ((t (:foreground ,blue)))) 403 | (message-cited-text ((t (:foreground ,base2)))) 404 | (message-separator ((t (:foreground ,base3)))) 405 | (message-header-xheader ((t (:foreground ,magenta)))) 406 | (message-header-name ((t (:foreground ,cyan)))) 407 | (message-header-other ((t (:foreground ,red)))) 408 | (message-header-newsgroups ((t (:foreground ,yellow :weight bold)))) 409 | (message-header-subject ((t (:foreground ,base00)))) 410 | (message-header-cc ((t (:foreground ,green :weight bold)))) 411 | (message-header-to ((t (:foreground ,base1 :weight bold)))) 412 | 413 | ;; parenface 414 | (paren-face ((t (:foreground ,base01)))) 415 | 416 | ;; slime 417 | (slime-error-face ((t (:foreground ,red :inverse-video t)))) ; ErrorMsg 418 | (slime-note-face ((t (:foreground ,yellow)))) 419 | (slime-repl-inputted-output-face ((t (:foreground ,red)))) 420 | (slime-repl-output-mouseover-face ((t (:box (:color ,base3))))) 421 | (slime-style-warning-face ((t (:foreground ,orange :weight bold)))) 422 | (slime-warning-face ((t (:foreground ,red :weight bold)))) ; WarningMsg 423 | 424 | ;; whitespace 425 | (whitespace-empty ((t (:foreground ,red)))) 426 | (whitespace-hspace ((t (:foreground ,orange)))) 427 | (whitespace-indentation ((t (:foreground ,base02)))) 428 | (whitespace-space ((t (:foreground ,base02)))) 429 | (whitespace-space-after-tab ((t (:foreground ,cyan)))) 430 | (whitespace-space-before-tab ((t (:foreground ,red :weight bold)))) 431 | (whitespace-tab ((t (:foreground ,base02)))) 432 | (whitespace-trailing ((t (:foreground ,red :background ,base02 :weight bold)))) 433 | (whitespace-highlight-face ((t (:foreground ,@red :background ,blue)))) 434 | (whitespace-line ((t (:foreground ,magenta :background ,base03)))) 435 | 436 | ;; rcirc 437 | (rcirc-my-nick ((t (:foreground ,blue)))) 438 | (rcirc-nick-in-message ((t (:foreground ,orange)))) 439 | (rcirc-other-nick ((t (:foreground ,green)))) 440 | (rcirc-prompt ((t (:foreground ,yellow)))) 441 | (rcirc-bright-nick ((t (:foreground ,magenta)))) 442 | (rcirc-server ((t (:foreground ,base1)))) 443 | (rcirc-timestamp ((t (:foreground ,base01)))) 444 | 445 | ;; erc 446 | (erc-input-face ((t (:foreground ,base01)))) 447 | (erc-keyword-face ((t (:foreground ,yellow :weight bold)))) 448 | (erc-my-nick-face ((t (:foreground ,blue)))) 449 | (erc-nick-defaunoctilux-face ((t (:foreground ,cyan)))) 450 | (erc-notice-face ((t (:foreground ,blue)))) 451 | (erc-timestamp-face ((t (:foreground ,base01)))) 452 | 453 | ;; evil 454 | (evil-ex-lazy-highlight ((t :inherit lazy-highlight))) 455 | (evil-ex-search ((t :inherit isearch))) 456 | (evil-ex-substitute-matches ((t (:foreground ,orange)))) 457 | (evil-ex-substitute-replacement ((t (:foreground ,red :underline t)))) 458 | 459 | ;;font-latex 460 | (font-latex-warning-face ((t (:foreground ,red)))) 461 | (font-latex-sectioning-5-face ((t (:foreground ,magenta)))) 462 | 463 | ;;flyspell 464 | (flyspell-incorrect ((t (:foreground ,red)))) 465 | (flyspell-duplicate ((t (:foreground ,yellow)))) 466 | 467 | ;; company-mode 468 | (company-tooltip ((t (:foreground ,base0 :background ,base02)))) 469 | (company-tooltip-selection ((t (:foreground ,base0 :background ,base01)))) 470 | (company-tooltip-mouse ((t (:background ,base02)))) 471 | (company-tooltip-common ((t (:foreground ,magenta :background ,base02)))) 472 | (company-tooltip-common-selection ((t (:foreground ,magenta :background ,base01)))) 473 | (company-tooltip-annotation ((t (:foreground ,base0 :background ,base02)))) 474 | (company-scrollbar-fg ((t (:background ,base01)))) 475 | (company-scrollbar-bg ((t (:background ,base3)))) 476 | (company-preview ((t (:foreground ,base0 :background ,base01)))) 477 | (company-preview-common ((t (:foreground ,base0 :background ,base01)))) 478 | (company-preview-search ((t (:foreground ,magenta :background ,base01)))) 479 | (company-echo ((t nil))) 480 | (company-echo-common ((t (:foreground ,magenta)))) 481 | 482 | ;; ;; ansi-term 483 | (term-color-black ((t (:foreground ,black)))) 484 | (term-color-red ((t (:foreground ,red)))) 485 | (term-color-green ((t (:foreground ,green)))) 486 | (term-color-yellow ((t (:foreground ,yellow)))) 487 | (term-color-blue ((t (:foreground ,blue)))) 488 | (term-color-magenta ((t (:foreground ,magenta)))) 489 | (term-color-cyan ((t (:foreground ,cyan)))) 490 | (term-color-white ((t (:foreground ,white)))) 491 | 492 | 493 | ;;;; Following need to re-check 494 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 495 | 496 | (escape-glyph-face ((,class (:foreground ,red)))) 497 | 498 | (isearch ((t (:foreground ,orange :backbround ,base03 :weight normal :slant normal :underline nil :inverse-video t)))) ; IncSearch 499 | (isearch-fail ((t (:foreground ,orange :background ,base03 :weight normal :slant normal :underline nil :inverse-video t)))) ; IncSearch 500 | (lazy-highlight ((t (:foreground ,yellow :background ,base03 :weight normal :slant normal :underline nil :inverse-video t)))) ; Search 501 | 502 | 503 | (menu ((t (:foreground ,base0 :background ,base02)))) 504 | 505 | ;; (region ((t (:foreground ,base01 :background ,base03 :weight bold :slant normal :underline nil :inverse-video t)))) ; Visual 506 | (secondary-selection ((t (:background ,base02)))) 507 | ;; (shadow ((t (:foreground ,base01)))) 508 | (trailing-whitespace ((t (:foreground ,red :weight normal :slant normal :underline nil :inverse-video t)))) 509 | (vertical-border ((t (:foreground ,base0)))) 510 | 511 | ;; (outline-4 ((,class (:slant normal :foreground ,comment)))) 512 | 513 | ;; ;; Font locks 514 | ;; (font-lock-builtin-face ((t (:foreground "#4BC98A")))) 515 | ;; (font-lock-comment-face ((t (:foreground ,comment :italic t)))) 516 | ;; (font-lock-constant-face ((t (:foreground "#E53F3F" :bold t)))) 517 | ;; (font-lock-function-name-face ((t (:foreground "#AD7FA8" :italic t :bold t)))) 518 | ;; (font-lock-keyword-face ((t (:foreground "#FFC125")))) 519 | ;; (font-lock-string-face ((t (:foreground "#95E454" :italic t)))) 520 | ;; (font-lock-type-face ((t (:foreground "#CAE682")))) 521 | ;; (font-lock-variable-name-face ((t (:foreground "#4BC98A")))) 522 | ;; (font-lock-warning-face ((t (:foreground "#E91303" :bold t)))) 523 | ;; (font-lock-doc-face ((t (:foreground "#40AAFA")))) 524 | 525 | ;; ;; Auto Complete 526 | ;; (ac-candidate-face ((t (:background ,selection :foreground ,foreground)))) 527 | ;; (ac-selection-face ((t (:background ,highlight :foreground ,background)))) 528 | 529 | ;; ;; Elscreen 530 | ;; (elscreen-tab-background-face ((t (:background ,background)))) 531 | ;; (elscreen-tab-control-face ((t (:foreground ,foreground :background "black" 532 | ;; :weight extra-bold)))) 533 | ;; (elscreen-tab-current-screen-face ((t (:background "#250628" :foreground "Gray90" 534 | ;; :bold t)))) 535 | ;; (elscreen-tab-other-screen-face ((t (:background "#1D1D1F" :foreground "Gray85" 536 | ;; :bold t)))) 537 | ;; ;; Evil 538 | ;; (evil-state-normal-face ((t :foreground ,purple :bold t))) 539 | ;; (evil-state-insert-face ((t :foreground ,red :bold t))) 540 | ;; (evil-state-visual-face ((t :foreground ,blue :bold t))) 541 | ;; (evil-state-emacs-face ((t :foreground ,green :bold t))) 542 | 543 | ;; ;; Flymake 544 | ;; (flymake-warnline ((,class (:underline ,orange :background ,background)))) 545 | ;; (flymake-errline ((,class (:underline ,red :background ,background)))) 546 | 547 | ;; ;; Clojure errors 548 | ;; (clojure-test-failure-face ((,class (:background nil :inherit flymake-warnline)))) 549 | ;; (clojure-test-error-face ((,class (:background nil :inherit flymake-errline)))) 550 | ;; (clojure-test-success-face ((,class (:background nil :foreground nil :underline ,green)))) 551 | 552 | ;; ;; For Brian Carper's extended clojure syntax table 553 | ;; (clojure-keyword ((,class (:foreground ,yellow)))) 554 | ;; (clojure-parens ((,class (:foreground ,foreground)))) 555 | ;; (clojure-braces ((,class (:foreground ,green)))) 556 | ;; (clojure-brackets ((,class (:foreground ,yellow)))) 557 | ;; (clojure-double-quote ((,class (:foreground ,aqua :background nil)))) 558 | ;; (clojure-special ((,class (:foreground ,blue)))) 559 | ;; (clojure-java-call ((,class (:foreground ,purple)))) 560 | 561 | ;; ;; Search 562 | ;; (match ((,class (:foreground ,blue :background ,background :inverse-video t)))) 563 | ;; (isearch ((,class (:foreground ,yellow :background ,background :inverse-video t)))) 564 | ;; (isearch-lazy-highlight-face ((,class (:foreground ,aqua :background ,background :inverse-video t)))) 565 | ;; (isearch-fail ((,class (:background ,background :inherit font-lock-warning-face :inverse-video t)))) 566 | 567 | ;; ;; IDO 568 | ;; (ido-first-match ((,class (:foreground ,yellow :weight bold)))) 569 | ;; (ido-only-match ((,class (:foreground ,orange :weight bold)))) 570 | ;; (ido-virtual ((,class (:foreground ,comment)))) 571 | ;; (ido-incomplete-regexp ((,class (:foreground ,red :bold t)))) 572 | ;; (ido-subdir ((,class (:foreground ,aqua :bold t)))) 573 | ;; (ido-virtual ((,class (:foreground ,purple)))) 574 | 575 | ;; ;; which-function 576 | ;; (which-func ((,class (:foreground ,blue :background nil :weight bold)))) 577 | 578 | ;; ;; Emacs interface 579 | 580 | ;; (linum ((,class (:foreground ,cursor :background ,background)))) 581 | 582 | ;; ;; (border ((,class (:background ,current-line)))) 583 | ;; ;; (border-glyph ((,class (nil)))) 584 | ;; (highlight ((,class (:foreground ,current-line :background ,green)))) 585 | ;; (link ((,class (:foreground ,blue)))) 586 | ;; (link-visited ((,class (:foreground ,purple)))) 587 | ;; (gui-element ((,class (:background ,current-line :foreground ,foreground)))) 588 | 589 | ;; ;; mode-line 590 | ;; (mode-line ((,class (:background ,background :foreground "#b1c3d4" 591 | ;; :box (:line-width 2 :color "#B184CB"))))) 592 | ;; (mode-line-inactive ((,class (:background ,current-line :foreground "#7b8793" 593 | ;; :box (:line-width 2 :color "#565968"))))) 594 | ;; (mode-line-buffer-id ((,class (:foreground ,foreground :background nil)))) 595 | ;; (mode-line-emphasis ((,class (:foreground ,foreground :slant italic)))) 596 | ;; (mode-line-highlight ((,class (:foreground ,purple :box nil :weight bold)))) 597 | 598 | ;; (minibuffer-prompt ((,class (:foreground ,red :bold t)))) 599 | ;; (region ((,class (:background ,selection)))) 600 | ;; (secondary-selection ((,class (:background ,current-line)))) 601 | 602 | ;; ;; (header-line ((,class (:inherit mode-line :foreground ,purple :background nil)))) 603 | 604 | ;; (trailing-whitespace ((,class (:background ,red :foreground ,yellow)))) 605 | ;; (whitespace-empty ((,class (:foreground ,red :background ,yellow)))) 606 | ;; (whitespace-hspace ((,class (:background ,selection :foreground ,comment)))) 607 | ;; (whitespace-indentation ((,class (:background ,yellow :foreground ,red)))) 608 | ;; (whitespace-line ((,class (:background ,current-line :foreground ,purple)))) 609 | ;; (whitespace-newline ((,class (:foreground ,comment)))) 610 | ;; (whitespace-space ((,class (:background ,current-line :foreground ,comment)))) 611 | ;; (whitespace-space-after-tab ((,class (:background ,yellow :foreground ,red)))) 612 | ;; (whitespace-space-before-tab ((,class (:background ,orange :foreground ,red)))) 613 | ;; (whitespace-tab ((,class (:background ,selection :foreground ,comment)))) 614 | ;; (whitespace-trailing ((,class (:background ,red :foreground ,yellow)))) 615 | 616 | ;; ;; Parenthesis matching (built-in) 617 | ;; (show-paren-match ((,class (:background ,blue :foreground ,current-line)))) 618 | ;; (show-paren-mismatch ((,class (:background ,orange :foreground ,current-line)))) 619 | 620 | ;; ;; Parenthesis matching (mic-paren) 621 | ;; (paren-face-match ((,class (:foreground nil :background nil :inherit show-paren-match)))) 622 | ;; (paren-face-mismatch ((,class (:foreground nil :background nil :inherit show-paren-mismatch)))) 623 | ;; (paren-face-no-match ((,class (:foreground nil :background nil :inherit show-paren-mismatch)))) 624 | 625 | ;; ;; Parenthesis dimming (parenface) 626 | ;; (paren-face ((,class (:foreground ,comment :background nil)))) 627 | 628 | ;; (sh-heredoc ((,class (:foreground nil :inherit font-lock-string-face :weight normal)))) 629 | ;; (sh-quoted-exec ((,class (:foreground nil :inherit font-lock-preprocessor-face)))) 630 | ;; (slime-highlight-edits-face ((,class (:weight bold)))) 631 | ;; (slime-repl-input-face ((,class (:weight normal :underline nil)))) 632 | ;; (slime-repl-prompt-face ((,class (:underline nil :weight bold :foreground ,purple)))) 633 | ;; (slime-repl-result-face ((,class (:foreground ,green)))) 634 | ;; (slime-repl-output-face ((,class (:foreground ,blue :background ,background)))) 635 | 636 | ;; (csv-separator-face ((,class (:foreground ,orange)))) 637 | 638 | ;; (diff-added ((,class (:foreground ,green)))) 639 | ;; (diff-changed ((,class (:foreground ,yellow)))) 640 | ;; (diff-removed ((,class (:foreground ,red)))) 641 | ;; (diff-header ((,class (:background ,current-line)))) 642 | ;; (diff-file-header ((,class (:background ,selection)))) 643 | ;; (diff-hunk-header ((,class (:foreground ,yellow :italic t)))) 644 | ;; (diff-context ((,class (:foreground ,foreground)))) 645 | 646 | ;; (ediff-even-diff-A ((,class (:foreground nil :background nil :inverse-video t)))) 647 | ;; (ediff-even-diff-B ((,class (:foreground nil :background nil :inverse-video t)))) 648 | ;; (ediff-odd-diff-A ((,class (:foreground ,comment :background nil :inverse-video t)))) 649 | ;; (ediff-odd-diff-B ((,class (:foreground ,comment :background nil :inverse-video t)))) 650 | 651 | ;; (eldoc-highlight-function-argument ((,class (:foreground ,green :weight bold)))) 652 | 653 | ;; ;; undo-tree 654 | ;; (undo-tree-visualizer-default-face ((,class (:foreground ,foreground)))) 655 | ;; (undo-tree-visualizer-current-face ((,class (:foreground ,green :weight bold)))) 656 | ;; (undo-tree-visualizer-active-branch-face ((,class (:foreground ,red)))) 657 | ;; (undo-tree-visualizer-register-face ((,class (:foreground ,yellow)))) 658 | 659 | ;; ;; auctex 660 | ;; (font-latex-bold-face ((,class (:foreground ,green)))) 661 | ;; (font-latex-doctex-documentation-face ((,class (:background ,current-line)))) 662 | ;; (font-latex-italic-face ((,class (:foreground ,green)))) 663 | ;; (font-latex-math-face ((,class (:foreground ,orange)))) 664 | ;; (font-latex-sectioning-0-face ((,class (:foreground ,yellow)))) 665 | ;; (font-latex-sectioning-1-face ((,class (:foreground ,yellow)))) 666 | ;; (font-latex-sectioning-2-face ((,class (:foreground ,yellow)))) 667 | ;; (font-latex-sectioning-3-face ((,class (:foreground ,yellow)))) 668 | ;; (font-latex-sectioning-4-face ((,class (:foreground ,yellow)))) 669 | ;; (font-latex-sectioning-5-face ((,class (:foreground ,yellow)))) 670 | ;; (font-latex-sedate-face ((,class (:foreground ,aqua)))) 671 | ;; (font-latex-string-face ((,class (:foreground ,yellow)))) 672 | ;; (font-latex-verbatim-face ((,class (:foreground ,orange)))) 673 | ;; (font-latex-warning-face ((,class (:foreground ,red)))) 674 | 675 | ;; ;; dired+ 676 | ;; (diredp-compressed-file-suffix ((,class (:foreground ,blue)))) 677 | ;; (diredp-dir-heading ((,class (:foreground nil :background nil :inherit heading)))) 678 | ;; (diredp-dir-priv ((,class (:foreground ,aqua :background nil)))) 679 | ;; (diredp-exec-priv ((,class (:foreground ,blue :background nil)))) 680 | ;; (diredp-executable-tag ((,class (:foreground ,red :background nil)))) 681 | ;; (diredp-file-name ((,class (:foreground ,yellow)))) 682 | ;; (diredp-file-suffix ((,class (:foreground ,green)))) 683 | ;; (diredp-flag-mark-line ((,class (:background nil :inherit highlight)))) 684 | ;; (diredp-ignored-file-name ((,class (:foreground ,comment)))) 685 | ;; (diredp-link-priv ((,class (:background nil :foreground ,purple)))) 686 | ;; (diredp-mode-line-flagged ((,class (:foreground ,red)))) 687 | ;; (diredp-mode-line-marked ((,class (:foreground ,green)))) 688 | ;; (diredp-no-priv ((,class (:background nil)))) 689 | ;; (diredp-number ((,class (:foreground ,yellow)))) 690 | ;; (diredp-other-priv ((,class (:background nil :foreground ,purple)))) 691 | ;; (diredp-rare-priv ((,class (:foreground ,red :background nil)))) 692 | ;; (diredp-read-priv ((,class (:foreground ,green :background nil)))) 693 | ;; (diredp-symlink ((,class (:foreground ,purple)))) 694 | ;; (diredp-write-priv ((,class (:foreground ,yellow :background nil)))) 695 | 696 | ;; ;; Magit 697 | ;; (magit-branch ((,class (:foreground ,green)))) 698 | ;; (magit-header ((,class (:inherit nil :weight bold)))) 699 | ;; (magit-item-highlight ((,class (:background ,background)))) 700 | ;; (magit-log-graph ((,class (:foreground ,comment)))) 701 | ;; (magit-log-sha1 ((,class (:foreground ,orange)))) 702 | ;; (magit-log-head-label-bisect-bad ((,class (:foreground ,red)))) 703 | ;; (magit-log-head-label-bisect-good ((,class (:foreground ,green)))) 704 | ;; (magit-log-head-label-default ((,class (:foreground ,yellow :box nil :weight bold)))) 705 | ;; (magit-log-head-label-local ((,class (:foreground ,blue)))) 706 | ;; (magit-log-head-label-remote ((,class (:foreground ,green)))) 707 | ;; (magit-log-head-label-tags ((,class (:foreground ,aqua :box nil :weight bold)))) 708 | ;; (magit-section-title ((,class (:inherit diff-hunk-header)))) 709 | 710 | ;; ;; git-gutter 711 | ;; (git-gutter-fr:modified ((,class (:foreground ,yellow)))) 712 | ;; (git-gutter-fr:added ((,class (:inherit diff-added)))) 713 | ;; (git-gutter-fr:deleted ((,class (:inherit diff-removed)))) 714 | 715 | ;; (link ((t (:foreground "dodger blue" :underline t)))) 716 | ;; (widget-button ((,class (:underline t)))) 717 | ;; (widget-field ((,class (:background ,current-line :box (:line-width 1 :color ,foreground))))) 718 | 719 | ;; ;; Compilation (most faces politely inherit from 'success, 'error, 'warning etc.) 720 | ;; (compilation-column-number ((,class (:foreground ,yellow)))) 721 | ;; (compilation-line-number ((,class (:foreground ,yellow)))) 722 | ;; (compilation-message-face ((,class (:foreground ,blue)))) 723 | ;; (compilation-mode-line-exit ((,class (:foreground ,green)))) 724 | ;; (compilation-mode-line-fail ((,class (:foreground ,red)))) 725 | ;; (compilation-mode-line-run ((,class (:foreground ,blue)))) 726 | 727 | ;; ;; Grep 728 | ;; (grep-context-face ((,class (:foreground ,comment)))) 729 | ;; (grep-error-face ((,class (:foreground ,red :weight bold :underline t)))) 730 | ;; (grep-hit-face ((,class (:foreground ,blue)))) 731 | ;; (grep-match-face ((,class (:foreground nil :background nil :inherit match)))) 732 | 733 | ;; (regex-tool-matched-face ((,class (:foreground nil :background nil :inherit match)))) 734 | 735 | ;; ;; mark-multiple 736 | ;; (mm/master-face ((,class (:inherit region :foreground nil :background nil)))) 737 | ;; (mm/mirror-face ((,class (:inherit region :foreground nil :background nil)))) 738 | 739 | ;; (org-agenda-structure ((,class (:foreground ,purple)))) 740 | ;; (org-agenda-date ((,class (:foreground ,blue :underline nil)))) 741 | ;; (org-agenda-done ((,class (:foreground ,green)))) 742 | ;; (org-agenda-dimmed-todo-face ((,class (:foreground ,comment)))) 743 | ;; (org-block ((,class (:foreground ,yellow)))) 744 | ;; (org-code ((,class (:foreground ,yellow)))) 745 | ;; (org-column ((,class (:background ,current-line)))) 746 | ;; (org-column-title ((,class (:inherit org-column :weight bold :underline t)))) 747 | ;; (org-date ((,class (:foreground ,purple :underline t :bold t)))) 748 | ;; (org-agenda-date-weekend ((t (:bold t :foreground ,orange :weight bold)))) 749 | ;; (org-document-info ((,class (:foreground ,aqua)))) 750 | ;; (org-document-info-keyword ((,class (:foreground ,green)))) 751 | ;; (org-document-title ((,class (:weight bold :foreground ,orange :height 1.44)))) 752 | ;; (org-ellipsis ((,class (:foreground ,comment)))) 753 | ;; (org-footnote ((,class (:foreground ,aqua)))) 754 | ;; (org-formula ((,class (:foreground ,red)))) 755 | ;; ;;(org-hide ((,class (:foreground ,current-line)))) 756 | ;; (org-hide ((t (:foreground "#0B0B0E")))) 757 | ;; (org-scheduled ((,class (:foreground ,green)))) 758 | ;; (org-scheduled-previously ((,class (:foreground ,orange)))) 759 | ;; (org-scheduled-today ((,class (:foreground ,green)))) 760 | ;; (org-special-keyword ((,class (:foreground ,orange)))) 761 | ;; ;;(org-table ((,class (:foreground ,purple)))) 762 | ;; (org-todo ((,class (:foreground ,red :bold t)))) 763 | ;; (org-done ((t (:foreground "#4BC98A" :bold t)))) 764 | 765 | ;; (org-upcoming-deadline ((,class (:foreground ,orange)))) 766 | ;; (org-warning ((,class (:weight bold :foreground ,red)))) 767 | 768 | ;; (markdown-url-face ((,class (:inherit link)))) 769 | ;; (markdown-link-face ((,class (:foreground ,blue :underline t)))) 770 | 771 | ;; (hl-sexp-face ((,class (:background ,current-line)))) 772 | ;; (highlight-80+ ((,class (:background ,current-line)))) 773 | 774 | ;; ;; Python-specific overrides 775 | ;; (py-builtins-face ((,class (:foreground ,orange :weight normal)))) 776 | 777 | ;; ;; js2-mode 778 | ;; (js2-warning-face ((,class (:underline ,orange)))) 779 | ;; (js2-error-face ((,class (:foreground nil :underline ,red)))) 780 | ;; (js2-external-variable-face ((,class (:foreground ,purple)))) 781 | ;; (js2-function-param-face ((,class (:foreground ,blue)))) 782 | ;; (js2-instance-member-face ((,class (:foreground ,blue)))) 783 | ;; (js2-private-function-call-face ((,class (:foreground ,red)))) 784 | 785 | ;; ;; js3-mode 786 | ;; (js3-warning-face ((,class (:underline ,orange)))) 787 | ;; (js3-error-face ((,class (:foreground nil :underline ,red)))) 788 | ;; (js3-external-variable-face ((,class (:foreground ,purple)))) 789 | ;; (js3-function-param-face ((,class (:foreground ,blue)))) 790 | ;; (js3-jsdoc-tag-face ((,class (:foreground ,orange)))) 791 | ;; (js3-jsdoc-type-face ((,class (:foreground ,aqua)))) 792 | ;; (js3-jsdoc-value-face ((,class (:foreground ,yellow)))) 793 | ;; (js3-jsdoc-html-tag-name-face ((,class (:foreground ,blue)))) 794 | ;; (js3-jsdoc-html-tag-delimiter-face ((,class (:foreground ,green)))) 795 | ;; (js3-instance-member-face ((,class (:foreground ,blue)))) 796 | ;; (js3-private-function-call-face ((,class (:foreground ,red)))) 797 | 798 | ;; ;; nxml 799 | ;; (nxml-name-face ((,class (:foreground unspecified :inherit font-lock-constant-face)))) 800 | ;; (nxml-attribute-local-name-face ((,class (:foreground unspecified :inherit font-lock-variable-name-face)))) 801 | ;; (nxml-ref-face ((,class (:foreground unspecified :inherit font-lock-preprocessor-face)))) 802 | ;; (nxml-delimiter-face ((,class (:foreground unspecified :inherit font-lock-keyword-face)))) 803 | ;; (nxml-delimited-data-face ((,class (:foreground unspecified :inherit font-lock-string-face)))) 804 | ;; (rng-error-face ((,class (:underline ,red)))) 805 | 806 | ;; ;; RHTML 807 | ;; (erb-delim-face ((,class (:background ,current-line)))) 808 | ;; (erb-exec-face ((,class (:background ,current-line :weight bold)))) 809 | ;; (erb-exec-delim-face ((,class (:background ,current-line)))) 810 | ;; (erb-out-face ((,class (:background ,current-line :weight bold)))) 811 | ;; (erb-out-delim-face ((,class (:background ,current-line)))) 812 | ;; (erb-comment-face ((,class (:background ,current-line :weight bold :slant italic)))) 813 | ;; (erb-comment-delim-face ((,class (:background ,current-line)))) 814 | 815 | ;; ;; Message-mode 816 | ;; (message-header-other ((,class (:foreground nil :background nil :weight normal)))) 817 | ;; (message-header-subject ((,class (:inherit message-header-other :weight bold :foreground ,yellow)))) 818 | ;; (message-header-to ((,class (:inherit message-header-other :weight bold :foreground ,orange)))) 819 | ;; (message-header-cc ((,class (:inherit message-header-to :foreground nil)))) 820 | ;; (message-header-name ((,class (:foreground ,blue :background nil)))) 821 | ;; (message-header-newsgroups ((,class (:foreground ,aqua :background nil :slant normal)))) 822 | ;; (message-separator ((,class (:foreground ,purple)))) 823 | 824 | ;; ;; Jabber 825 | ;; (jabber-chat-prompt-local ((,class (:foreground ,yellow)))) 826 | ;; (jabber-chat-prompt-foreign ((,class (:foreground ,orange)))) 827 | ;; (jabber-chat-prompt-system ((,class (:foreground ,yellow :weight bold)))) 828 | ;; (jabber-chat-text-local ((,class (:foreground ,yellow)))) 829 | ;; (jabber-chat-text-foreign ((,class (:foreground ,orange)))) 830 | ;; (jabber-chat-text-error ((,class (:foreground ,red)))) 831 | 832 | ;; (jabber-roster-user-online ((,class (:foreground ,green)))) 833 | ;; (jabber-roster-user-xa ((,class :foreground ,comment))) 834 | ;; (jabber-roster-user-dnd ((,class :foreground ,yellow))) 835 | ;; (jabber-roster-user-away ((,class (:foreground ,orange)))) 836 | ;; (jabber-roster-user-chatty ((,class (:foreground ,purple)))) 837 | ;; (jabber-roster-user-error ((,class (:foreground ,red)))) 838 | ;; (jabber-roster-user-offline ((,class (:foreground ,comment)))) 839 | 840 | ;; (jabber-rare-time-face ((,class (:foreground ,comment)))) 841 | ;; (jabber-activity-face ((,class (:foreground ,purple)))) 842 | ;; (jabber-activity-personal-face ((,class (:foreground ,aqua)))) 843 | 844 | ;; ;; Gnus 845 | ;; (gnus-cite-1 ((,class (:inherit outline-1 :foreground nil)))) 846 | ;; (gnus-cite-2 ((,class (:inherit outline-2 :foreground nil)))) 847 | ;; (gnus-cite-3 ((,class (:inherit outline-3 :foreground nil)))) 848 | ;; (gnus-cite-4 ((,class (:inherit outline-4 :foreground nil)))) 849 | ;; (gnus-cite-5 ((,class (:inherit outline-5 :foreground nil)))) 850 | ;; (gnus-cite-6 ((,class (:inherit outline-6 :foreground nil)))) 851 | ;; (gnus-cite-7 ((,class (:inherit outline-7 :foreground nil)))) 852 | ;; (gnus-cite-8 ((,class (:inherit outline-8 :foreground nil)))) 853 | ;; ;; there are several more -cite- faces... 854 | ;; (gnus-header-content ((,class (:inherit message-header-other)))) 855 | ;; (gnus-header-subject ((,class (:inherit message-header-subject)))) 856 | ;; (gnus-header-from ((,class (:inherit message-header-other-face :weight bold :foreground ,orange)))) 857 | 858 | ;; (gnus-header-name ((,class (:inherit message-header-name)))) 859 | ;; (gnus-button ((,class (:inherit link :foreground nil)))) 860 | ;; (gnus-signature ((,class (:inherit font-lock-comment-face)))) 861 | 862 | ;; (gnus-summary-normal-unread ((,class (:foreground ,blue :weight normal)))) 863 | ;; (gnus-summary-normal-read ((,class (:foreground ,foreground :weight normal)))) 864 | ;; (gnus-summary-normal-ancient ((,class (:foreground ,aqua :weight normal)))) 865 | ;; (gnus-summary-normal-ticked ((,class (:foreground ,orange :weight normal)))) 866 | ;; (gnus-summary-low-unread ((,class (:foreground ,comment :weight normal)))) 867 | ;; (gnus-summary-low-read ((,class (:foreground ,comment :weight normal)))) 868 | ;; (gnus-summary-low-ancient ((,class (:foreground ,comment :weight normal)))) 869 | ;; (gnus-summary-high-unread ((,class (:foreground ,yellow :weight normal)))) 870 | ;; (gnus-summary-high-read ((,class (:foreground ,green :weight normal)))) 871 | ;; (gnus-summary-high-ancient ((,class (:foreground ,green :weight normal)))) 872 | ;; (gnus-summary-high-ticked ((,class (:foreground ,orange :weight normal)))) 873 | ;; (gnus-summary-cancelled ((,class (:foreground ,red :background nil :weight normal)))) 874 | 875 | ;; (gnus-group-mail-low ((,class (:foreground ,comment)))) 876 | ;; (gnus-group-mail-low-empty ((,class (:foreground ,comment)))) 877 | ;; (gnus-group-mail-1 ((,class (:foreground nil :weight normal :inherit outline-1)))) 878 | ;; (gnus-group-mail-2 ((,class (:foreground nil :weight normal :inherit outline-2)))) 879 | ;; (gnus-group-mail-3 ((,class (:foreground nil :weight normal :inherit outline-3)))) 880 | ;; (gnus-group-mail-4 ((,class (:foreground nil :weight normal :inherit outline-4)))) 881 | ;; (gnus-group-mail-5 ((,class (:foreground nil :weight normal :inherit outline-5)))) 882 | ;; (gnus-group-mail-6 ((,class (:foreground nil :weight normal :inherit outline-6)))) 883 | ;; (gnus-group-mail-1-empty ((,class (:inherit gnus-group-mail-1 :foreground ,comment)))) 884 | ;; (gnus-group-mail-2-empty ((,class (:inherit gnus-group-mail-2 :foreground ,comment)))) 885 | ;; (gnus-group-mail-3-empty ((,class (:inherit gnus-group-mail-3 :foreground ,comment)))) 886 | ;; (gnus-group-mail-4-empty ((,class (:inherit gnus-group-mail-4 :foreground ,comment)))) 887 | ;; (gnus-group-mail-5-empty ((,class (:inherit gnus-group-mail-5 :foreground ,comment)))) 888 | ;; (gnus-group-mail-6-empty ((,class (:inherit gnus-group-mail-6 :foreground ,comment)))) 889 | ;; (gnus-group-news-1 ((,class (:foreground nil :weight normal :inherit outline-5)))) 890 | ;; (gnus-group-news-2 ((,class (:foreground nil :weight normal :inherit outline-6)))) 891 | ;; (gnus-group-news-3 ((,class (:foreground nil :weight normal :inherit outline-7)))) 892 | ;; (gnus-group-news-4 ((,class (:foreground nil :weight normal :inherit outline-8)))) 893 | ;; (gnus-group-news-5 ((,class (:foreground nil :weight normal :inherit outline-1)))) 894 | ;; (gnus-group-news-6 ((,class (:foreground nil :weight normal :inherit outline-2)))) 895 | ;; (gnus-group-news-1-empty ((,class (:inherit gnus-group-news-1 :foreground ,comment)))) 896 | ;; (gnus-group-news-2-empty ((,class (:inherit gnus-group-news-2 :foreground ,comment)))) 897 | ;; (gnus-group-news-3-empty ((,class (:inherit gnus-group-news-3 :foreground ,comment)))) 898 | ;; (gnus-group-news-4-empty ((,class (:inherit gnus-group-news-4 :foreground ,comment)))) 899 | ;; (gnus-group-news-5-empty ((,class (:inherit gnus-group-news-5 :foreground ,comment)))) 900 | ;; (gnus-group-news-6-empty ((,class (:inherit gnus-group-news-6 :foreground ,comment)))) 901 | 902 | ;; ;; erc 903 | ;; (erc-direct-msg-face ((,class (:foreground ,orange)))) 904 | ;; (erc-error-face ((,class (:foreground ,red)))) 905 | ;; (erc-header-face ((,class (:foreground ,foreground :background ,selection)))) 906 | ;; (erc-input-face ((,class (:foreground ,green)))) 907 | ;; (erc-keyword-face ((,class (:foreground ,yellow)))) 908 | ;; (erc-current-nick-face ((,class (:foreground ,green)))) 909 | ;; (erc-my-nick-face ((,class (:foreground ,green)))) 910 | ;; (erc-nick-default-face ((,class (:weight normal :foreground ,purple)))) 911 | ;; (erc-nick-msg-face ((,class (:weight normal :foreground ,yellow)))) 912 | ;; (erc-notice-face ((,class (:foreground ,comment)))) 913 | ;; (erc-pal-face ((,class (:foreground ,orange)))) 914 | ;; (erc-prompt-face ((,class (:foreground ,blue)))) 915 | ;; (erc-timestamp-face ((,class (:foreground ,aqua)))) 916 | 917 | ;; ;; woman 918 | ;; (woman-italic-face ((t (:slant italic :weight bold)))) 919 | ;; (woman-unknown ((t (:foreground ,red :weight bold)))) 920 | ;; (woman-addition ((t (:foreground ,aqua)))) 921 | ;; (woman-bold ((t (:inherit bold :foreground ,blue)))) 922 | 923 | ;; (custom-variable-tag ((,class (:foreground ,blue)))) 924 | ;; (custom-group-tag ((,class (:foreground ,blue)))) 925 | ;; (custom-state ((,class (:foreground ,green)))) 926 | 927 | ))) 928 | 929 | (defun coldnew-theme--theme-name (mode) 930 | (intern (format "coldnew-theme-%s" (symbol-name mode)))) 931 | 932 | (defmacro coldnew-theme--define-theme (mode) 933 | "Define a theme for the coldnew variant `MODE'." 934 | (let ((name (coldnew-theme--theme-name mode)) 935 | (doc (format "coldnew's personal color theme (%s version)" mode))) 936 | `(progn 937 | (deftheme ,name ,doc) 938 | (put ',name 'theme-immediate t) 939 | (message (format "%s : %s" (symbol-name ',name) ,doc)) 940 | (coldnew-theme--with-colors 941 | ',mode 942 | (apply 'custom-theme-set-faces ',name 943 | (coldnew-theme--face-specs)) 944 | (custom-theme-set-variables 945 | ',name 946 | `(ansi-color-names-vector (vector ,foreground ,red ,green ,yellow ,blue ,magenta ,cyan ,background)) 947 | '(ansi-color-faces-vector [default bold shadow italic underline bold bold-italic bold]))) 948 | (provide-theme ',name)))) 949 | 950 | (defun coldnew-theme--load-theme (mode) 951 | (if (fboundp 'load-theme) 952 | (let ((name (coldnew-theme--theme-name mode))) 953 | (if (> emacs-major-version 23) 954 | (load-theme name t) 955 | (load-theme name))) 956 | ;; not support for older emace. 957 | (error "emacs should support load-theme to make coldnew-theme work."))) 958 | 959 | ;; ;;;; Mode-line 960 | 961 | 962 | ;;;###autoload 963 | (when (boundp 'custom-theme-load-path) 964 | (add-to-list 'custom-theme-load-path 965 | (file-name-as-directory (file-name-directory (or load-file-name (buffer-file-name)))))) 966 | 967 | (provide 'coldnew-theme) 968 | 969 | ;; Local Variables: 970 | ;; byte-compile-warnings: (not cl-functions) 971 | ;; End: 972 | 973 | ;;; coldnew-theme.el ends here 974 | -------------------------------------------------------------------------------- /init.org: -------------------------------------------------------------------------------- 1 | #+TITLE: coldnew's emacs config 2 | #+AUTHOR: Yen-Chin, Lee 3 | #+email: coldnew.tw at gmail.com 4 | #+DESCRIPTION: A literate programming style exposition of my Emacs configuration 5 | #+LANGUAGE: en 6 | #+STARTUP: overview indent align 7 | #+BABEL: :cache yes 8 | #+OPTIONS: ^:nil 9 | #+PROPERTY: header-args :comments link 10 | 11 | # Badge 12 | [[http://www.gnu.org/licenses/gpl-3.0.txt][https://img.shields.io/badge/license-GPL_3-green.svg?dummy]] 13 | [[https://travis-ci.org/coldnew/coldnew-spacemacs][https://travis-ci.org/coldnew/coldnew-spacemacs.svg?branch=master]] 14 | 15 | * Introduction 16 | 17 | This is another emacs config of mine, which is a totally rewritten version 18 | based on top of [[https://github.com/syl20bnr/spacemacs][spacemacs]] and [[https://github.com/coldnew/coldnew-emacs][coldnew-emacs]] with [[http://en.wikipedia.org/wiki/Literate_programming][literate programming]] 19 | in [[http://orgmode.org/][org-mode]], but it uses English to write this config instead. 20 | 21 | Feel free to use it :). 22 | 23 | ** Install emacs 24 | 25 | My emacs is running under =Mac OSX= and =Gentoo Linux= and I really like them, 26 | following are some record for how I installed my emacs. 27 | 28 | *** Mac OSX 29 | 30 | In Mac OSX, I use [[http://brew.sh/][homebrew]] to mantain opensource packages, I always install latest 31 | version of emacs via following command 32 | 33 | #+BEGIN_EXAMPLE 34 | brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls --with-rsvg --with-imagemagick 35 | brew linkapps 36 | #+END_EXAMPLE 37 | 38 | *** Gentoo Linux 39 | 40 | [[https://www.gentoo.org/][Gentoo Linux]] is the best linux distrobution I ever used and it's really easy to install latest apps. 41 | 42 | #+BEGIN_EXAMPLE 43 | USE="X gtk3 inotify xft imagemagick" emerge app-editors/emacs 44 | #+END_EXAMPLE 45 | 46 | ** Install or testing this config 47 | 48 | - First use git to download whole repo 49 | 50 | : git clone https://github.com/coldnew/coldnew-spacemacs.git 51 | 52 | - Then use git submodule to download the spacemacs 53 | 54 | : git submodule init 55 | : git submodule update 56 | 57 | - You also need to install [[https://github.com/cask/cask][Cask]] for package management 58 | 59 | : curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python 60 | 61 | - Then use the =make= command bootstrap this config 62 | 63 | : make bootstrap 64 | 65 | - If you only want to generate the =init.el=, jut type 66 | 67 | : make init.el 68 | 69 | - If you do not put this repo on =~/.emacs.d=, you need to use following 70 | command to start emacs 71 | 72 | : emacs -q -l ~/coldnew-spacemacs/init.el 73 | 74 | ** Packages need to install in system (Optional) 75 | 76 | Some extra packages need to be installed in the system manually. These packages 77 | are =optional= but can make this configuration work more nicely. 78 | 79 | *** Mac OSX 80 | 81 | #+BEGIN_SRC sh :tangle no 82 | brew install the_silver_searcher 83 | brew install fasd 84 | brew install docmacs 85 | brew install aspell --with-lang-en 86 | #+END_SRC 87 | 88 | *** Gentoo Linux 89 | 90 | In Gentoo Linux, don't forget to enable ~USE=emacs~ to make gentoo auto install 91 | emacs-related packages. 92 | 93 | #+BEGIN_SRC sh :tangle no 94 | emerge sys-apps/the_silver_searcher 95 | emerge app-shells/fasd 96 | emerge app-shells/doxymacs 97 | emerge app-shells/aspell 98 | #+END_SRC 99 | 100 | * Initialization Emacs 101 | 102 | There are some configurations I need to put at the beginning of the emacs 103 | config. These configurations are derived from my original init.el file. 104 | 105 | ** load prefer newer 106 | 107 | #+BEGIN_SRC emacs-lisp 108 | ;; since emacs 24.4, new option `load-prefer-newer' has been 109 | ;; introduce, which make me never accidentally using outdated compiled files. 110 | (setq load-prefer-newer t) 111 | #+END_SRC 112 | 113 | ** change the user-emacs-directory 114 | 115 | I this configuration, =user-emacs-directory= always refer to the emacs 116 | configuration's init.el parent directory. 117 | 118 | #+BEGIN_SRC emacs-lisp 119 | ;; We set `user-emacs-directory' here so we can use command-line 120 | ;; switch different emacs configuration like following: 121 | ;; 122 | ;; emacs -q -l ~/coldnew-spacemacs/init.el 123 | (defconst user-emacs-directory 124 | (file-name-directory (or load-file-name (buffer-file-name))) 125 | "My emacs config directory.") 126 | #+END_SRC 127 | 128 | ** define user-cache-directory variable 129 | 130 | Setup the cache directory to store some cache content. 131 | 132 | #+BEGIN_SRC emacs-lisp 133 | (defconst user-cache-directory 134 | (file-name-as-directory (concat user-emacs-directory ".cache")) 135 | "My emacs storage area for persistent files.") 136 | #+END_SRC 137 | 138 | * Package Management 139 | 140 | Before we start this section, we need to initialize =package.el= first. 141 | 142 | #+BEGIN_SRC emacs-lisp 143 | ;; This must come before configurations of installed packages. 144 | ;; Don't delete this line. If you don't want it, just comment it out by adding a 145 | ;; semicolon to the start of the line. You may delete these explanatory 146 | ;; comments. 147 | (package-initialize) 148 | #+END_SRC 149 | 150 | The main package magement in my emacs is [[https://github.com/cask/cask][Cask]], which is a really nice package 151 | like npm, cargo ...etc. 152 | 153 | [[https://github.com/cask/cask][Cask]] can also install packages according to your emacs version, so you don't be 154 | afraid to get version conflicts after upgrade emacs. 155 | 156 | Take my emacs as example, after initialize [[https://github.com/cask/cask][Cask]], all package install by 157 | =package.el= just save to =.cask= folder according to your emacs version. 158 | 159 | #+BEGIN_EXAMPLE 160 | coldnew@Sara ~/.emacs.d $ tree -L 1 .cask/ 161 | .cask/ 162 | ├── 24.5.1 163 | ├── 25.0.50.1 164 | └── 25.1.50.1 165 | 166 | 3 directories, 0 files 167 | #+END_EXAMPLE 168 | 169 | ** Cask and Pallet 170 | 171 | [[https://github.com/rdallasgray/pallet][Pallet]] is a wonderful little tool built on [[https://github.com/cask/cask][Cask]], a dependency management tool 172 | for Emacs packages. Pallet adds automatic updating of the =Caskfile= when 173 | packages are installed and deleted. 174 | 175 | *** Installing Cask 176 | 177 | Just run this command in your terminal of choice: 178 | 179 | #+BEGIN_SRC sh :tangle no 180 | curl -fsSkL https://raw.github.com/cask/cask/master/go | python 181 | #+END_SRC 182 | 183 | then add =~/.cask/bin= to your =PATH= so that you can use =cask=. 184 | 185 | *** Creating a Caskfile :caskfile: 186 | 187 | For now, we just need a minimal =Cask= to get Pallet set up. Mine 188 | looks like this: 189 | 190 | #+BEGIN_SRC emacs-lisp :tangle (if (file-exists-p "Cask") "no" "Cask") 191 | (source gnu) 192 | (source melpa) 193 | 194 | (depends-on "evil") 195 | (depends-on "f") 196 | (depends-on "s") 197 | (depends-on "dash") 198 | (depends-on "noflet") 199 | (depends-on "pallet") 200 | (depends-on "async") 201 | (depends-on "req-package") 202 | (depends-on "quelpa") 203 | #+END_SRC 204 | 205 | Then run the following command in your =.emacs.d= directory to set up 206 | [[https://github.com/rdallasgray/pallet][Pallet]]. 207 | 208 | #+BEGIN_SRC sh :tangle no 209 | cask install 210 | #+END_SRC 211 | 212 | Since the =Cask= file is just emacs-lisp file, add it to mode-alist. 213 | 214 | #+BEGIN_SRC emacs-lisp 215 | (add-to-list 'auto-mode-alist '("Cask$" . emacs-lisp-mode)) 216 | #+END_SRC 217 | 218 | *** Initialize Cask 219 | 220 | Finally, we add the following lines to our init file: 221 | 222 | #+BEGIN_SRC emacs-lisp 223 | (require 'cask "~/.cask/cask.el") 224 | (cask-initialize) 225 | #+END_SRC 226 | 227 | *** Initialize Pallet 228 | 229 | Since we already install pallet via cask, we just need to use the following code 230 | to initialize pallet. 231 | 232 | #+BEGIN_SRC emacs-lisp 233 | (require 'pallet) 234 | (pallet-mode t) 235 | #+END_SRC 236 | 237 | ** quelpa 238 | 239 | [[https://github.com/quelpa/quelpa][quelpa]] is another package manager which can help you builds an ELPA compatible 240 | package and installs that locally. 241 | 242 | GitHub: https://github.com/quelpa/quelpa 243 | 244 | #+BEGIN_SRC emacs-lisp 245 | (unless (require 'quelpa nil t) 246 | (with-temp-buffer 247 | (url-insert-file-contents "https://raw.github.com/quelpa/quelpa/master/bootstrap.el") 248 | (eval-buffer))) 249 | ;; save quelpa builds and packages in .cache/quelpa 250 | (setq quelpa-dir (expand-file-name "quelpa" user-cache-directory)) 251 | #+END_SRC 252 | 253 | ** req-package 254 | 255 | [[https://github.com/edvorg/req-package][req-package]] is a wrapper on top of [[https://github.com/jwiegley/use-package][use-package]], a package dependency management 256 | tool. The documentation for =use-package= is immensely helpful for figuring out 257 | how to describe package dependencies and settings. =req-package= adds the 258 | =:require= keyword which allows us to define dependencies between related 259 | packages. 260 | 261 | *** Initialize req-package 262 | 263 | With the preceding process complete, we just need to add the following 264 | line to our init file to begin using =req-package=: 265 | 266 | #+BEGIN_SRC emacs-lisp 267 | (require 'req-package) 268 | #+END_SRC 269 | 270 | *** Start loading packages in right order 271 | 272 | To start loading packages in right order, we need to added following in the last 273 | of emacs config. 274 | 275 | #+BEGIN_SRC emacs-lisp :tangle no 276 | (req-package-finish) 277 | #+END_SRC 278 | 279 | You can take a look at [[*End%20of%20configuration][End of configuration]] section. 280 | 281 | * Load Path 282 | 283 | The variable =load-path= lists all the directories where Emacs should look for 284 | Elisp files. 285 | 286 | Though I use =Cask= as package management in my emacs, some local packages like 287 | my own theme or others can't fetch by elpa need to add to load-path, this will 288 | help emacs find them. 289 | 290 | Following are my method to add directories to load-path ~recursively~, this 291 | function also create directory to prevent directory not exist. 292 | 293 | If you don't have any local elisp and all packages is mantain by cask or elpa or 294 | spacemacs, you can skip following code. 295 | 296 | #+BEGIN_SRC emacs-lisp 297 | ;; Add directories to emacs's `load-path' recursively. 298 | ;; if path does not exist, create directory. 299 | (let* ((lisp-dir '("local-lisp/" "theme/"))) 300 | (dolist (lisp-path lisp-dir) 301 | (when (not (file-exists-p lisp-path)) 302 | (make-directory (concat user-emacs-directory lisp-path) t)) 303 | (let* ((load-dir (concat user-emacs-directory lisp-path)) 304 | (default-directory load-dir)) 305 | (setq load-path 306 | (append 307 | (let ((load-path (copy-sequence load-path))) 308 | (append 309 | (copy-sequence (normal-top-level-add-to-load-path '("."))) 310 | (normal-top-level-add-subdirs-to-load-path))) 311 | load-path))))) 312 | #+END_SRC 313 | 314 | * Spacemacs 315 | 316 | [[https://github.com/syl20bnr/spacemacs][Spacemacs]] is an emacs starterkit focus on [[https://gitorious.org/evil/pages/Home][Evil]], which emulate vim keymap on 317 | Emacs. 318 | 319 | I make my emacs on top of spacemacs since I also use vim keymap. 320 | 321 | In my config file, the original =~/.spacemacs= file has moved to 322 | =~/.emacs.d/spacemacs.d/init.el= , I also advice spacemacs funtion to 323 | prevent orphan packages deleted by spacemacs. 324 | 325 | After all spacemacs init done, switch back to =*scratch*= buffer. 326 | 327 | ** Load basic spacemacs configuration file 328 | 329 | Latest spacemacs can setup =SPACEMACSDIR= to load customize spacemacs init.el 330 | file. 331 | 332 | #+BEGIN_SRC emacs-lisp 333 | (setenv "SPACEMACSDIR" (concat user-emacs-directory "spacemacs.d")) 334 | #+END_SRC 335 | 336 | ** Overwrite spacemacs function to let it not remove my packages 337 | 338 | I use =Cask= to handle all packages, spacemacs should do nothing here. 339 | 340 | #+BEGIN_SRC emacs-lisp 341 | ;; Make spacemacs not remove my packages. 342 | (defadvice configuration-layer/delete-orphan-packages (around null-func activate) 343 | "Overwrite the spacemacs's `configuration-layer/delete-orphan-packages' 344 | to make it not remove any orphan packages.") 345 | #+END_SRC 346 | 347 | ** Spacemacs no need to check newer version 348 | 349 | Since my spacemacs is installed as submodule, it's no need to check for newer 350 | version, I'll handle this myself. 351 | 352 | #+BEGIN_SRC emacs-lisp 353 | (defadvice spacemacs/check-for-new-version (around null-func activate) 354 | "Overwrite the spacemacs's `spacemacs/check-for-new-version' to 355 | makt it useless since I use git submodule to bundle spacemacs with my emacs.") 356 | #+END_SRC 357 | 358 | ** Load spacemacs 359 | 360 | The original spacemacs is suggest to clone it to =~/.emacs.d=, I really not like 361 | this. Instead, I move it to =~/.emacs.d/modules/spacemacs= so I can use org-mode 362 | with literature writing. 363 | 364 | #+BEGIN_SRC emacs-lisp 365 | ;; Make a fake entry point for spacemacs, also modify the 366 | ;; `user-emacs-directory' temporary to mislead spacemacs real emacs 367 | ;; directory. 368 | (require 'f) 369 | (let* ((spacemacs-dir 370 | (directory-file-name (f-join user-emacs-directory "modules" "spacemacs"))) 371 | (spacemacs-init 372 | (concat (file-name-as-directory spacemacs-dir) "init.el")) 373 | (user-emacs-directory (file-name-directory spacemacs-init))) 374 | ;; Initial spacemacs, our emacs run on top of it 375 | (load spacemacs-init)) 376 | #+END_SRC 377 | 378 | ** Some function should execute after loading spacemacs-init. 379 | 380 | spacemacs is really awesome, but there's something I don't like. 381 | 382 | *** Disable global highlight by default 383 | 384 | #+BEGIN_SRC emacs-lisp 385 | (global-hl-line-mode -1) 386 | #+END_SRC 387 | 388 | *** switch back to `*scratch*' buffer after loading spacemacs finished 389 | 390 | #+BEGIN_SRC emacs-lisp 391 | ;; After spacemacs loading finished, switch back to `*scratch*' buffer 392 | ;; and make sure it's in `lisp-interaction-mode' 393 | (switch-to-buffer "*scratch*") 394 | (with-current-buffer (get-buffer-create "*scratch*") 395 | (lisp-interaction-mode)) 396 | #+END_SRC 397 | 398 | *** Not use ido-mode 399 | 400 | I don't like the =ido-mode=. 401 | 402 | #+BEGIN_SRC emacs-lisp 403 | (ido-mode -1) 404 | #+END_SRC 405 | 406 | *** Move helm input in minibuffer 407 | 408 | I *really* hate spacemacs default echo the helm input in header line, it's 409 | really annoying. 410 | 411 | #+BEGIN_SRC emacs-lisp 412 | (setq helm-echo-input-in-header-line nil) 413 | (remove-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe) 414 | #+END_SRC 415 | 416 | * Basic setup 417 | 418 | Most setup I want to use is done by [[https://github.com/syl20bnr/spacemacs][spacemacs]], but I still keep some basic setup 419 | here, some are not set or just keep for backward compability. 420 | 421 | ** Startup emacs server 422 | 423 | #+BEGIN_SRC emacs-lisp 424 | ;; Only start server mode if I'm not root 425 | (unless (string-equal "root" (getenv "USER")) 426 | (require 'server) 427 | (unless (server-running-p) (server-start))) 428 | #+END_SRC 429 | 430 | ** Under Mac OSX use Command key as ALT 431 | 432 | Under Mac OSX, I always bind =Caps lock= as Control key, and make the =Command= 433 | key as =ALT= key like I done in Linux. 434 | 435 | The =Option= key will be setup as =Super=. 436 | 437 | We also disable some keys like =⌘-h= bypass to system in emacs-mac port. 438 | 439 | #+BEGIN_SRC emacs-lisp 440 | (setq mac-option-modifier 'super) 441 | (setq mac-command-modifier 'meta) 442 | (setq mac-pass-command-to-system nil) 443 | #+END_SRC 444 | 445 | ** Don't ask me when close emacs with process is running 446 | 447 | #+BEGIN_SRC emacs-lisp 448 | (when (require 'noflet) 449 | (defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate) 450 | "Prevent annoying \"Active processes exist\" query when you quit Emacs." 451 | (noflet ((process-list ())) ad-do-it))) 452 | #+END_SRC 453 | 454 | ** Don't ask me when kill process buffer 455 | 456 | #+BEGIN_SRC emacs-lisp 457 | (setq kill-buffer-query-functions 458 | (remq 'process-kill-buffer-query-function 459 | kill-buffer-query-functions)) 460 | #+END_SRC 461 | 462 | ** Save custom-file as cache 463 | 464 | Most of my config is written in this file, it's no need to tracking the emacs's 465 | custom-setting. 466 | 467 | I move the file to cache-dir and make git ignore it. 468 | 469 | #+BEGIN_SRC emacs-lisp 470 | (setq-default custom-file (concat user-cache-directory "custom.el")) 471 | ;; load custom-file only when file exist 472 | (when (file-exists-p custom-file) 473 | (load-file custom-file)) 474 | #+END_SRC 475 | 476 | ** Async rebuild init.el after save 477 | 478 | #+BEGIN_SRC emacs-lisp 479 | (when (require 'async nil 'noerror) 480 | ;; If I'm edit my init.org, async generate init.el when save. 481 | (defun tangle-init () 482 | "If the current buffer is 'init.org' the code-blocks are tangled." 483 | (let ((buffer-name "async-make-init.el")) 484 | (when (equal (buffer-file-name) 485 | (expand-file-name (concat user-emacs-directory "init.org"))) 486 | ;; If previous building buffer exist, discard it 487 | (when (get-buffer (concat "*" buffer-name "*")) 488 | (kill-buffer (concat "*" buffer-name "*"))) 489 | ;; build with `make init.el' command 490 | (async-start-process buffer-name "make" 'ignore "init.el")))) 491 | ;; Add to hook 492 | (add-hook 'after-save-hook 'tangle-init)) 493 | #+END_SRC 494 | 495 | ** Turn-off menu bar 496 | 497 | The menu bar is one of the UI elements which work best with mouses. 498 | 499 | #+BEGIN_SRC emacs-lisp 500 | (menu-bar-mode -1) 501 | #+END_SRC 502 | 503 | ** Turn-off tool bar 504 | 505 | I never use the tool bar, it's really no need. 506 | 507 | #+BEGIN_SRC emacs-lisp 508 | (tool-bar-mode -1) 509 | #+END_SRC 510 | 511 | ** Turn-off blinking cursor 512 | 513 | I hate the blinking cursor actually, it's really annoying. 514 | 515 | #+BEGIN_SRC emacs-lisp 516 | (blink-cursor-mode -1) 517 | #+END_SRC 518 | 519 | ** Turn-off scroll bar 520 | 521 | Actually when you familier with emacs, you don't need to use scroll-bar anymore. 522 | 523 | #+BEGIN_SRC emacs-lisp 524 | (scroll-bar-mode -1) 525 | #+END_SRC 526 | 527 | ** Ask for y or n, not yes or no 528 | 529 | Emacs starts out asking for you to type yes or no with most important questions. 530 | Just let me use =y= or =n= with no =RET= required an I'm quite happy. 531 | 532 | #+BEGIN_SRC emacs-lisp 533 | (defalias 'yes-or-no-p 'y-or-n-p) 534 | #+END_SRC 535 | 536 | * Languages and Encodings 537 | 538 | Since current Emacs default run on UTF-8, it's no need to setup the encoding. 539 | 540 | For language, though Traditional Chinese is my mothertone, I still prefer use 541 | =en_US= to display time info. 542 | 543 | #+BEGIN_SRC emacs-lisp 544 | (prefer-coding-system 'utf-8) 545 | (setq system-time-locale "en_US") 546 | #+END_SRC 547 | 548 | * Buildin Packages :buildin: 549 | 550 | Some buildin packages not loaded by emacs, load it here. 551 | 552 | ** cl-lib 553 | 554 | #+BEGIN_SRC emacs-lisp 555 | (req-package cl-lib) 556 | #+END_SRC 557 | 558 | ** htmlize :htmlize: 559 | 560 | #+BEGIN_SRC emacs-lisp 561 | (req-package htmlize) 562 | #+END_SRC 563 | 564 | * External Packages :packages: 565 | 566 | Most of emacs packages do not need many configs or just provide 567 | commands/functions to use, I put them here. 568 | 569 | ** 4clojure 570 | 571 | [[https://github.com/losingkeys/4clojure.el][4clojure.el]] let you open and evaluate [[http://www.4clojure.com/][4clojure]] questions. 572 | 573 | #+BEGIN_SRC emacs-lisp 574 | (req-package 4clojure) 575 | #+END_SRC 576 | 577 | ** ascii 578 | 579 | [[http://www.emacswiki.org/emacs/AsciiMode][Ascii]] provides a way to display ASCII code on a window, that is, display in 580 | another window an ASCII table highlighting the current character code. 581 | 582 | #+BEGIN_SRC emacs-lisp 583 | (req-package ascii 584 | :init (progn 585 | ;; ascii-toggle 586 | (defun ascii-toggle () 587 | "Toggle ascii-mode." 588 | (interactive) 589 | (if (not (ascii-off)) (ascii-on))) 590 | 591 | ;; alias ascii to ascii-toggle 592 | (defalias 'ascii 'ascii-toggle))) 593 | #+END_SRC 594 | 595 | ** ascii-art-to-unicode 596 | 597 | Convert simple ASCII art drawings (and org-tables) to beautiful Unicode. 598 | 599 | #+BEGIN_SRC emacs-lisp 600 | (req-package ascii-art-to-unicode) 601 | #+END_SRC 602 | 603 | ** iedit 604 | 605 | [[https://github.com/victorhge/iedit][iedit]] let you edit multiple regions in the same way simultaneously. 606 | 607 | GitHub: https://github.com/victorhge/iedit 608 | 609 | #+BEGIN_SRC emacs-lisp 610 | (req-package iedit) 611 | #+END_SRC 612 | 613 | ** pangu-spacing 614 | 615 | [[https://github.com/coldnew/pangu-spacing][pangu-spcing]] is an minor-mode to auto add =space= between Chinese and English 616 | characters. Note that these white-space characters are not really added to the 617 | contents, it just like to do so. 618 | 619 | #+BEGIN_SRC emacs-lisp 620 | (req-package pangu-spacing 621 | :init 622 | (progn 623 | ;; start pangu-spacing globally 624 | (global-pangu-spacing-mode 1) 625 | ;; Always insert `real' space in org-mode. 626 | (add-hook 'org-mode-hook 627 | '(lambda () 628 | (set (make-local-variable 'pangu-spacing-real-insert-separtor) t))))) 629 | #+END_SRC 630 | 631 | ** sx 632 | 633 | [[https://github.com/vermiculus/sx.el/][SX]] is a full featured Stack Exchange mode for GNU Emacs 24+. Using the official 634 | API, it provides a versatile experience for the Stack Exchange network within 635 | Emacs itself. 636 | 637 | #+BEGIN_SRC emacs-lisp 638 | (req-package sx :require sx-load) 639 | #+END_SRC 640 | 641 | ** hungry-delete 642 | 643 | [[https://github.com/nflath/hungry-delete][hungry-delete]] borrows hungry deletion from =cc-mode=, which will causes deletion 644 | to delete all whitespace in the direction you are deleting. 645 | 646 | #+BEGIN_SRC emacs-lisp 647 | (req-package hungry-delete 648 | :init (global-hungry-delete-mode)) 649 | #+END_SRC 650 | 651 | ** rainbow-mode 652 | 653 | [[https://julien.danjou.info/projects/emacs-packages][rainbow-mode]] s a minor mode for Emacs which displays strings representing colors 654 | with the color they represent as background. 655 | 656 | #+BEGIN_SRC emacs-lisp 657 | (req-package rainbow-mode) 658 | #+END_SRC 659 | 660 | ** doxymacs 661 | 662 | #+BEGIN_SRC emacs-lisp 663 | (req-package doxymacs 664 | :config 665 | (add-hook 'prog-mode-hook '(lambda () (doxymacs-mode)))) 666 | #+END_SRC 667 | 668 | ** password-generator 669 | 670 | [[https://github.com/zargener/emacs-password-genarator][password-generator]] provides simple functions to create passwords and insert them 671 | inside buffer immediately. 672 | 673 | #+BEGIN_SRC emacs-lisp 674 | (req-package password-generator) 675 | #+END_SRC 676 | 677 | ** discover-my-major 678 | 679 | [[https://github.com/steckerhalter/discover-my-major][discover-my-major]] make you discover key bindings and their meaning for the 680 | current Emacs major mode. 681 | 682 | #+BEGIN_SRC emacs-lisp 683 | (req-package discover-my-major) 684 | #+END_SRC 685 | 686 | ** howdoi 687 | 688 | [[https://github.com/atykhonov/emacs-howdoi][howdoi]] is a way to query Stack Overflow directly from the Emacs and get back the 689 | most upvoted answer to the first question that comes up for that query. 690 | 691 | #+BEGIN_SRC emacs-lisp 692 | (req-package howdoi) 693 | #+END_SRC 694 | 695 | ** exec-path-from-shell 696 | 697 | [[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] is A GNU Emacs library to ensure environment variables 698 | inside Emacs look the same as in the user's shell. 699 | 700 | Ever find that a command works in your shell, but not in Emacs? 701 | 702 | This happens a lot on OS X, where an Emacs instance started from the GUI 703 | inherits a default set of environment variables. 704 | 705 | This library works solves this problem by copying important environment 706 | variables from the user's shell: it works by asking your shell to print out the 707 | variables of interest, then copying them into the Emacs environment. 708 | 709 | #+BEGIN_SRC emacs-lisp 710 | (req-package exec-path-from-shell 711 | :init (when (memq window-system '(mac ns x)) 712 | (exec-path-from-shell-initialize))) 713 | #+END_SRC 714 | 715 | ** manage-minor-mode 716 | 717 | [[https://github.com/ShingoFukuyama/manage-minor-mode][manage-minor-mode]] let you manage your minor-mode on the dedicated interface 718 | buffer. 719 | 720 | #+BEGIN_SRC emacs-lisp 721 | (req-package manage-minor-mode) 722 | #+END_SRC 723 | 724 | ** noflet 725 | 726 | GitHub: https://github.com/nicferrier/emacs-noflet 727 | 728 | #+BEGIN_SRC emacs-lisp 729 | (req-package noflet) 730 | #+END_SRC 731 | 732 | ** mustache :mustache: 733 | 734 | A mustache templating library in Emacs Lisp. 735 | 736 | GitHub: https://github.com/Wilfred/mustache.el 737 | 738 | #+BEGIN_SRC emacs-lisp 739 | (req-package mustache) 740 | #+END_SRC 741 | 742 | ** manage-minor-mode 743 | 744 | Manage your minor-mode on the dedicated interface buffer. 745 | 746 | GitHub: https://github.com/ShingoFukuyama/manage-minor-mode 747 | 748 | #+BEGIN_EXAMPLE 749 | (req-package manage-minor-mode) 750 | #+END_EXAMPLE 751 | 752 | ** expand-region 753 | 754 | Expand region increases the selected region by semantic units. Just keep 755 | pressing the key until it selects what you want. 756 | 757 | GitHub: https://github.com/magnars/expand-region.el 758 | 759 | #+BEGIN_SRC emacs-lisp 760 | (req-package expand-region) 761 | #+END_SRC 762 | 763 | ** verify-url 764 | 765 | verify-url is a little tool that used to find out invalid urls in the buffer or 766 | region. 767 | 768 | Use =M-x verify-url= to find invalid urls in current buffer. 769 | 770 | After executed command, you can use =verify-url/next-invalid-url= to goto next 771 | invalid-url or =verify-url/previous-invalid-url= to goto previous one. 772 | 773 | GitHub: https://github.com/lujun9972/verify-url 774 | 775 | #+BEGIN_SRC emacs-lisp 776 | (req-package verify-url) 777 | #+END_SRC 778 | 779 | ** zzz-to-char 780 | 781 | This package provides two new commands: =zzz-to-char= and =zzz-up-to-char= which 782 | work like built-ins zap-to-char and zap-up-to-char, but allow you quickly select 783 | exact character you want to “zzz” to. 784 | 785 | The commands are minimalistic and often work like built-in ones when there is 786 | only one occurrence of target character (except they automatically work in 787 | backward direction too). You can also specify how many characters to scan from 788 | each side of point, see =zzz-to-char-reach=. 789 | 790 | This package uses avy as backend. 791 | 792 | GitHub: https://github.com/mrkkrp/zzz-to-char 793 | 794 | #+BEGIN_SRC emacs-lisp 795 | (req-package zzz-to-char) 796 | #+END_SRC 797 | 798 | * Interactive Commands :command: 799 | 800 | In emacs, we can use =M-x= to execute interactive commands, I 801 | implement some of them to make my emacs more easy to use. 802 | 803 | ** Buffers :buffer: 804 | 805 | *** Kill all buffers except *scratch* buffer 806 | 807 | Sometimes I just want to kill all buffers, this command will kill all 808 | of them and make =*scratch*= buffer alone. 809 | 810 | #+BEGIN_SRC emacs-lisp 811 | (defun nuke-all-buffers () 812 | "Kill all buffers, leaving *scratch* only." 813 | (interactive) 814 | (mapcar (lambda (x) (kill-buffer x)) (buffer-list)) 815 | (delete-other-windows)) 816 | #+END_SRC 817 | 818 | *** Make emacs can always save buffers (even if file is not modified) 819 | 820 | The default command *save-buffer* will not really save file when it 821 | untouched, use this command can let me force save file even if file is 822 | not modified. 823 | 824 | #+BEGIN_SRC emacs-lisp 825 | (defun save-buffer-always () 826 | "Save the buffer even if it is not modified." 827 | (interactive) 828 | (set-buffer-modified-p t) 829 | (save-buffer)) 830 | #+END_SRC 831 | 832 | *** Abort minibuffer recursive edit 833 | 834 | #+BEGIN_SRC emacs-lisp 835 | (defun minibuffer-keyboard-quit () 836 | "Abort recursive edit. 837 | In Delete Selection mode, if the mark is active, just deactivate it; 838 | then it takes a second \\[keyboard-quit] to abort the minibuffer." 839 | (interactive) 840 | (if (and delete-selection-mode transient-mark-mode mark-active) 841 | (setq deactivate-mark t) 842 | (when (get-buffer "*Completions*") (delete-windows-on "*Completions*")) 843 | (abort-recursive-edit))) 844 | #+END_SRC 845 | 846 | *** Make buffer untabify 847 | 848 | #+BEGIN_SRC emacs-lisp 849 | (defun untabify-buffer () 850 | (interactive) 851 | (save-excursion 852 | (untabify (point-min) (point-max)))) 853 | #+END_SRC 854 | 855 | *** Indent whole buffer 856 | 857 | #+BEGIN_SRC emacs-lisp 858 | (defun indent-whole-buffer () 859 | "Indent whole buffer." 860 | (interactive) 861 | (save-excursion 862 | (indent-region (point-min) (point-max)))) 863 | #+END_SRC 864 | 865 | *** Remove buffers trailing whitespace and untabify 866 | 867 | #+BEGIN_SRC emacs-lisp 868 | (defun cleanup-buffer () 869 | "Perform a bunch of operations on the whitespace content of a buffer." 870 | (interactive) 871 | (save-excursion 872 | (delete-trailing-whitespace) 873 | (indent-region (point-min) (point-max)) 874 | (untabify (point-min) (point-max)))) 875 | #+END_SRC 876 | 877 | *** Replace the preceding sexp with its value 878 | 879 | #+BEGIN_SRC emacs-lisp 880 | (defun eval-and-replace () 881 | "Replace the preceding sexp with its value." 882 | (interactive) 883 | (backward-kill-sexp) 884 | (condition-case nil 885 | (prin1 (eval (read (current-kill 0))) 886 | (current-buffer)) 887 | (error (message "Invalid expression") 888 | (insert (current-kill 0))))) 889 | #+END_SRC 890 | 891 | *** Quick folding source block 892 | 893 | #+BEGIN_SRC emacs-lisp 894 | (defun quick-folding-source () 895 | "Use emacs buildin easy to folding code." 896 | (interactive) 897 | (set-selective-display 898 | (if selective-display nil 1))) 899 | #+END_SRC 900 | 901 | ** Edit (Insert/Remove) 902 | 903 | *** Insert U200B char 904 | 905 | == character is a =zero width space character= which is nice to 906 | use under org-mode. 907 | 908 | For more info, please see: [[https://lists.gnu.org/archive/html/emacs-orgmode/2012-09/msg00155.html][suggestion for org-emphasis-regexp-components: *U*nited *N*ations]] 909 | 910 | #+BEGIN_SRC emacs-lisp 911 | (defun insert-U200B-char () 912 | "Insert char, this character is nice use in org-mode." 913 | (interactive) 914 | (insert "\ufeff")) 915 | #+END_SRC 916 | 917 | *** Insert empty line after current line 918 | 919 | #+BEGIN_SRC emacs-lisp 920 | (defun insert-empty-line () 921 | "Insert an empty line after current line and position cursor on newline." 922 | (interactive) 923 | (move-end-of-line nil) 924 | (open-line 1) 925 | (next-line 1)) 926 | #+END_SRC 927 | 928 | *** Insert lorem ipsum 929 | 930 | #+BEGIN_SRC emacs-lisp 931 | (defun insert-lorem () 932 | "Insert a lorem ipsum." 933 | (interactive) 934 | (insert "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do " 935 | "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" 936 | "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " 937 | "aliquip ex ea commodo consequat. Duis aute irure dolor in " 938 | "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla " 939 | "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in " 940 | "culpa qui officia deserunt mollit anim id est laborum.")) 941 | #+END_SRC 942 | 943 | *** Delete word 944 | 945 | #+BEGIN_SRC emacs-lisp 946 | (defun delete-word (arg) 947 | "Delete characters forward until encountering the end of a word. 948 | With argument, do this that many times." 949 | (interactive "p") 950 | (delete-region (point) (progn (forward-word arg) (point)))) 951 | #+END_SRC 952 | 953 | *** Backward delete word 954 | 955 | #+BEGIN_SRC emacs-lisp 956 | (defun backward-delete-word (arg) 957 | "Delete characters backward until encountering the end of a word. 958 | With argument, do this that many times." 959 | (interactive "p") 960 | (delete-word (- arg))) 961 | #+END_SRC 962 | 963 | *** Set mark or expand region 964 | 965 | #+BEGIN_SRC emacs-lisp 966 | (defun set-mark-mode/rectangle-mark-mode () 967 | "toggle between set-mark-command or rectangle-mark-mode" 968 | (interactive) 969 | (if (not mark-active) 970 | (call-interactively 'set-mark-command) 971 | (call-interactively 'rectangle-mark-mode))) 972 | #+END_SRC 973 | 974 | *** Indent region/buffer and cleanup 975 | 976 | #+BEGIN_SRC emacs-lisp 977 | (defun indent-region-or-buffer-and-cleanup () 978 | "Indents a region if selected, otherwise the whole buffer." 979 | (interactive) 980 | (cl-flet ((format-fn (BEG END) (indent-region BEG END) (untabify BEG END))) 981 | (save-excursion 982 | (if (region-active-p) 983 | (progn 984 | (delete-trailing-whitespace (region-beginning) (region-end)) 985 | (format-fn (region-beginning) (region-end)) 986 | (message "Indented selected region and clear whitespace and untabify.")) 987 | (progn 988 | (delete-trailing-whitespace) 989 | (format-fn (point-min) (point-max)) 990 | (message "Indented whole buffer and clear whitespace and untabify.")))))) 991 | #+END_SRC 992 | 993 | ** File Handle 994 | 995 | *** Reopen file as root 996 | 997 | #+BEGIN_SRC emacs-lisp 998 | (defun file-reopen-as-root () 999 | (interactive) 1000 | (when buffer-file-name 1001 | (find-alternate-file 1002 | (concat "/sudo:root@localhost:" 1003 | buffer-file-name)))) 1004 | #+END_SRC 1005 | 1006 | *** Delete current buffer file 1007 | 1008 | #+BEGIN_SRC emacs-lisp 1009 | (defun delete-current-buffer-file () 1010 | "Removes file connected to current buffer and kills buffer." 1011 | (interactive) 1012 | (let ((filename (buffer-file-name)) 1013 | (buffer (current-buffer)) 1014 | (name (buffer-name))) 1015 | (if (not (and filename (file-exists-p filename))) 1016 | (ido-kill-buffer) 1017 | (when (yes-or-no-p "Are you sure you want to remove this file? ") 1018 | (delete-file filename) 1019 | (kill-buffer buffer) 1020 | (message "File '%s' successfully removed" filename))))) 1021 | #+END_SRC 1022 | 1023 | *** Rename current Buffer and file 1024 | 1025 | #+BEGIN_SRC emacs-lisp 1026 | (defun rename-current-buffer-file () 1027 | "Renames current buffer and file it is visiting." 1028 | (interactive) 1029 | (let ((name (buffer-name)) 1030 | (filename (buffer-file-name))) 1031 | (if (not (and filename (file-exists-p filename))) 1032 | (error "Buffer '%s' is not visiting a file!" name) 1033 | (let ((new-name (read-file-name "New name: " filename))) 1034 | (if (get-buffer new-name) 1035 | (error "A buffer named '%s' already exists!" new-name) 1036 | (rename-file filename new-name 1) 1037 | (rename-buffer new-name) 1038 | (set-visited-file-name new-name) 1039 | (set-buffer-modified-p nil) 1040 | (message "File '%s' successfully renamed to '%s'" 1041 | name (file-name-nondirectory new-name))))))) 1042 | #+END_SRC 1043 | 1044 | *** Add executable attribute to file 1045 | 1046 | Actually this command is the same as =chmod +x= but it doesn't use any shell 1047 | command, it use emacs's logior function to change file attribute. 1048 | 1049 | I only make =owener= can has executable permission, not change it for gourp or 1050 | others user. 1051 | 1052 | #+BEGIN_SRC emacs-lisp 1053 | (defun set-file-executable() 1054 | "Add executable permissions on current file." 1055 | (interactive) 1056 | (when (buffer-file-name) 1057 | (set-file-modes buffer-file-name 1058 | (logior (file-modes buffer-file-name) #o100)) 1059 | (message (concat "Made " buffer-file-name " executable")))) 1060 | #+END_SRC 1061 | 1062 | *** Clone current file to new one 1063 | 1064 | #+BEGIN_SRC emacs-lisp 1065 | (defun clone-file-and-open (filename) 1066 | "Clone the current buffer writing it into FILENAME and open it" 1067 | (interactive "FClone to file: ") 1068 | (save-restriction 1069 | (widen) 1070 | (write-region (point-min) (point-max) filename nil nil nil 'confirm)) 1071 | (find-file filename)) 1072 | #+END_SRC 1073 | 1074 | ** Debug 1075 | 1076 | *** Eval emacs buffer until error 1077 | 1078 | A really nice command help me to find error on elisp buffer. 1079 | 1080 | #+BEGIN_SRC emacs-lisp 1081 | (defun eval-buffer-until-error () 1082 | "Evaluate emacs buffer until error occured." 1083 | (interactive) 1084 | (goto-char (point-min)) 1085 | (while t (eval (read (current-buffer))))) 1086 | #+END_SRC 1087 | 1088 | * Theme :theme: 1089 | 1090 | I always use dark theme for coding, [[https://github.com/kuanyui/moe-theme.el][moe-theme]] is a good start point, it's bright 1091 | and has good default faces for most modes. It also has dark and light versions, 1092 | which is convenient. 1093 | 1094 | However, I always want to customize everything on my own, so I rebuild another 1095 | emacs theme called =coldnew-theme-night= and =coldnew-theme-day=, you can find 1096 | them at [[file:theme/coldnew-theme.el]]. 1097 | 1098 | Before use emacs's =load-theme= function, I advise it to it fully 1099 | unload previous theme before loading a new one. 1100 | 1101 | #+BEGIN_SRC emacs-lisp 1102 | ;; Make `load-theme' fully unload previous theme before loading a new one. 1103 | (defadvice load-theme 1104 | (before theme-dont-propagate activate) 1105 | (mapc #'disable-theme custom-enabled-themes)) 1106 | 1107 | ;; My light theme 1108 | (req-package coldnew-theme-day-theme 1109 | :require (powerline powerline-evil)) 1110 | 1111 | ;; My night them (default) 1112 | (req-package coldnew-theme-night-theme 1113 | :config (coldnew-theme-night)) 1114 | 1115 | ;; (req-package coldnew-modeline-config 1116 | ;; :require (powerline powerline-evil)) 1117 | ;; TODO: 1118 | (req-package spaceline) 1119 | #+END_SRC 1120 | 1121 | * Minibuffer :minibuffer: 1122 | 1123 | #+BEGIN_SRC emacs-lisp 1124 | (req-package minibuffer 1125 | :config 1126 | (progn 1127 | ;; Make cursor in minibufer use bar shape 1128 | (add-hook 'minibuffer-setup-hook '(lambda () (setq cursor-type 'bar))))) 1129 | #+END_SRC 1130 | 1131 | ** Setup keybindings :keybinding: 1132 | 1133 | Some general purpose keybinding I famillier with. 1134 | 1135 | #+BEGIN_SRC emacs-lisp 1136 | (define-key minibuffer-local-map (kbd "C-w") 'backward-kill-word) 1137 | (define-key minibuffer-local-map (kbd "M-p") 'previous-history-element) 1138 | (define-key minibuffer-local-map (kbd "M-n") 'next-history-element) 1139 | (define-key minibuffer-local-map (kbd "C-g") 'minibuffer-keyboard-quit) 1140 | #+END_SRC 1141 | 1142 | Some shortcuts let me access system path more easily. 1143 | 1144 | #+BEGIN_SRC emacs-lisp 1145 | (add-hook 1146 | 'minibuffer-setup-hook 1147 | '(lambda () 1148 | ;; switch to tmp dir 1149 | (define-key minibuffer-local-map 1150 | (kbd "M-t") '(lambda() 1151 | (interactive) 1152 | (let ((dir (if (eq system-type 'darwin) 1153 | "/Volumes/ramdisk/" "/tmp/"))) 1154 | (kill-line 0) (insert dir)))) 1155 | 1156 | ;; switch to home dir 1157 | (define-key minibuffer-local-map 1158 | (kbd "M-h") '(lambda() (interactive) (kill-line 0) 1159 | (insert (file-name-as-directory (getenv "HOME"))))) 1160 | 1161 | ;; other with C-x prefix to prevent conflict with helm 1162 | (define-key minibuffer-local-map 1163 | (kbd "C-x r") '(lambda() (interactive) (kill-line 0) (insert "/"))) 1164 | 1165 | ;; More easy for tramp connect 1166 | (define-key minibuffer-local-map 1167 | (kbd "C-x s") '(lambda() (interactive) (kill-line 0) (insert "/ssh:"))) 1168 | )) 1169 | #+END_SRC 1170 | 1171 | * Editors :editor: 1172 | 1173 | Why emacs config has an editor section, doesn't means emacs is not an editor ? 1174 | Yes, Emacs is an OS :) 1175 | 1176 | I put some editor/IDE relative functions and packages here. 1177 | 1178 | ** Line Numbers :linum: 1179 | 1180 | In most case, I'll make line numers display globally by =linum=. 1181 | 1182 | #+BEGIN_SRC emacs-lisp 1183 | (req-package linum :init (global-linum-mode 1)) 1184 | #+END_SRC 1185 | 1186 | Disable line number in some mode, for example, since =org-mode= can 1187 | has many lines, it's not recommand to enable linum-mode. 1188 | 1189 | I use =linum-off= to disable some mode. 1190 | 1191 | #+BEGIN_SRC emacs-lisp 1192 | (req-package linum-off 1193 | :config 1194 | (progn 1195 | (setq linum-disabled-mode-list 1196 | '(eshell-mode shell-mode term-mode erc-mode compilation-mode 1197 | woman-mode w3m-mode calendar-mode org-mode 1198 | )))) 1199 | #+END_SRC 1200 | 1201 | ** Keeping files in sync 1202 | 1203 | By default, Emacs will not update the contents of open buffers when a file 1204 | changes on disk. This is inconvenient when switching branches in Git - as you’d 1205 | risk editing stale buffers. 1206 | 1207 | This problem can be solved by: 1208 | 1209 | #+BEGIN_SRC emacs-lisp 1210 | (global-auto-revert-mode 1) 1211 | (setq global-auto-revert-non-file-buffers t) 1212 | (setq auto-revert-verbose nil) 1213 | (setq revert-without-query '(".*")) ;; disable revert query 1214 | #+END_SRC 1215 | 1216 | ** Colorfy delimters 1217 | 1218 | [[https://github.com/Fanael/rainbow-delimiters][rainbow-delimiters]] is a "rainbow parentheses"-like mode which 1219 | highlights delimiters such as parentheses, brackets or braces 1220 | according to their depth. Each successive level is highlighted in a 1221 | different color. This makes it easy to spot matching delimiters, 1222 | orient yourself in the code, and tell which statements are at a given 1223 | depth. 1224 | 1225 | #+BEGIN_SRC emacs-lisp 1226 | (req-package rainbow-delimiters 1227 | :config 1228 | (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)) 1229 | #+END_SRC 1230 | 1231 | ** Vim Emulation :evil: 1232 | 1233 | Though I am really familier with emacs, I still like some vim command. 1234 | 1235 | #+BEGIN_SRC emacs-lisp :noweb no-export :exports code 1236 | (req-package evil 1237 | :require (undo-tree) 1238 | :init (evil-mode t) 1239 | :config 1240 | (progn 1241 | ;; default state set to insert-state 1242 | (setq evil-default-state 'insert) 1243 | ;; Bind all emacs-state key to insert state 1244 | (setcdr evil-insert-state-map nil) 1245 | (define-key evil-insert-state-map 1246 | (read-kbd-macro evil-toggle-key) 'evil-emacs-state) 1247 | ;; Make sure `ESC' in insert-state will call `evil-normal-state' 1248 | (define-key evil-insert-state-map [escape] 'evil-normal-state) 1249 | ;; Make all emacs-state buffer become to insert-state 1250 | (dolist (m evil-emacs-state-modes) 1251 | (add-to-list 'evil-insert-state-modes m)) 1252 | )) 1253 | #+END_SRC 1254 | 1255 | ** Add support for editorconfig :editorconfig: 1256 | 1257 | [[http://editorconfig.org/][EditorConfig]] helps developers define and maintain consistent coding 1258 | styles between different editors and IDEs. The EditorConfig project 1259 | consists of a file format for defining coding styles and a collection 1260 | of text editor plugins that enable editors to read the file format and 1261 | adhere to defined styles. EditorConfig files are easily readable and 1262 | they work nicely with version control systems. 1263 | 1264 | #+BEGIN_SRC emacs-lisp 1265 | (req-package editorconfig) 1266 | #+END_SRC 1267 | 1268 | ** En/Decrypt files by EasyPG 1269 | 1270 | #+BEGIN_SRC emacs-lisp 1271 | (req-package epa-file 1272 | :init (epa-file-enable) 1273 | :config 1274 | (progn 1275 | ;; Control whether or not to pop up the key selection dialog. 1276 | (setq epa-file-select-keys 0) 1277 | ;; Cache passphrase for symmetric encryption. 1278 | (setq epa-file-cache-passphrase-for-symmetric-encryption t))) 1279 | #+END_SRC 1280 | 1281 | ** Remote file editing :tramp: 1282 | 1283 | #+BEGIN_SRC emacs-lisp 1284 | (req-package tramp 1285 | :config 1286 | (progn 1287 | (setq tramp-default-method "rsync"))) 1288 | #+END_SRC 1289 | 1290 | ** Intelligently call whitespace-cleanup on save :whitespace: 1291 | 1292 | This Emacs library minor mode will intelligently call =whitespace-cleanup= before 1293 | buffers are saved. 1294 | 1295 | =whitespace-cleanup= is a handy function, but putting it in =before-save-hook= 1296 | for every buffer is overkill, and causes messy diffs when editing third-party 1297 | code that did not initially have clean whitespace. 1298 | 1299 | Additionally, whitespace preferences are often project-specific, and it's 1300 | inconvenient to set up =before-save-hook= in a =.dir-locals.el= file. 1301 | 1302 | =whitespace-cleanup-mode= is a minor mode which calls =whitespace-cleanup= 1303 | before saving the current buffer, but only if the whitespace in the buffer was 1304 | initially clean. It determines this by quickly checking to see if 1305 | =whitespace-cleanup= would have any effect on the buffer. 1306 | 1307 | GitHub: https://github.com/purcell/whitespace-cleanup-mode 1308 | 1309 | #+BEGIN_SRC emacs-lisp 1310 | (req-package whitespace-cleanup-mode 1311 | :init (add-hook 'prog-mode-hook 'whitespace-cleanup-mode)) 1312 | #+END_SRC 1313 | 1314 | ** Highlight numbers 1315 | 1316 | =highlight-numbers= is an Emacs minor mode that highlights numeric literals in 1317 | source code. 1318 | 1319 | GitHub: https://github.com/Fanael/highlight-numbers 1320 | 1321 | #+BEGIN_SRC emacs-lisp 1322 | (req-package highlight-numbers 1323 | :init 1324 | ;; json-mode has it's own highlight numbers method 1325 | (add-hook 'prog-mode-hook '(lambda() 1326 | (if (not (derived-mode-p 'json-mode)) 1327 | (highlight-numbers-mode))))) 1328 | #+END_SRC 1329 | 1330 | ** Highlight escape charset 1331 | 1332 | GitHub: https://github.com/dgutov/highlight-escape-sequences 1333 | 1334 | #+BEGIN_SRC emacs-lisp 1335 | (req-package highlight-escape-sequences 1336 | :config 1337 | (progn 1338 | ;; Make face the same as builtin face 1339 | (put 'font-lock-regexp-grouping-backslash 'face-alias 'font-lock-builtin-face) 1340 | 1341 | ;; Add extra modes 1342 | (add-to-list 'hes-simple-modes 'c-mode) 1343 | (add-to-list 'hes-simple-modes 'c++-mode) 1344 | 1345 | ;; Enable globally 1346 | (hes-mode 1))) 1347 | #+END_SRC 1348 | 1349 | ** Highlight FIXME, TODO 1350 | 1351 | #+begin_src emacs-lisp 1352 | (defun font-lock-comment-annotations () 1353 | "Highlight a bunch of well known comment annotations. 1354 | This functions should be added to the hooks of major modes for programming." 1355 | (font-lock-add-keywords 1356 | nil 1357 | '(("\\<\\(FIX\\(ME\\)?\\|BUG\\|HACK\\):" 1 font-lock-warning-face t) 1358 | ("\\<\\(NOTE\\):" 1 'org-level-2 t) 1359 | ("\\<\\(TODO\\):" 1 'org-todo t) 1360 | ("\\<\\(DONE\\):" 1 'org-done t)) 1361 | )) 1362 | 1363 | (add-hook 'prog-mode-hook 'font-lock-comment-annotations) 1364 | #+end_src 1365 | 1366 | ** Project management with projectile 1367 | 1368 | #+BEGIN_SRC emacs-lisp 1369 | (req-package projectile 1370 | :interpreter ("projectile" . projectil-mode)) 1371 | #+END_SRC 1372 | 1373 | ** Completion with Company mode :company: 1374 | 1375 | [[http://company-mode.github.io/][Company]] is a text completion framework for Emacs. The name stands for "complete 1376 | anything". It uses pluggable back-ends and front-ends to retrieve and display 1377 | completion candidates. 1378 | 1379 | #+BEGIN_SRC emacs-lisp 1380 | (req-package company 1381 | :init (global-company-mode 1) 1382 | :config (setq company-idle-delay nil)) 1383 | #+END_SRC 1384 | 1385 | *** Completion C/C++ headers 1386 | 1387 | #+BEGIN_SRC emacs-lisp 1388 | (req-package company-c-headers 1389 | :require company 1390 | :init (add-to-list 'company-backends 'company-c-headers)) 1391 | #+END_SRC 1392 | 1393 | *** Add quickhelp in company-mode 1394 | 1395 | #+BEGIN_SRC emacs-lisp 1396 | (req-package company-quickhelp 1397 | :require company 1398 | :init (company-quickhelp-mode 1)) 1399 | #+END_SRC 1400 | 1401 | *** Sort completion candidates by previous completion choices 1402 | 1403 | Company-statistics is a global minor mode built on top of the in-buffer 1404 | completion system company-mode. The idea is to keep a log of a certain number of 1405 | completions you choose, along with some context information, and use that to 1406 | rank candidates the next time you have to choose — hopefully showing you 1407 | likelier candidates at the top of the list. 1408 | 1409 | GitHub: https://github.com/company-mode/company-statistics 1410 | 1411 | #+BEGIN_SRC emacs-lisp 1412 | (req-package company-statistics 1413 | :config 1414 | (progn 1415 | (setq company-statistics-file (concat user-cache-directory 1416 | "company-statistics-cache.el")) 1417 | (add-hook 'after-init-hook 'company-statistics-mode))) 1418 | #+END_SRC 1419 | 1420 | *** Setup keybindings :keybinding: 1421 | 1422 | #+BEGIN_SRC emacs-lisp 1423 | (add-hook 1424 | 'company-mode-hook 1425 | '(lambda() 1426 | (define-key company-active-map (kbd "C-g") 'company-abort) 1427 | (define-key company-active-map (kbd "C-n") 'company-select-next) 1428 | (define-key company-active-map (kbd "C-p") 'company-select-previous) 1429 | (define-key company-active-map (kbd "TAB") 'company-complete-selection) 1430 | (define-key company-active-map (kbd "") 'company-complete-selection))) 1431 | #+END_SRC 1432 | 1433 | ** Snippet handle by yasnippet :yasnippet: 1434 | 1435 | #+BEGIN_SRC emacs-lisp 1436 | (req-package yasnippet 1437 | :init (yas-global-mode 1) 1438 | :mode ("emacs.+/snippets/" . snippet-mode) 1439 | :config 1440 | (progn 1441 | (setq yas/prompt-functions '(yas-dropdown-prompt 1442 | yas-completing-prompt 1443 | yas-ido-prompt)) 1444 | 1445 | (setq yas/snippet-dirs (concat user-emacs-directory "snippets")))) 1446 | #+END_SRC 1447 | 1448 | *** Implement org-mode's easy-template like function 1449 | 1450 | I really like org-mode's =easy-template= function, so I implement one called 1451 | =major-mode-expand= which will let you use easy-template like function in any 1452 | major-mode. 1453 | 1454 | #+BEGIN_SRC emacs-lisp 1455 | (eval-after-load 'yasnippet 1456 | '(progn 1457 | (defadvice yas-expand (around major-mode-expand activate) 1458 | "Try to complete a structure template before point like org-mode does. 1459 | This looks for strings like \"") 'helm-execute-persistent-action) 1540 | (define-key helm-map (kbd "C-w") 'backward-kill-word))) 1541 | #+END_SRC 1542 | 1543 | * Org :org: 1544 | 1545 | #+BEGIN_SRC emacs-lisp 1546 | (req-package org 1547 | :require (org-crypt) 1548 | :mode (("\\.org\\'" . org-mode) 1549 | ("\\.org_archive\\'" . org-mode)) 1550 | :config 1551 | (progn 1552 | ;; Always enable auto indent mode 1553 | (setq org-indent-mode t) 1554 | ;; fontify source code 1555 | (setq org-src-fontify-natively t) 1556 | ;; Use current window when switch to source block 1557 | (setq org-src-window-setup 'current-window) 1558 | ;; Disable prompting to evaluate babel blocks 1559 | (setq org-confirm-babel-evaluate nil) 1560 | ;; Disable add validation link when export to HTML 1561 | (setq org-html-validation-link nil))) 1562 | #+END_SRC 1563 | 1564 | ** Capture and Agenda 1565 | 1566 | #+BEGIN_SRC emacs-lisp 1567 | (eval-after-load 'org 1568 | '(progn 1569 | ;; make agenda show on current window 1570 | (setq org-agenda-window-setup 'current-window) 1571 | ;; highlight current in agenda 1572 | (add-hook 'org-agenda-mode-hook 'hl-line-mode) 1573 | ;; Setup files for agenda 1574 | (setq org-agenda-files (list "~/Org/task/Office.org" "~/Org/task/Personal.org")) 1575 | ;; 1576 | (setq org-directory "~/Org") 1577 | (setq org-default-notes-file (f-join org-directory "task" "Office.org")) 1578 | ;; Always use `C-g' to exit agenda 1579 | (add-hook 'org-agenda-mode-hook 1580 | '(lambda () 1581 | (local-set-key (kbd "C-g") 'org-agenda-exit))) 1582 | )) 1583 | #+END_SRC 1584 | 1585 | ** Extend org-mode's easy templates 1586 | 1587 | #+BEGIN_SRC emacs-lisp 1588 | (eval-after-load 'org 1589 | '(progn 1590 | (add-to-list 'org-structure-template-alist 1591 | '("E" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC")) 1592 | (add-to-list 'org-structure-template-alist 1593 | '("S" "#+BEGIN_SRC sh\n?\n#+END_SRC")) 1594 | (add-to-list 'org-structure-template-alist 1595 | '("p" "#+BEGIN_SRC plantuml :file uml.png \n?\n#+END_SRC")) 1596 | )) 1597 | #+END_SRC 1598 | 1599 | ** Extend babel support languages 1600 | 1601 | #+BEGIN_SRC emacs-lisp 1602 | (eval-after-load 'org 1603 | '(progn 1604 | (org-babel-do-load-languages 1605 | 'org-babel-load-languages 1606 | '((emacs-lisp . t) 1607 | (C . t) 1608 | (ditaa . t) 1609 | (dot . t) 1610 | (js . t) 1611 | (latex . t) 1612 | (perl . t) 1613 | (python . t) 1614 | (ruby . t) 1615 | (sh . t) 1616 | (plantuml . t) 1617 | (clojure . t) 1618 | )) 1619 | (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)) 1620 | )) 1621 | #+END_SRC 1622 | 1623 | ** Setup link abbreviations 1624 | 1625 | [[https://www.gnu.org/software/emacs/manual/html_node/org/Link-abbreviations.html][Link abbreviations]] 1626 | 1627 | An abbreviated link looks like 1628 | 1629 | : [[linkword:tag][description]] 1630 | 1631 | #+BEGIN_SRC emacs-lisp 1632 | (setq org-link-abbrev-alist 1633 | '(("google" . "http://www.google.com/search?q=") 1634 | ("google-map" . "http://maps.google.com/maps?q=%s") 1635 | )) 1636 | #+END_SRC 1637 | 1638 | ** Make spell-checking tool ignore some org-mode section 1639 | 1640 | see: http://emacs.stackexchange.com/questions/450/intelligent-spell-checking-in-org-mode 1641 | 1642 | #+BEGIN_SRC emacs-lisp 1643 | (eval-after-load 'ispell 1644 | '(progn 1645 | (add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:")) 1646 | (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC")) 1647 | )) 1648 | #+END_SRC 1649 | 1650 | ** Latex Export 1651 | 1652 | #+BEGIN_SRC emacs-lisp 1653 | (setq org-format-latex-options 1654 | '(:forground "black" :background "white" 1655 | :scale 1.5 1656 | :html-foreground "Black" :html-background "Transparent" 1657 | :html-scale 1.0 1658 | :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))) 1659 | #+END_SRC 1660 | 1661 | ** Setup keybindings :keybinding: 1662 | 1663 | #+BEGIN_SRC emacs-lisp :noweb yes :results silent 1664 | (add-hook 1665 | 'org-mode-hook 1666 | '(lambda() 1667 | (define-key org-mode-map (kbd "C-c b") 'org-metaleft) 1668 | (define-key org-mode-map (kbd "C-c f") 'org-metaright) 1669 | (define-key org-mode-map (kbd "C-c p") 'org-metaup) 1670 | (define-key org-mode-map (kbd "C-c p") 'org-metadown) 1671 | (define-key org-mode-map (kbd "C-c i") 'org-insert-link) 1672 | (define-key org-mode-map (kbd "C-c I") 'org-toggle-inline-images))) 1673 | #+END_SRC 1674 | 1675 | * Programming Languages 1676 | 1677 | ** Bash :bash: 1678 | 1679 | #+BEGIN_SRC emacs-lisp 1680 | (req-package flymake-shell 1681 | :require (flymake shell) 1682 | :config (add-hook 'sh-set-shell-hook 'flymake-shell-load)) 1683 | #+END_SRC 1684 | 1685 | ** Batch :bat: 1686 | 1687 | #+BEGIN_SRC emacs-lisp 1688 | (req-package batch-mode :mode "\\.bat\\'") 1689 | #+END_SRC 1690 | 1691 | ** C / C++ :cpp: 1692 | 1693 | #+BEGIN_SRC emacs-lisp 1694 | (req-package cc-mode 1695 | :mode 1696 | (("\\.h\\'" . c-mode) 1697 | ("\\.c\\'" . c-mode) 1698 | ("\\.hpp\\'" . c++-mode) 1699 | ("\\.cpp\\'" . c++-mode)) 1700 | :config 1701 | (progn 1702 | ;; use regexp to check if it's C++ header 1703 | (add-to-list 'magic-mode-alist 1704 | `(,(lambda () 1705 | (and (string= (file-name-extension (or (buffer-file-name) "")) "h") 1706 | (or (re-search-forward "#include <\\w+>" 1707 | magic-mode-regexp-match-limit t) 1708 | (re-search-forward "\\W\\(class\\|template\\namespace\\)\\W" 1709 | magic-mode-regexp-match-limit t) 1710 | (re-search-forward "std::" 1711 | magic-mode-regexp-match-limit t)))) 1712 | . c++-mode)) 1713 | )) 1714 | #+END_SRC 1715 | 1716 | *** Add eldoc support for C/C++ :eldoc: 1717 | 1718 | #+BEGIN_SRC emacs-lisp 1719 | (req-package c-eldoc 1720 | :config 1721 | (progn 1722 | (add-hook 'c-mode-common-hook 1723 | '(lambda () 1724 | (setq c-eldoc-includes "`pkg-config gtk+-3.0 --cflags --libs` -I./ -I../") 1725 | (c-turn-on-eldoc-mode))))) 1726 | #+END_SRC 1727 | 1728 | *** Highlight a few dangerous types in C/C++ :cwarn: 1729 | 1730 | [[http://www.emacswiki.org/emacs/CWarnMode][cwarn-mode]] is a minor mode that ca highlight a few dangerous types in C/C++. 1731 | 1732 | By default it highlights: 1733 | 1734 | - Semicolons right after conditions and loops (e.g. ~if (x == y);~) 1735 | - Assignments in tests (e.g. ~if (x = y) {~) 1736 | - Functions with reference parameters (e.g. ~void funct(string &p) {~) 1737 | 1738 | #+BEGIN_SRC emacs-lisp 1739 | (req-package cwarn 1740 | :init (add-hook 'c-mode-common-hook '(lambda () (cwarn-mode 1)))) 1741 | #+END_SRC 1742 | 1743 | *** Use dummy-h-mode to help detect header's major mode 1744 | 1745 | [[https://github.com/yascentur/dummy-h-mode-el][dummy-h-mode]] is an major-mode to help switch major mode to c/c++/objc-mode on .h 1746 | file. 1747 | 1748 | GitHub: https://github.com/yascentur/dummy-h-mode-el 1749 | 1750 | #+BEGIN_SRC emacs-lisp 1751 | (req-package dummy-h-mode 1752 | :require cc-mode 1753 | :mode "\\.h$" 1754 | :config 1755 | (progn 1756 | (add-hook 'dummy-h-mode-hook 1757 | (lambda () 1758 | (setq dummy-h-mode-default-major-mode 'c-mode))) 1759 | (add-hook 'dummy-h-mode-hook 1760 | (lambda () 1761 | (setq dummy-h-mode-search-limit 60000))))) 1762 | #+END_SRC 1763 | 1764 | *** Extra highlight keywords for C/C++ 1765 | 1766 | Extra hightlight for =stdint.h= 1767 | 1768 | #+BEGIN_SRC emacs-lisp 1769 | (dolist (m '(c-mode c++-mode)) 1770 | (font-lock-add-keywords 1771 | m 1772 | '(("\\<\\(int8_t\\|int16_t\\|int32_t\\|int64_t\\|uint8_t\\|uint16_t\\|uint32_t\\|uint64_t\\)\\>" . font-lock-keyword-face)))) 1773 | #+END_SRC 1774 | 1775 | *** Syntax check and code-completion with CMake project :cmake: 1776 | 1777 | [[https://github.com/redguardtoo/cpputils-cmake][cpputils-cmake]] is a nice tool for cmake project. 1778 | 1779 | GitHub: https://github.com/redguardtoo/cpputils-cmake 1780 | 1781 | #+BEGIN_SRC emacs-lisp 1782 | (req-package cpputils-cmake 1783 | :require (flymake flycheck) 1784 | :config 1785 | (progn 1786 | (add-hook 'c-mode-common-hook 1787 | (lambda () 1788 | (when (derived-mode-p 'c-mode 'c++-mode) 1789 | (cppcm-reload-all)))))) 1790 | #+END_SRC 1791 | 1792 | *** Emacs extension allowing quick switch between header and source file in C/C++ 1793 | 1794 | This extension allows to quickly switch between header and a source file with 1795 | the same name located in the directory tree or repository. It is an alternatife 1796 | to =ff-find-other-file=. 1797 | 1798 | GitHub: https://github.com/fourier/cff 1799 | 1800 | #+BEGIN_SRC emacs-lisp 1801 | (req-package cff 1802 | :config 1803 | (progn 1804 | (add-hook 'c++-mode-hook 1805 | '(lambda () 1806 | (define-key c-mode-base-map (kbd "M-o") 'cff-find-other-file))) 1807 | (add-hook 'c-mode-hook 1808 | '(lambda () 1809 | (define-key c-mode-base-map (kbd "M-o") 'cff-find-other-file))))) 1810 | #+END_SRC 1811 | 1812 | *** C language coding style 1813 | 1814 | I always use =linux coding style= for c language by default. 1815 | 1816 | #+BEGIN_SRC emacs-lisp 1817 | (add-hook 'c-mode-hook 1818 | '(lambda () 1819 | (c-set-style "linux") 1820 | (setq c-basic-offset 8) 1821 | ;; Make TAB equivilent to 8 spaces 1822 | (setq tab-width 8))) 1823 | #+END_SRC 1824 | 1825 | As part of Linux Kernel developer, I add =linux-kernel= coding style rule, which 1826 | use =tabs= as indent and follow linux kernel development rules. Use following 1827 | code to make emacs switch to =linux-kernel= style automatically when enter linux 1828 | kernel directories. 1829 | 1830 | This coding style is document in https://www.kernel.org/doc/Documentation/CodingStyle. 1831 | 1832 | #+BEGIN_SRC emacs-lisp 1833 | (defun c-lineup-arglist-tabs-only (ignored) 1834 | "Line up argument lists by tabs, not spaces" 1835 | (let* ((anchor (c-langelem-pos c-syntactic-element)) 1836 | (column (c-langelem-2nd-pos c-syntactic-element)) 1837 | (offset (- (1+ column) anchor)) 1838 | (steps (floor offset c-basic-offset))) 1839 | (* (max steps 1) 1840 | c-basic-offset))) 1841 | 1842 | ;; Add Linux kernel style 1843 | (add-hook 'c-mode-common-hook 1844 | (lambda () 1845 | (c-add-style "linux-kernel" 1846 | '("linux" (c-offsets-alist 1847 | (arglist-cont-nonempty 1848 | c-lineup-gcc-asm-reg 1849 | c-lineup-arglist-tabs-only)))))) 1850 | 1851 | (defun linux-kernel-development-setup () 1852 | (let ((filename (buffer-file-name))) 1853 | ;; Enable kernel mode for the appropriate files 1854 | (when (and filename 1855 | (or (locate-dominating-file filename "Kbuild") 1856 | (locate-dominating-file filename "Kconfig") 1857 | (save-excursion (goto-char 0) 1858 | (search-forward-regexp "^#include $" nil t)))) 1859 | ;; (setq indent-tabs-mode t) 1860 | ;; (setq show-trailing-whitespace t) 1861 | (c-set-style "linux-kernel") 1862 | (message "Setting up indentation for the linux kernel")))) 1863 | 1864 | (add-hook 'c-mode-hook 'linux-kernel-development-setup) 1865 | #+END_SRC 1866 | 1867 | *** C++ language coding style 1868 | 1869 | Use my C++ coding style. 1870 | 1871 | #+BEGIN_SRC emacs-lisp 1872 | (add-hook 'c++-mode-hook 1873 | '(lambda () 1874 | 1875 | ;; Use stroustrup style 1876 | (c-set-style "stroustrup") 1877 | 1878 | ;; Setting indentation lvel 1879 | (setq c-basic-offset 4) 1880 | 1881 | ;; Make TAB equivilent to 4 spaces 1882 | (setq tab-width 4) 1883 | 1884 | ;; Use spaces to indent instead of tabs. 1885 | (setq indent-tabs-mode nil) 1886 | 1887 | ;; Indent the continuation by 2 1888 | (setq c-continued-statement-offset 2) 1889 | 1890 | ;; Brackets should be at same indentation level as the statements they open 1891 | ;; for example: 1892 | ;; if (0) becomes if (0) 1893 | ;; { { 1894 | ;; ; ; 1895 | ;; } } 1896 | (c-set-offset 'substatement-open 0) 1897 | 1898 | ;; make open-braces after a case 1899 | (c-set-offset 'case-label '+) 1900 | 1901 | ;; Not indent code inside a namespace 1902 | ;; for example: 1903 | ;; namespace A { 1904 | ;; 1905 | ;; int namespace_global_variable; 1906 | ;; 1907 | ;; class Class { 1908 | ;; 1909 | ;; Class(); 1910 | ;; //... 1911 | ;; }; 1912 | ;; 1913 | ;; } 1914 | (c-set-offset 'innamespace 0) 1915 | )) 1916 | #+END_SRC 1917 | 1918 | *** Setup keybindings :keybinding: 1919 | 1920 | #+BEGIN_SRC emacs-lisp 1921 | ;; C 1922 | (add-hook 1923 | 'c-mode-hook 1924 | '(lambda() 1925 | (define-key helm-map (kbd "C-c C-o") 'ff-find-other-file))) 1926 | #+END_SRC 1927 | 1928 | #+BEGIN_SRC emacs-lisp 1929 | ;; C++ 1930 | (add-hook 1931 | 'c++-mode-hook 1932 | '(lambda() 1933 | (define-key helm-map (kbd "C-c C-o") 'ff-find-other-file))) 1934 | #+END_SRC 1935 | 1936 | ** CMake :c:cpp: 1937 | 1938 | #+BEGIN_SRC emacs-lisp 1939 | (req-package cmake-font-lock 1940 | :require (cmake-mode) 1941 | :init (add-hook 'cmake-mode-hook 'cmake-font-lock-activate)) 1942 | #+END_SRC 1943 | 1944 | ** GLSL :glsl: 1945 | 1946 | #+BEGIN_SRC emacs-lisp 1947 | (req-package glsl-mode 1948 | :mode (("\\.vs\\'" . glsl-mode) 1949 | ("\\.fs\\'" . glsl-mode) 1950 | ("\\.gs\\'" . glsl-mode)) 1951 | :config (setq glsl-other-file-alist '(("\\.fs$" (".vs")) 1952 | ("\\.vs$" (".fs"))))) 1953 | #+END_SRC 1954 | 1955 | ** Go :golang: 1956 | 1957 | #+BEGIN_SRC emacs-lisp 1958 | (req-package go-mode 1959 | :mode "\\.go$" 1960 | :config 1961 | (progn 1962 | ;; Use gofmt to format code before save 1963 | (add-hook 'before-save-hook 'gofmt-before-save))) 1964 | #+END_SRC 1965 | 1966 | ** Graphviz :graphviz: 1967 | 1968 | #+BEGIN_SRC emacs-lisp 1969 | (req-package graphviz-dot-mode 1970 | :init (defalias 'dot-mode 'graphviz-dot-mode)) 1971 | #+END_SRC 1972 | 1973 | ** Java :java: 1974 | 1975 | #+BEGIN_SRC emacs-lisp 1976 | (req-package malabar-mode 1977 | :mode "\\.java$") 1978 | 1979 | (req-package gradle-mode 1980 | :mode "\\.gradle$") 1981 | #+END_SRC 1982 | 1983 | ** javascript :javascript: 1984 | 1985 | #+BEGIN_SRC emacs-lisp 1986 | (req-package js2-mode 1987 | :init (setq js2-highlight-level 3) 1988 | :mode "\\.js$") 1989 | #+END_SRC 1990 | 1991 | *** Simplify importing JS modules 1992 | 1993 | =import-js= is a tool to automatically import dependencies in your JavaScript 1994 | project. Use it in Vim or Emacs by placing your cursor on a variable and hit 1995 | =j (Vim)=, or =(M-x) import-js-import (Emacs)=. 1996 | 1997 | GitHub: https://github.com/trotzig/import-js 1998 | 1999 | #+BEGIN_SRC emacs-lisp 2000 | (req-package import-js) 2001 | #+END_SRC 2002 | 2003 | ** Json :javascript:json: 2004 | 2005 | #+BEGIN_SRC emacs-lisp 2006 | (req-package json-reformat :commands json-reformat-region) 2007 | 2008 | (req-package flymake-json :require flymake) 2009 | 2010 | (req-package json-mode 2011 | :require flymake-json 2012 | :mode ("\\.json$" . json-mode) 2013 | :init (add-hook 'json-mode-hook (lambda () (flymake-json-load)))) 2014 | #+END_SRC 2015 | 2016 | ** Markdown :markdown: 2017 | 2018 | #+BEGIN_SRC emacs-lisp 2019 | (req-package markdown-mode 2020 | :mode "\\.\\(md\\|markdown\\)\\'") 2021 | #+END_SRC 2022 | 2023 | ** Python :python: 2024 | 2025 | #+BEGIN_SRC emacs-lisp 2026 | (req-package jinja2-mode) 2027 | #+END_SRC 2028 | 2029 | ** QML :qml:qt: 2030 | 2031 | #+BEGIN_SRC emacs-lisp 2032 | (req-package qml-mode 2033 | :init (add-to-list 'auto-mode-alist '("\\.qml$" . qml-mode))) 2034 | #+END_SRC 2035 | 2036 | ** Ruby :ruby: 2037 | 2038 | #+BEGIN_SRC emacs-lisp 2039 | (req-package ruby-mode 2040 | :mode (("Rakefile\\'" . ruby-mode) 2041 | ("\\.rake$" . ruby-mode) 2042 | ("\\.gemspec$" . ruby-mode) 2043 | ("\\.rb$'" . ruby-mode) 2044 | ("\\.ru$" . ruby-mode) 2045 | ("Gemfile$" . ruby-mode) 2046 | ("Guardfile$" . ruby-mode)) 2047 | :config 2048 | (progn 2049 | ;; We never want to edit Rubinius bytecode 2050 | (add-to-list 'completion-ignored-extensions ".rbc") 2051 | )) 2052 | #+END_SRC 2053 | 2054 | #+BEGIN_SRC emacs-lisp 2055 | (req-package rake) 2056 | #+END_SRC 2057 | ** Rust :rust: 2058 | 2059 | [[https://github.com/rust-lang/rust-mode][rust-mode]] is a major emacs-mode for editing Rust source code. 2060 | 2061 | #+BEGIN_SRC emacs-lisp 2062 | (req-package rust-mode 2063 | :mode "\\.rs\\'") 2064 | #+END_SRC 2065 | 2066 | ** scala :scala: 2067 | 2068 | #+BEGIN_SRC emacs-lisp 2069 | (req-package scala-mode 2070 | :mode (("\\.scala$" . scala-mode))) 2071 | 2072 | (req-package sbt-mode 2073 | :mode (("\\.sbt$" . sbt-mode))) 2074 | #+END_SRC 2075 | 2076 | ** SSH Config :ssh: 2077 | 2078 | #+BEGIN_SRC emacs-lisp 2079 | (req-package ssh-config-mode 2080 | :mode (("\\.ssh/config\\'" . ssh-config-mode) 2081 | ("sshd?_config\\'" . ssh-config-mode) 2082 | ("known_hosts\\'" . ssh-known-hosts-mode) 2083 | ("authorized_keys2?\\'" . ssh-authorized-keys-mode)) 2084 | :init (add-hook 'ssh-config-mode-hook 'turn-on-font-lock)) 2085 | #+END_SRC 2086 | 2087 | ** XML :xml: 2088 | 2089 | #+BEGIN_SRC emacs-lisp 2090 | (req-package nxml-mode 2091 | :mode (("\\.pom$" . nxml-mode)) 2092 | :config 2093 | (progn 2094 | ;; Any file start with xml will be treat as nxml-mode 2095 | (add-to-list 'magic-mode-alist '("<\\?xml" . nxml-mode)) 2096 | 2097 | ;; Use nxml-mode instead of sgml, xml or html mode. 2098 | (mapc 2099 | (lambda (pair) 2100 | (if (or (eq (cdr pair) 'xml-mode) 2101 | (eq (cdr pair) 'sgml-mode)) 2102 | (setcdr pair 'nxml-mode))) 2103 | auto-mode-alist) 2104 | )) 2105 | #+END_SRC 2106 | 2107 | ** YAML :yaml: 2108 | 2109 | #+BEGIN_SRC emacs-lisp 2110 | (req-package yaml-mode 2111 | :mode "\\.yml$") 2112 | #+END_SRC 2113 | 2114 | * LISP Development :lisp: 2115 | 2116 | Though =LISP= has many dialet, it still is the best programming language I ever 2117 | met. 2118 | 2119 | ** Emacs Lisp :elisp: 2120 | 2121 | *** Add eldoc support :eldoc: 2122 | 2123 | #+BEGIN_SRC emacs-lisp 2124 | (req-package eldoc 2125 | :init 2126 | (add-hook 'emacs-lisp-mode-hook 2127 | '(lambda () 2128 | ;; enable eldoc 2129 | (turn-on-eldoc-mode) 2130 | ;; fix for paredit if exist 2131 | (eval-after-load 'paredit 2132 | '(progn 2133 | (eldoc-add-command 'paredit-backward-delete 2134 | 'paredit-close-round)))))) 2135 | #+END_SRC 2136 | 2137 | *** Additional flavour to emacs-lisp programming :el@spice: 2138 | 2139 | el-spice is a minor mode that provides additional configuration to make 2140 | programming in Emacs Lisp more enjoyable. 2141 | 2142 | GitHub: https://github.com/vedang/el-spice 2143 | 2144 | #+BEGIN_SRC emacs-lisp 2145 | (req-package el-spice) 2146 | #+END_SRC 2147 | 2148 | *** On-the-fly evaluation/substitution of emacs lisp code :litable: 2149 | 2150 | [[https://github.com/Fuco1/litable][litable]] keeps a list of pure functions as a safeguard for unwanted evaluations. 2151 | A function must first be accepted into this list (using =M-x litable-accept-as-pure=) 2152 | before it can be evaluated on-the-fly. 2153 | 2154 | You should take care of what function you accept as pure to avoid any 2155 | unfortunate accidents. Also, note that the pure functions list persists across 2156 | sessions. 2157 | 2158 | GitHub: https://github.com/Fuco1/litable 2159 | 2160 | #+BEGIN_SRC emacs-lisp 2161 | (req-package litable :init (litable-mode)) 2162 | #+END_SRC 2163 | 2164 | *** Highlight defined symbols 2165 | 2166 | #+BEGIN_SRC emacs-lisp :tangle no 2167 | (req-package hl-defined 2168 | :config 2169 | (add-hook 'emacs-lisp-mode-hook 'hdefd-highlight-mode) 2170 | (add-hook 'lisp-interaction-mode-hook 'hdefd-highlight-mode)) 2171 | #+END_SRC 2172 | 2173 | *** Highlight functions or macros belone to cl.el 2174 | 2175 | #+BEGIN_SRC emacs-lisp 2176 | (req-package highlight-cl 2177 | :init 2178 | (add-hook 'emacs-lisp-mode-hook 2179 | '(lambda () 2180 | (highlight-cl-add-font-lock-keywords)))) 2181 | #+END_SRC 2182 | 2183 | *** Remove *.elc when save 2184 | 2185 | #+BEGIN_SRC emacs-lisp 2186 | (defun remove-elc-on-save () 2187 | "If you're saving an elisp file, likely the .elc is no longer valid." 2188 | (make-local-variable 'after-save-hook) 2189 | (add-hook 'after-save-hook 2190 | (lambda () 2191 | (if (file-exists-p (concat buffer-file-name "c")) 2192 | (delete-file (concat buffer-file-name "c")))))) 2193 | 2194 | (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save) 2195 | #+END_SRC 2196 | 2197 | ** Clojure :clojure: 2198 | 2199 | #+BEGIN_SRC emacs-lisp 2200 | (req-package clojure-mode 2201 | :require (clojure-mode-extra-font-locking flycheck-clojure) 2202 | :mode "\\.\\(clj\\|boot\\|cljx\\|edn\\|cljs\\|cljs.hl\\)\\'") 2203 | #+END_SRC 2204 | 2205 | *** Add refactor function support 2206 | 2207 | https://github.com/clojure-emacs/clj-refactor.el 2208 | 2209 | #+BEGIN_SRC emacs-lisp 2210 | (req-package clj-refactor 2211 | :config 2212 | (progn 2213 | ;; Add clj-refactor to clojure-mode 2214 | (add-hook 'clojure-mode-hook '(lambda () (clj-refactor-mode 1))) 2215 | ;; Use `C-c C-x' as prefix 2216 | (cljr-add-keybindings-with-prefix "C-c C-x"))) 2217 | #+END_SRC 2218 | 2219 | *** Use cider for interactive development 2220 | 2221 | [[https://github.com/clojure-emacs/cider][cider]] is a Clojure Interactive Development Environment that Rocks for Emacs 2222 | 2223 | #+BEGIN_SRC emacs-lisp 2224 | (req-package cider 2225 | :require (cider-decompile cider-eval-sexp-fu eldoc) 2226 | :config 2227 | (progn 2228 | 2229 | ;; Enable eldoc in Clojure buffers 2230 | (eval-after-load 'eldoc 2231 | '(progn 2232 | (add-hook 'cider-mode-hook #'eldoc-mode))) 2233 | 2234 | ;; Hide `*nrepl-connection*' and `*nrepl-server*' buffers from appearing 2235 | ;; in some buffer switching commands like switch-to-buffer 2236 | (setq nrepl-hide-special-buffers t) 2237 | 2238 | ;; Enabling CamelCase support for editing commands(like forward-word, 2239 | ;; backward-word, etc) in the REPL is quite useful since we often have 2240 | ;; to deal with Java class and method names. The built-in Emacs minor 2241 | ;; mode subword-mode provides such functionality 2242 | (add-hook 'cider-repl-mode-hook #'subword-mode) 2243 | 2244 | ;; The use of paredit when editing Clojure (or any other Lisp) code is 2245 | ;; highly recommended. You're probably using it already in your 2246 | ;; clojure-mode buffers (if you're not you probably should). You might 2247 | ;; also want to enable paredit in the REPL buffer as well. 2248 | ;; (add-hook 'cider-repl-mode-hook #'paredit-mode) 2249 | 2250 | ;; Auto-select the error buffer when it's displayed: 2251 | (setq cider-auto-select-error-buffer t) 2252 | 2253 | ;; Controls whether to pop to the REPL buffer on connect. 2254 | (setq cider-repl-pop-to-buffer-on-connect nil) 2255 | 2256 | ;; Controls whether to auto-select the error popup buffer. 2257 | (setq cider-auto-select-error-buffer t) 2258 | 2259 | ;; T to wrap history around when the end is reached. 2260 | (setq cider-repl-wrap-history t) 2261 | 2262 | ;; Log protocol messages to the `nrepl-message-buffer-name' buffer. 2263 | (setq nrepl-log-messages t) 2264 | 2265 | ;; Toggle between test and implementation, instead of showing test report buffer. 2266 | (eval-adter-load 'projectile 2267 | (define-key cider-mode-map (kbd "C-c C-t") 'projectile-toggle-between-implementation-and-test)) 2268 | )) 2269 | #+END_SRC 2270 | 2271 | *** Insert libraries in project more easily 2272 | 2273 | [[https://github.com/AdamClements/latest-clojure-libraries][latest-clojure-libraries]] helps to looks up the latest version of clojure 2274 | libraries on clojars/maven and automatically populates the buffer with the 2275 | appropriate dependency vector. Optionally uses pomegranate to load the 2276 | dependency directly into your running nrepl. 2277 | 2278 | To use this plugin, you need to edit your =~/.lein/profiles.clj= :plugins vector 2279 | to include =[lein-ancient "0.5.1"]= and optionally add 2280 | =[com.cemerick/pomegranate "0.2.0"]= to your :dependencies vector if you want 2281 | the feature which automatically adds the library to your classpath without 2282 | restarting the repl. 2283 | 2284 | After all step done, use =M-x latest-clojure-libraries-insert-dependency= to 2285 | insert latest clojure libraries to your project. 2286 | 2287 | GitHub: https://github.com/AdamClements/latest-clojure-libraries 2288 | 2289 | #+BEGIN_SRC emacs-lisp 2290 | (req-package latest-clojure-libraries) 2291 | #+END_SRC 2292 | 2293 | * Web Development :web: 2294 | 2295 | #+BEGIN_SRC emacs-lisp 2296 | (req-package web-mode 2297 | :mode (("\\.html?\\'" . web-mode) 2298 | ("\\.ejs?\\'" . web-mode))) 2299 | #+END_SRC 2300 | 2301 | ** CSS :css: 2302 | 2303 | #+BEGIN_SRC emacs-lisp 2304 | (req-package css-mode :mode "\\.css\\'") 2305 | #+END_SRC 2306 | 2307 | *** Add support for eldoc :eldoc: 2308 | 2309 | #+BEGIN_SRC emacs-lisp 2310 | (req-package css-eldoc 2311 | :config 2312 | (progn 2313 | (add-hook 'css-mode-hook 'turn-on-css-eldoc) 2314 | (add-hook 'scss-mode-hook 'turn-on-css-eldoc) 2315 | (add-hook 'less-css-mode-hook 'turn-on-css-eldoc))) 2316 | #+END_SRC 2317 | 2318 | ** Less :less: 2319 | 2320 | #+BEGIN_SRC emacs-lisp 2321 | (req-package less-css-mode 2322 | :init (add-to-list 'auto-mode-alist '("\\.less$" . less-css-mode)) 2323 | :mode "\\.less$") 2324 | #+END_SRC 2325 | 2326 | ** SCSS :css:scss: 2327 | 2328 | #+BEGIN_SRC emacs-lisp 2329 | (req-package scss-mode 2330 | :mode "\\.scss\\'" 2331 | :config 2332 | (progn 2333 | ;; dont' build scss to css after save file 2334 | (setq scss-compile-at-save nil))) 2335 | #+END_SRC 2336 | 2337 | ** mustache :mustache: 2338 | 2339 | Sometimes we will use [[https://mustache.github.io/][mustache]] as template system, [[https://github.com/mustache/emacs][mustache-mode]] is a nice 2340 | helper. 2341 | 2342 | GitHub: https://github.com/mustache/emacs 2343 | 2344 | #+BEGIN_SRC emacs-lisp 2345 | (req-package mustache-mode :mode "\\.mustache$") 2346 | #+END_SRC 2347 | 2348 | ** Use emmet-mode to add Zen Coding support 2349 | 2350 | [[https://github.com/smihica/emmet-mode][emmet-mode]] is a fork of [[https://github.com/rooney/zencoding][zencoding-mode]] which add minor mode providing support 2351 | for Zen Coding by producing HTML from CSS-like selectors. 2352 | 2353 | GitHub: https://github.com/smihica/emmet-mode 2354 | 2355 | #+BEGIN_SRC emacs-lisp :tangle no 2356 | (req-package emmet-mode 2357 | :config 2358 | (progn 2359 | ;; Following mode support emmet-mode 2360 | (add-hook 'html-mode-hook 'emmet-mode) 2361 | (add-hook 'sgml-mode-hook 'emmet-mode) 2362 | (add-hook 'nxml-mode-hook 'emmet-mode) 2363 | (add-hook 'css-mode-hook 'emmet-mode) 2364 | 2365 | ;; Move cursor between quotes after expand 2366 | (add-hook 'emmt-mode-hook 2367 | '(lambda() 2368 | (setq emmet-move-cursor-between-quotes t))) 2369 | 2370 | ;; Make tab can also expand emmt instead of use yasnippet directly 2371 | (define-key emmt-mode-keymap (kbd "TAB") 'emmt-expand-yas) 2372 | (define-key emmt-mode-keymap (kbd "") 'emmt-expand-yas))) 2373 | #+END_SRC 2374 | 2375 | * Terminal Emulator :term: 2376 | 2377 | ** Sane Term 2378 | 2379 | Ansi Term with sane options and the ability to cycle/create terms. 2380 | 2381 | GitHub: https://github.com/adamrt/sane-term 2382 | 2383 | #+BEGIN_SRC emacs-lisp 2384 | (req-package sane-term 2385 | :config 2386 | (progn 2387 | ;; shell to use for sane-term 2388 | (setq sane-term-shell-command "/bin/bash") 2389 | ;; sane-term will create first term if none exist 2390 | (setq sane-term-initial-create t) 2391 | ;; `C-d' or `exit' will kill the term buffer. 2392 | (setq sane-term-kill-on-exit t) 2393 | ;; After killing a term buffer, not cycle to another. 2394 | (setq sane-term-next-on-kill nil))) 2395 | #+END_SRC 2396 | 2397 | ** Eshell :eshell: 2398 | 2399 | eshell is not really a system shell, it's written in pure lisp. What I 2400 | like is it fully integrated with emacs. 2401 | 2402 | #+BEGIN_SRC emacs-lisp 2403 | (req-package eshell 2404 | :init 2405 | ;; move eshell cache dir to ~/.emacs.d/.cache 2406 | (setq eshell-directory-name (concat user-cache-directory "eshell"))) 2407 | #+END_SRC 2408 | 2409 | *** Use bash like prompt with color 2410 | 2411 | #+BEGIN_SRC emacs-lisp 2412 | (eval-after-load 'eshell 2413 | '(progn 2414 | ;; Make eshell prompt look likes default bash prompt 2415 | (setq eshell-prompt-function 2416 | '(lambda () 2417 | (concat 2418 | user-login-name "@" system-name " " 2419 | (if (search (directory-file-name (expand-file-name (getenv "HOME"))) (eshell/pwd)) 2420 | (replace-regexp-in-string (expand-file-name (getenv "HOME")) "~" (eshell/pwd)) 2421 | (eshell/pwd)) 2422 | (if (= (user-uid) 0) " # " " $ ")))) 2423 | ;; Add color for eshell prompt like Gentoo does 2424 | (defun colorfy-eshell-prompt () 2425 | (let* ((mpoint) 2426 | (user-string-regexp (concat "^" user-login-name "@" system-name))) 2427 | (save-excursion 2428 | (goto-char (point-min)) 2429 | (while (re-search-forward (concat user-string-regexp ".*[$#]") (point-max) t) 2430 | (setq mpoint (point)) 2431 | (overlay-put (make-overlay (point-at-bol) mpoint) 'face '(:foreground "dodger blue"))) 2432 | (goto-char (point-min)) 2433 | (while (re-search-forward user-string-regexp (point-max) t) 2434 | (setq mpoint (point)) 2435 | (overlay-put (make-overlay (point-at-bol) mpoint) 'face '(:foreground "green3")))))) 2436 | ;; Make eshell prompt more colorful 2437 | (add-hook 'eshell-output-filter-functions 'colorfy-eshell-prompt))) 2438 | #+END_SRC 2439 | 2440 | *** Use ansi-term to render visual commands 2441 | 2442 | #+BEGIN_SRC emacs-lisp 2443 | (eval-after-load 'eshell 2444 | '(progn 2445 | (setq eshell-visual-commands 2446 | '("less" "tmux" "htop" "top" "bash" "zsh" "fish" "ssh" "tail")) 2447 | 2448 | (setq eshell-visual-subcommands 2449 | '(("git" "log" "diff" "show"))) 2450 | )) 2451 | #+END_SRC 2452 | 2453 | *** Support for multi-eshell instance 2454 | 2455 | #+BEGIN_SRC emacs-lisp 2456 | (req-package multi-eshell 2457 | :require eshell 2458 | :config 2459 | (progn 2460 | (setq multi-eshell-shell-function '(eshell)) 2461 | (setq multi-eshell-name "*eshell*"))) 2462 | #+END_SRC 2463 | 2464 | *** Add autojump command 2465 | 2466 | [[http://www.emacswiki.org/emacs/EshellAutojump][Eshell Autojump]] is an [[https://github.com/joelthelion/autojump][autojump]] like command written in pure elisp, 2467 | which add a =j= command to let you jump to folder you has been access. 2468 | 2469 | #+BEGIN_SRC emacs-lisp 2470 | (req-package eshell-autojump :require eshell) 2471 | #+END_SRC 2472 | 2473 | *** Eshell commands setup 2474 | 2475 | **** .. 2476 | 2477 | #+BEGIN_SRC emacs-lisp 2478 | (defun eshell/.. (&optional level) 2479 | "Go up LEVEL directories" 2480 | (interactive) 2481 | (let ((level (or level 1))) 2482 | (eshell/cd (make-string (1+ level) ?.)) 2483 | (eshell/ls))) 2484 | #+END_SRC 2485 | 2486 | **** clear 2487 | 2488 | #+BEGIN_SRC emacs-lisp 2489 | (defun eshell/clear () 2490 | "Clears the shell buffer ala Unix's clear or DOS' cls" 2491 | ;; the shell prompts are read-only, so clear that for the duration 2492 | (let ((inhibit-read-only t)) 2493 | ;; simply delete the region 2494 | (delete-region (point-min) (point-max)))) 2495 | #+END_SRC 2496 | 2497 | **** emacs 2498 | 2499 | #+BEGIN_SRC emacs-lisp 2500 | (defun eshell/emacs (&rest args) 2501 | "Open a file in emacs. Some habits die hard." 2502 | (if (null args) 2503 | ;; If I just ran "emacs", I probably expect to be launching 2504 | ;; Emacs, which is rather silly since I'm already in Emacs. 2505 | ;; So just pretend to do what I ask. 2506 | (bury-buffer) 2507 | ;; We have to expand the file names or else naming a directory in an 2508 | ;; argument causes later arguments to be looked for in that directory, 2509 | ;; not the starting directory 2510 | (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args)))))) 2511 | 2512 | (defalias 'eshell/e 'eshell/emacs) 2513 | #+END_SRC 2514 | 2515 | **** unpack 2516 | 2517 | #+BEGIN_SRC emacs-lisp 2518 | (defun eshell/unpack (file) 2519 | (let ((command (some (lambda (x) 2520 | (if (string-match-p (car x) file) 2521 | (cadr x))) 2522 | '((".*\.tar.bz2" "tar xjf") 2523 | (".*\.tar.gz" "tar xzf") 2524 | (".*\.bz2" "bunzip2") 2525 | (".*\.rar" "unrar x") 2526 | (".*\.gz" "gunzip") 2527 | (".*\.tar" "tar xf") 2528 | (".*\.tbz2" "tar xjf") 2529 | (".*\.tgz" "tar xzf") 2530 | (".*\.zip" "unzip") 2531 | (".*\.Z" "uncompress") 2532 | (".*" "echo 'Could not unpack the file:'"))))) 2533 | (eshell-command-result (concat command " " file)))) 2534 | #+END_SRC 2535 | 2536 | * Window Management :window: 2537 | 2538 | ** Maximized window after emac start 2539 | 2540 | #+BEGIN_SRC emacs-lisp 2541 | (modify-all-frames-parameters '((fullscreen . maximized))) 2542 | #+END_SRC 2543 | 2544 | ** winner-mode :winner: 2545 | 2546 | #+BEGIN_SRC emacs-lisp 2547 | (req-package winner 2548 | :config 2549 | (progn 2550 | ;; I use my own keymap for winner-mode 2551 | (setq winner-dont-bind-my-keys t) 2552 | ;; Start winner-mode globally 2553 | (winner-mode t))) 2554 | #+END_SRC 2555 | 2556 | * Version Control 2557 | 2558 | ** Git :git: 2559 | 2560 | *** Add suport for git configuration files 2561 | 2562 | 2563 | #+BEGIN_SRC emacs-lisp 2564 | (req-package gitconfig-mode 2565 | :mode (("/\\.?git/?config\\'" . gitconfig-mode) 2566 | ("/\\.gitmodules\\'" . gitconfig-mode) 2567 | ("/_gitconfig\\'" . gitconfig-mode)) 2568 | :config 2569 | (add-hook 'gitconfig-mode-hook 'flyspell-mode)) 2570 | 2571 | (req-package gitignore-mode 2572 | :mode (("/\\.gitignore\\'" . gitignore-mode) 2573 | ("/\\.git/info/exclude\\'" . gitignore-mode) 2574 | ("/git/ignore\\'" . gitignore-mode))) 2575 | #+END_SRC 2576 | 2577 | *** Use git-wip to view your WIP commit 2578 | 2579 | https://github.com/itsjeyd/git-wip-timemachine 2580 | 2581 | #+BEGIN_SRC emacs-lisp 2582 | (req-package git-wip-timemachine) 2583 | #+END_SRC 2584 | 2585 | *** Setup keybindings :keybinding: 2586 | 2587 | #+BEGIN_SRC emacs-lisp :noweb yes :results silent 2588 | (add-hook 2589 | 'magit-mode-hook 2590 | '(lambda() 2591 | (define-key magit-mode-map (kbd "C-g") 'magit-mode-quit-window))) 2592 | #+END_SRC 2593 | 2594 | * Cedet :cedet: 2595 | 2596 | #+BEGIN_SRC emacs-lisp 2597 | (req-package cedet 2598 | :config 2599 | (progn 2600 | (setq ede-project-placeholder-cache-file (concat user-cache-directory "ede-projects.el")) 2601 | (setq semanticdb-default-save-directory (concat user-cache-directory "semanticdb")) 2602 | (setq srecode-map-save-file (concat user-cache-directory "srecode-map.el")) 2603 | )) 2604 | #+END_SRC 2605 | 2606 | * Keybinding :keybinding: 2607 | 2608 | Create my minor-mode to control all keybindings 2609 | 2610 | #+begin_src emacs-lisp 2611 | (defvar coldnew-editor-map (make-keymap)) 2612 | 2613 | (define-minor-mode coldnew-editor-mode 2614 | "coldnew's editor minor mode." 2615 | :init-value t 2616 | :keymap coldnew-editor-map) 2617 | 2618 | (define-globalized-minor-mode global-coldnew-editor-mode 2619 | coldnew-editor-mode (lambda () 2620 | (if (not (minibufferp (current-buffer))) 2621 | (coldnew-editor-mode 1)))) 2622 | 2623 | ;; Gloabal enable 2624 | (global-coldnew-editor-mode t) 2625 | #+end_src 2626 | 2627 | ** Spacemacs Map 2628 | 2629 | spacemacs reserve the =SPC-o= for user setup theirs own keymap, I think I should add something here :( 2630 | 2631 | ** Normal State 2632 | 2633 | #+BEGIN_SRC emacs-lisp 2634 | (evil-define-key 'normal coldnew-editor-map 2635 | (kbd "C-x C-f") 'helm-find-files 2636 | (kbd "C-x C-q") 'read-only-mode 2637 | (kbd "C-x C-s") 'save-buffer-always 2638 | (kbd "C-x M-1") 'deft-or-close 2639 | (kbd "C-x M-2") 'multi-eshell 2640 | (kbd "C-x M-3") 'mu4e 2641 | (kbd "C-x M-4") 'erc-start-or-switch 2642 | (kbd "C-x vl") 'magit-log 2643 | (kbd "C-x vp") 'magit-push 2644 | (kbd "C-x vs") 'magit-status 2645 | (kbd "C-x b") 'helm-buffers-list 2646 | (kbd "M-[") 'winner-undo 2647 | (kbd "M-]") 'winner-redo 2648 | (kbd "M-x") 'helm-M-x 2649 | (kbd "M-s") 'helm-occur 2650 | (kbd "C-x C-o") 'other-frame 2651 | (kbd "M-o") 'other-window 2652 | (kbd "C--") 'text-scale-decrease 2653 | (kbd "C-=") 'text-scale-increase 2654 | ) 2655 | #+END_SRC 2656 | 2657 | ** Insert State 2658 | 2659 | #+BEGIN_SRC emacs-lisp 2660 | (evil-define-key 'insert coldnew-editor-map 2661 | (kbd "") 'hungry-delete-backward 2662 | (kbd "TAB") 'yas/expand 2663 | (kbd "C-;") 'iedit-mode 2664 | (kbd "C-d") 'hungry-delete-forward 2665 | (kbd "C-l") 'hungry-delete-backward 2666 | (kbd "C-n") 'evil-next-line 2667 | (kbd "M-z") 'zzz-to-char 2668 | (kbd "C-o") 'evil-execute-in-normal-state 2669 | (kbd "C-p") 'evil-previous-line 2670 | (kbd "C-w") 'backward-kill-word 2671 | (kbd "C-x C-f") 'helm-find-files 2672 | (kbd "C-x C-n") 'company-complete 2673 | (kbd "C-x C-q") 'read-only-mode 2674 | (kbd "C-x C-s") 'save-buffer-always 2675 | (kbd "C-x M-1") 'deft-or-close 2676 | (kbd "C-x M-2") 'multi-eshell 2677 | (kbd "C-x M-3") 'mu4e 2678 | (kbd "C-x M-4") 'erc-start-or-switch 2679 | (kbd "C-x vl") 'magit-log 2680 | (kbd "C-x vp") 'magit-push 2681 | (kbd "C-x vs") 'magit-status 2682 | (kbd "C-x b") 'helm-buffers-list 2683 | (kbd "M-") 'insert-U200B-char 2684 | (kbd "M-[") 'winner-undo 2685 | (kbd "M-]") 'winner-redo 2686 | (kbd "M-s") 'helm-occur 2687 | (kbd "s-") 'insert-empty-line 2688 | (kbd "s-") 'insert-U200B-char 2689 | (kbd "C-v") 'set-mark-mode/rectangle-mark-mode 2690 | (kbd "C-x C-i") 'indent-region-or-buffer-and-cleanup 2691 | (kbd "M-v") 'er/expand-region 2692 | (kbd "M-x") 'helm-M-x 2693 | (kbd "M-y") 'helm-show-kill-ring 2694 | (kbd "M-o") 'other-window 2695 | (kbd "C-x C-o") 'other-frame 2696 | (kbd "C--") 'text-scale-decrease 2697 | (kbd "C-x t") 'sane-term 2698 | (kbd "C-x T") 'sane-term 2699 | ) 2700 | #+END_SRC 2701 | 2702 | ** Ex Command 2703 | 2704 | #+BEGIN_SRC emacs-lisp 2705 | (evil-ex-define-cmd "ag" 'helm-ag) 2706 | (evil-ex-define-cmd "agp[roject]" 'helm-projectile-ag) 2707 | (evil-ex-define-cmd "agi[nteractive]" 'helm-do-ag) 2708 | (evil-ex-define-cmd "google" 'helm-google) 2709 | (evil-ex-define-cmd "google-suggest" 'helm-google-suggest) 2710 | (evil-ex-define-cmd "gtag" 'ggtags-create-tags) 2711 | (evil-ex-define-cmd "howdoi" 'howdoi-query) 2712 | #+END_SRC 2713 | 2714 | * End of configuration 2715 | 2716 | Oh YA!! We finish loading emacs configuration :) 2717 | 2718 | However, since we use =req-package= for loading and installing packages, be sure 2719 | to execute following line to send =req-package= on its merry way. 2720 | 2721 | #+BEGIN_SRC emacs-lisp 2722 | (req-package-finish) 2723 | #+END_SRC 2724 | 2725 | In the end of configuration, I'll load my private config from =~/.personal.el=, 2726 | which contains something like password or account settings. 2727 | 2728 | #+BEGIN_SRC emacs-lisp 2729 | (let ((secret "~/.personal.el")) 2730 | (when (file-exists-p secret) (load-file secret))) 2731 | #+END_SRC 2732 | 2733 | * Reference 2734 | 2735 | Following link is refrence for my emac config. 2736 | 2737 | ~[1]~ https://github.com/r0man/.emacs.d/blob/master/init.el.org 2738 | 2739 | ~[2]~ https://github.com/bodil/emacs.d 2740 | 2741 | ~[3]~ https://github.com/mgalgs/.emacs.d 2742 | 2743 | ~[4]~ https://raw.githubusercontent.com/sbisaacson/literate-emacs/master/README.org 2744 | 2745 | ~[5]~ https://github.com/jhenahan/emacs.d/blob/master/emacs-init.org 2746 | 2747 | ~[6]~ https://ryuslash.org/dotfiles/emacs/init.html 2748 | 2749 | ~[7]~ http://www.wisdomandwonder.com/wordpress/wp-content/uploads/2014/03/C3F.org_.txt 2750 | 2751 | ~[8]~ https://github.com/howardabrams/dot-files 2752 | --------------------------------------------------------------------------------