{"id":20405997,"url":"https://github.com/coldnew/coldnew-spacemacs","last_synced_at":"2025-03-05T02:19:08.138Z","repository":{"id":26759985,"uuid":"30217890","full_name":"coldnew/coldnew-spacemacs","owner":"coldnew","description":"My spacemacs config (based on coldnew-emacs)","archived":false,"fork":false,"pushed_at":"2015-12-30T05:47:21.000Z","size":521,"stargazers_count":49,"open_issues_count":2,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-15T12:14:33.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coldnew.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-03T01:14:28.000Z","updated_at":"2023-10-31T07:23:57.000Z","dependencies_parsed_at":"2022-09-01T21:11:40.907Z","dependency_job_id":null,"html_url":"https://github.com/coldnew/coldnew-spacemacs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fcoldnew-spacemacs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fcoldnew-spacemacs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fcoldnew-spacemacs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coldnew%2Fcoldnew-spacemacs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coldnew","download_url":"https://codeload.github.com/coldnew/coldnew-spacemacs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241950397,"owners_count":20047633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T05:14:14.816Z","updated_at":"2025-03-05T02:19:08.113Z","avatar_url":"https://github.com/coldnew.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: coldnew's emacs config\n#+AUTHOR: Yen-Chin, Lee \u003ccoldnew\u003e\n#+email: coldnew.tw at gmail.com\n#+DESCRIPTION: A literate programming style exposition of my Emacs configuration\n#+LANGUAGE: en\n#+STARTUP: overview indent align\n#+BABEL: :cache yes\n#+OPTIONS: ^:nil\n#+PROPERTY: header-args :comments link\n\n# Badge\n[[http://www.gnu.org/licenses/gpl-3.0.txt][https://img.shields.io/badge/license-GPL_3-green.svg?dummy]]\n[[https://travis-ci.org/coldnew/coldnew-spacemacs][https://travis-ci.org/coldnew/coldnew-spacemacs.svg?branch=master]]\n\n* Introduction\n\nThis is another emacs config of mine, which is a totally rewritten version\nbased 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]]\nin [[http://orgmode.org/][org-mode]], but it uses English to write this config instead.\n\nFeel free to use it :).\n\n** Install emacs\n\nMy emacs is running under =Mac OSX= and =Gentoo Linux= and I really like them,\nfollowing are some record for how I installed my emacs.\n\n*** Mac OSX\n\nIn Mac OSX, I use [[http://brew.sh/][homebrew]] to mantain opensource packages, I always install latest\nversion of emacs via following command\n\n#+BEGIN_EXAMPLE\n  brew install emacs --HEAD --use-git-head --with-cocoa --with-gnutls --with-rsvg --with-imagemagick\n  brew linkapps\n#+END_EXAMPLE\n\n*** Gentoo Linux\n\n[[https://www.gentoo.org/][Gentoo Linux]] is the best linux distrobution I ever used and it's really easy to install latest apps.\n\n#+BEGIN_EXAMPLE\n  USE=\"X gtk3 inotify xft imagemagick\" emerge app-editors/emacs\n#+END_EXAMPLE\n\n** Install or testing this config\n\n- First use git to download whole repo\n\n  : git clone https://github.com/coldnew/coldnew-spacemacs.git\n\n- Then use git submodule to download the spacemacs\n\n  : git submodule init\n  : git submodule update\n\n- You also need to install [[https://github.com/cask/cask][Cask]] for package management\n\n  : curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python\n\n- Then use the =make= command bootstrap this config\n\n  : make bootstrap\n\n- If you only want to generate the =init.el=, jut type\n\n  : make init.el\n\n- If you do not put this repo on =~/.emacs.d=, you need to use following\n  command to start emacs\n\n  : emacs -q -l ~/coldnew-spacemacs/init.el\n\n** Packages need to install in system (Optional)\n\nSome extra packages need to be installed in the system manually. These packages\nare =optional= but can make this configuration work more nicely.\n\n*** Mac OSX\n\n#+BEGIN_SRC sh :tangle no\n  brew install the_silver_searcher\n  brew install fasd\n  brew install docmacs\n  brew install aspell --with-lang-en\n#+END_SRC\n\n*** Gentoo Linux\n\nIn Gentoo Linux, don't forget to enable ~USE=emacs~ to make gentoo auto install\nemacs-related packages.\n\n#+BEGIN_SRC sh :tangle no\n  emerge sys-apps/the_silver_searcher\n  emerge app-shells/fasd\n  emerge app-shells/doxymacs\n  emerge app-shells/aspell\n#+END_SRC\n\n* Initialization Emacs\n\nThere are some configurations I need to put at the beginning of the emacs\nconfig. These configurations are derived from my original init.el file.\n\n** load prefer newer\n\n#+BEGIN_SRC emacs-lisp\n  ;; since emacs 24.4, new option `load-prefer-newer' has been\n  ;; introduce, which make me never accidentally using outdated compiled files.\n  (setq load-prefer-newer t)\n#+END_SRC\n\n** change the user-emacs-directory\n\nI this configuration, =user-emacs-directory= always refer to the emacs\nconfiguration's init.el parent directory.\n\n#+BEGIN_SRC emacs-lisp\n  ;; We set `user-emacs-directory' here so we can use command-line\n  ;; switch different emacs configuration like following:\n  ;;\n  ;;    emacs -q -l ~/coldnew-spacemacs/init.el\n  (defconst user-emacs-directory\n    (file-name-directory (or load-file-name (buffer-file-name)))\n    \"My emacs config directory.\")\n#+END_SRC\n\n** define user-cache-directory variable\n\nSetup the cache directory to store some cache content.\n\n#+BEGIN_SRC emacs-lisp\n  (defconst user-cache-directory\n    (file-name-as-directory (concat user-emacs-directory \".cache\"))\n    \"My emacs storage area for persistent files.\")\n#+END_SRC\n\n* Package Management\n\nBefore we start this section, we need to initialize =package.el= first.\n\n#+BEGIN_SRC emacs-lisp\n  ;; This must come before configurations of installed packages.\n  ;; Don't delete this line. If you don't want it, just comment it out by adding a\n  ;; semicolon to the start of the line. You may delete these explanatory\n  ;; comments.\n  (package-initialize)\n#+END_SRC\n\nThe main package magement in my emacs is [[https://github.com/cask/cask][Cask]], which is a really nice package\nlike npm, cargo ...etc.\n\n[[https://github.com/cask/cask][Cask]] can also install packages according to your emacs version, so you don't be\nafraid to get version conflicts after upgrade emacs.\n\nTake my emacs as example, after initialize [[https://github.com/cask/cask][Cask]], all package install by\n=package.el= just save to =.cask= folder according to your emacs version.\n\n#+BEGIN_EXAMPLE\n  coldnew@Sara ~/.emacs.d $ tree -L 1 .cask/\n  .cask/\n  ├── 24.5.1\n  ├── 25.0.50.1\n  └── 25.1.50.1\n\n  3 directories, 0 files\n#+END_EXAMPLE\n\n** Cask and Pallet\n\n[[https://github.com/rdallasgray/pallet][Pallet]] is a wonderful little tool built on [[https://github.com/cask/cask][Cask]], a dependency management tool\nfor Emacs packages. Pallet adds automatic updating of the =Caskfile= when\npackages are installed and deleted.\n\n*** Installing Cask\n\nJust run this command in your terminal of choice:\n\n#+BEGIN_SRC sh :tangle no\n  curl -fsSkL https://raw.github.com/cask/cask/master/go | python\n#+END_SRC\n\nthen add =~/.cask/bin= to your =PATH= so that you can use =cask=.\n\n*** Creating a Caskfile                                          :caskfile:\n\nFor now, we just need a minimal =Cask= to get Pallet set up. Mine\nlooks like this:\n\n#+BEGIN_SRC emacs-lisp :tangle (if (file-exists-p \"Cask\") \"no\" \"Cask\")\n  (source gnu)\n  (source melpa)\n\n  (depends-on \"evil\")\n  (depends-on \"f\")\n  (depends-on \"s\")\n  (depends-on \"dash\")\n  (depends-on \"noflet\")\n  (depends-on \"pallet\")\n  (depends-on \"async\")\n  (depends-on \"req-package\")\n  (depends-on \"quelpa\")\n#+END_SRC\n\nThen run the following command in your =.emacs.d= directory to set up\n[[https://github.com/rdallasgray/pallet][Pallet]].\n\n#+BEGIN_SRC sh :tangle no\n  cask install\n#+END_SRC\n\nSince the =Cask= file is just emacs-lisp file, add it to mode-alist.\n\n#+BEGIN_SRC emacs-lisp\n  (add-to-list 'auto-mode-alist '(\"Cask$\" . emacs-lisp-mode))\n#+END_SRC\n\n*** Initialize Cask\n\nFinally, we add the following lines to our init file:\n\n#+BEGIN_SRC emacs-lisp\n  (require 'cask \"~/.cask/cask.el\")\n  (cask-initialize)\n#+END_SRC\n\n*** Initialize Pallet\n\nSince we already install pallet via cask, we just need to use the following code\nto initialize pallet.\n\n#+BEGIN_SRC emacs-lisp\n  (require 'pallet)\n  (pallet-mode t)\n#+END_SRC\n\n** quelpa\n\n[[https://github.com/quelpa/quelpa][quelpa]] is another package manager which can help you builds an ELPA compatible\npackage and installs that locally.\n\nGitHub: https://github.com/quelpa/quelpa\n\n#+BEGIN_SRC emacs-lisp\n  (unless (require 'quelpa nil t)\n    (with-temp-buffer\n      (url-insert-file-contents \"https://raw.github.com/quelpa/quelpa/master/bootstrap.el\")\n      (eval-buffer)))\n  ;; save quelpa builds and packages in .cache/quelpa\n  (setq quelpa-dir (expand-file-name \"quelpa\" user-cache-directory))\n#+END_SRC\n\n** req-package\n\n[[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\ntool. The documentation for =use-package= is immensely helpful for figuring out\nhow to describe package dependencies and settings. =req-package= adds the\n=:require= keyword which allows us to define dependencies between related\npackages.\n\n*** Initialize req-package\n\nWith the preceding process complete, we just need to add the following\nline to our init file to begin using =req-package=:\n\n#+BEGIN_SRC emacs-lisp\n  (require 'req-package)\n#+END_SRC\n\n*** Start loading packages in right order\n\nTo start loading packages in right order, we need to added following in the last\nof emacs config.\n\n#+BEGIN_SRC emacs-lisp :tangle no\n  (req-package-finish)\n#+END_SRC\n\nYou can take a look at [[*End%20of%20configuration][End of configuration]] section.\n\n* Load Path\n\nThe variable =load-path= lists all the directories where Emacs should look for\nElisp files.\n\nThough I use =Cask= as package management in my emacs, some local packages like\nmy own theme or others can't fetch by elpa need to add to load-path, this will\nhelp emacs find them.\n\nFollowing are my method to add directories to load-path ~recursively~, this\nfunction also create directory to prevent directory not exist.\n\nIf you don't have any local elisp and all packages is mantain by cask or elpa or\nspacemacs, you can skip following code.\n\n#+BEGIN_SRC emacs-lisp\n  ;; Add directories to emacs's `load-path' recursively.\n  ;; if path does not exist, create directory.\n  (let* ((lisp-dir '(\"local-lisp/\" \"theme/\")))\n    (dolist (lisp-path lisp-dir)\n      (when (not (file-exists-p lisp-path))\n        (make-directory (concat user-emacs-directory lisp-path) t))\n      (let* ((load-dir (concat user-emacs-directory lisp-path))\n             (default-directory load-dir))\n        (setq load-path\n              (append\n               (let ((load-path (copy-sequence load-path)))\n                 (append\n                  (copy-sequence (normal-top-level-add-to-load-path '(\".\")))\n                  (normal-top-level-add-subdirs-to-load-path)))\n               load-path)))))\n#+END_SRC\n\n* Spacemacs\n\n[[https://github.com/syl20bnr/spacemacs][Spacemacs]] is an emacs starterkit focus on [[https://gitorious.org/evil/pages/Home][Evil]], which emulate vim keymap on\nEmacs.\n\nI make my emacs on top of spacemacs since I also use vim keymap.\n\nIn my config file, the original =~/.spacemacs= file has moved to\n=~/.emacs.d/spacemacs.d/init.el= , I also advice spacemacs funtion to\nprevent orphan packages deleted by spacemacs.\n\nAfter all spacemacs init done, switch back to =*scratch*= buffer.\n\n** Load basic spacemacs configuration file\n\nLatest spacemacs can setup =SPACEMACSDIR= to load customize spacemacs init.el\nfile.\n\n#+BEGIN_SRC emacs-lisp\n  (setenv \"SPACEMACSDIR\" (concat user-emacs-directory \"spacemacs.d\"))\n#+END_SRC\n\n** Overwrite spacemacs function to let it not remove my packages\n\nI use =Cask= to handle all packages, spacemacs should do nothing here.\n\n#+BEGIN_SRC emacs-lisp\n  ;; Make spacemacs not remove my packages.\n  (defadvice configuration-layer/delete-orphan-packages (around null-func activate)\n    \"Overwrite the spacemacs's `configuration-layer/delete-orphan-packages'\n    to make it not remove any orphan packages.\")\n#+END_SRC\n\n** Spacemacs no need to check newer version\n\nSince my spacemacs is installed as submodule, it's no need to check for newer\nversion, I'll handle this myself.\n\n#+BEGIN_SRC emacs-lisp\n  (defadvice spacemacs/check-for-new-version (around null-func activate)\n    \"Overwrite the spacemacs's `spacemacs/check-for-new-version' to\n    makt it useless since I use git submodule to bundle spacemacs with my emacs.\")\n#+END_SRC\n\n** Load spacemacs\n\nThe original spacemacs is suggest to clone it to =~/.emacs.d=, I really not like\nthis. Instead, I move it to =~/.emacs.d/modules/spacemacs= so I can use org-mode\nwith literature writing.\n\n#+BEGIN_SRC emacs-lisp\n  ;; Make a fake entry point for spacemacs, also modify the\n  ;; `user-emacs-directory' temporary to mislead spacemacs real emacs\n  ;; directory.\n  (require 'f)\n  (let* ((spacemacs-dir\n          (directory-file-name (f-join user-emacs-directory \"modules\" \"spacemacs\")))\n         (spacemacs-init\n          (concat (file-name-as-directory spacemacs-dir) \"init.el\"))\n         (user-emacs-directory (file-name-directory spacemacs-init)))\n    ;; Initial spacemacs, our emacs run on top of it\n    (load spacemacs-init))\n#+END_SRC\n\n** Some function should execute after loading spacemacs-init.\n\nspacemacs is really awesome, but there's something I don't like.\n\n*** Disable global highlight by default\n\n#+BEGIN_SRC emacs-lisp\n  (global-hl-line-mode -1)\n#+END_SRC\n\n*** switch back to `*scratch*' buffer after loading spacemacs finished\n\n#+BEGIN_SRC emacs-lisp\n  ;; After spacemacs loading finished, switch back to `*scratch*' buffer\n  ;; and make sure it's in `lisp-interaction-mode'\n  (switch-to-buffer \"*scratch*\")\n  (with-current-buffer (get-buffer-create \"*scratch*\")\n    (lisp-interaction-mode))\n#+END_SRC\n\n*** Not use ido-mode\n\nI don't like the =ido-mode=.\n\n#+BEGIN_SRC emacs-lisp\n  (ido-mode -1)\n#+END_SRC\n\n*** Move helm input in minibuffer\n\nI *really* hate spacemacs default echo the helm input in header line, it's\nreally annoying.\n\n#+BEGIN_SRC emacs-lisp\n  (setq helm-echo-input-in-header-line nil)\n  (remove-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)\n#+END_SRC\n\n* Basic setup\n\nMost setup I want to use is done by [[https://github.com/syl20bnr/spacemacs][spacemacs]], but I still keep some basic setup\nhere, some are not set or just keep for backward compability.\n\n** Startup emacs server\n\n#+BEGIN_SRC emacs-lisp\n  ;; Only start server mode if I'm not root\n  (unless (string-equal \"root\" (getenv \"USER\"))\n    (require 'server)\n    (unless (server-running-p) (server-start)))\n#+END_SRC\n\n** Under Mac OSX use Command key as ALT\n\nUnder Mac OSX, I always bind =Caps lock= as Control key, and make the =Command=\nkey as =ALT= key like I done in Linux.\n\nThe =Option= key will be setup as =Super=.\n\nWe also disable some keys like =⌘-h= bypass to system in emacs-mac port.\n\n#+BEGIN_SRC emacs-lisp\n  (setq mac-option-modifier 'super)\n  (setq mac-command-modifier 'meta)\n  (setq mac-pass-command-to-system nil)\n#+END_SRC\n\n** Don't ask me when close emacs with process is running\n\n#+BEGIN_SRC emacs-lisp\n  (when (require 'noflet)\n    (defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)\n      \"Prevent annoying \\\"Active processes exist\\\" query when you quit Emacs.\"\n      (noflet ((process-list ())) ad-do-it)))\n#+END_SRC\n\n** Don't ask me when kill process buffer\n\n#+BEGIN_SRC emacs-lisp\n  (setq kill-buffer-query-functions\n        (remq 'process-kill-buffer-query-function\n              kill-buffer-query-functions))\n#+END_SRC\n\n** Save custom-file as cache\n\nMost of my config is written in this file, it's no need to tracking the emacs's\ncustom-setting.\n\nI move the file to cache-dir and make git ignore it.\n\n#+BEGIN_SRC emacs-lisp\n  (setq-default custom-file (concat user-cache-directory \"custom.el\"))\n  ;; load custom-file only when file exist\n  (when (file-exists-p custom-file)\n    (load-file custom-file))\n#+END_SRC\n\n** Async rebuild init.el after save\n\n#+BEGIN_SRC emacs-lisp\n  (when (require 'async nil 'noerror)\n    ;; If I'm edit my init.org, async generate init.el when save.\n    (defun tangle-init ()\n      \"If the current buffer is 'init.org' the code-blocks are tangled.\"\n      (let ((buffer-name \"async-make-init.el\"))\n        (when (equal (buffer-file-name)\n                     (expand-file-name (concat user-emacs-directory \"init.org\")))\n          ;; If previous building buffer exist, discard it\n          (when (get-buffer (concat \"*\" buffer-name \"*\"))\n            (kill-buffer (concat \"*\" buffer-name \"*\")))\n          ;; build with `make init.el' command\n          (async-start-process buffer-name \"make\" 'ignore \"init.el\"))))\n    ;; Add to hook\n    (add-hook 'after-save-hook 'tangle-init))\n#+END_SRC\n\n** Turn-off menu bar\n\nThe menu bar is one of the UI elements which work best with mouses.\n\n#+BEGIN_SRC emacs-lisp\n  (menu-bar-mode -1)\n#+END_SRC\n\n** Turn-off tool bar\n\nI never use the tool bar, it's really no need.\n\n#+BEGIN_SRC emacs-lisp\n  (tool-bar-mode -1)\n#+END_SRC\n\n** Turn-off blinking cursor\n\nI hate the blinking cursor actually, it's really annoying.\n\n#+BEGIN_SRC emacs-lisp\n  (blink-cursor-mode -1)\n#+END_SRC\n\n** Turn-off scroll bar\n\nActually when you familier with emacs, you don't need to use scroll-bar anymore.\n\n#+BEGIN_SRC emacs-lisp\n  (scroll-bar-mode -1)\n#+END_SRC\n\n** Ask for y or n, not yes or no\n\nEmacs starts out asking for you to type yes or no with most important questions.\nJust let me use =y= or =n= with no =RET= required an I'm quite happy.\n\n#+BEGIN_SRC emacs-lisp\n  (defalias 'yes-or-no-p 'y-or-n-p)\n#+END_SRC\n\n* Languages and Encodings\n\nSince current Emacs default run on UTF-8, it's no need to setup the encoding.\n\nFor language, though Traditional Chinese is my mothertone, I still prefer use\n=en_US= to display time info.\n\n#+BEGIN_SRC emacs-lisp\n  (prefer-coding-system 'utf-8)\n  (setq system-time-locale \"en_US\")\n#+END_SRC\n\n* Buildin Packages                                                  :buildin:\n\nSome buildin packages not loaded by emacs, load it here.\n\n** cl-lib\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cl-lib)\n#+END_SRC\n\n** htmlize                                                         :htmlize:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package htmlize)\n#+END_SRC\n\n* External Packages                                                :packages:\n\nMost of emacs packages do not need many configs or just provide\ncommands/functions to use, I put them here.\n\n** 4clojure\n\n[[https://github.com/losingkeys/4clojure.el][4clojure.el]] let you open and evaluate [[http://www.4clojure.com/][4clojure]] questions.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package 4clojure)\n#+END_SRC\n\n** ascii\n\n[[http://www.emacswiki.org/emacs/AsciiMode][Ascii]] provides a way to display ASCII code on a window, that is, display in\nanother window an ASCII table highlighting the current character code.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package ascii\n    :init (progn\n            ;; ascii-toggle\n            (defun ascii-toggle ()\n              \"Toggle ascii-mode.\"\n              (interactive)\n              (if (not (ascii-off)) (ascii-on)))\n\n            ;; alias ascii to ascii-toggle\n            (defalias 'ascii 'ascii-toggle)))\n#+END_SRC\n\n** ascii-art-to-unicode\n\nConvert simple ASCII art drawings (and org-tables) to beautiful Unicode.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package ascii-art-to-unicode)\n#+END_SRC\n\n** iedit\n\n[[https://github.com/victorhge/iedit][iedit]] let you edit multiple regions in the same way simultaneously.\n\nGitHub: https://github.com/victorhge/iedit\n\n#+BEGIN_SRC emacs-lisp\n  (req-package iedit)\n#+END_SRC\n\n** pangu-spacing\n\n[[https://github.com/coldnew/pangu-spacing][pangu-spcing]] is an minor-mode to auto add =space= between Chinese and English\ncharacters. Note that these white-space characters are not really added to the\ncontents, it just like to do so.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package pangu-spacing\n    :init\n    (progn\n      ;; start pangu-spacing globally\n      (global-pangu-spacing-mode 1)\n      ;; Always insert `real' space in org-mode.\n      (add-hook 'org-mode-hook\n                '(lambda ()\n                   (set (make-local-variable 'pangu-spacing-real-insert-separtor) t)))))\n#+END_SRC\n\n** sx\n\n[[https://github.com/vermiculus/sx.el/][SX]] is a full featured Stack Exchange mode for GNU Emacs 24+. Using the official\nAPI, it provides a versatile experience for the Stack Exchange network within\nEmacs itself.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package sx :require sx-load)\n#+END_SRC\n\n** hungry-delete\n\n[[https://github.com/nflath/hungry-delete][hungry-delete]] borrows hungry deletion from =cc-mode=, which will causes deletion\nto delete all whitespace in the direction you are deleting.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package hungry-delete\n    :init (global-hungry-delete-mode))\n#+END_SRC\n\n** rainbow-mode\n\n[[https://julien.danjou.info/projects/emacs-packages][rainbow-mode]] s a minor mode for Emacs which displays strings representing colors\nwith the color they represent as background.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package rainbow-mode)\n#+END_SRC\n\n** doxymacs\n\n#+BEGIN_SRC emacs-lisp\n  (req-package doxymacs\n    :config\n    (add-hook 'prog-mode-hook '(lambda () (doxymacs-mode))))\n#+END_SRC\n\n** password-generator\n\n[[https://github.com/zargener/emacs-password-genarator][password-generator]] provides simple functions to create passwords and insert them\ninside buffer immediately.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package password-generator)\n#+END_SRC\n\n** discover-my-major\n\n[[https://github.com/steckerhalter/discover-my-major][discover-my-major]] make you discover key bindings and their meaning for the\ncurrent Emacs major mode.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package discover-my-major)\n#+END_SRC\n\n** howdoi\n\n[[https://github.com/atykhonov/emacs-howdoi][howdoi]] is a way to query Stack Overflow directly from the Emacs and get back the\nmost upvoted answer to the first question that comes up for that query.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package howdoi)\n#+END_SRC\n\n** exec-path-from-shell\n\n[[https://github.com/purcell/exec-path-from-shell][exec-path-from-shell]] is A GNU Emacs library to ensure environment variables\ninside Emacs look the same as in the user's shell.\n\nEver find that a command works in your shell, but not in Emacs?\n\nThis happens a lot on OS X, where an Emacs instance started from the GUI\ninherits a default set of environment variables.\n\nThis library works solves this problem by copying important environment\nvariables from the user's shell: it works by asking your shell to print out the\nvariables of interest, then copying them into the Emacs environment.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package exec-path-from-shell\n    :init (when (memq window-system '(mac ns x))\n            (exec-path-from-shell-initialize)))\n#+END_SRC\n\n** manage-minor-mode\n\n[[https://github.com/ShingoFukuyama/manage-minor-mode][manage-minor-mode]] let you manage your minor-mode on the dedicated interface\nbuffer.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package manage-minor-mode)\n#+END_SRC\n\n** noflet \n\nGitHub: https://github.com/nicferrier/emacs-noflet\n\n#+BEGIN_SRC emacs-lisp\n  (req-package noflet)\n#+END_SRC\n\n** mustache                                                       :mustache:\n\nA mustache templating library in Emacs Lisp.\n\nGitHub: https://github.com/Wilfred/mustache.el\n\n#+BEGIN_SRC emacs-lisp\n  (req-package mustache)\n#+END_SRC\n\n** manage-minor-mode\n\nManage your minor-mode on the dedicated interface buffer.\n\nGitHub: https://github.com/ShingoFukuyama/manage-minor-mode\n\n#+BEGIN_EXAMPLE\n  (req-package manage-minor-mode)\n#+END_EXAMPLE\n\n** expand-region\n\nExpand region increases the selected region by semantic units. Just keep\npressing the key until it selects what you want.\n\nGitHub: https://github.com/magnars/expand-region.el\n\n#+BEGIN_SRC emacs-lisp\n  (req-package expand-region)\n#+END_SRC\n\n** verify-url\n\nverify-url is a little tool that used to find out invalid urls in the buffer or\nregion.\n\nUse =M-x verify-url= to find invalid urls in current buffer.\n\nAfter executed command, you can use =verify-url/next-invalid-url= to goto next\ninvalid-url or =verify-url/previous-invalid-url= to goto previous one.\n\nGitHub: https://github.com/lujun9972/verify-url\n\n#+BEGIN_SRC emacs-lisp\n  (req-package verify-url)\n#+END_SRC\n\n** zzz-to-char\n\nThis package provides two new commands: =zzz-to-char= and =zzz-up-to-char= which\nwork like built-ins zap-to-char and zap-up-to-char, but allow you quickly select\nexact character you want to “zzz” to.\n\nThe commands are minimalistic and often work like built-in ones when there is\nonly one occurrence of target character (except they automatically work in\nbackward direction too). You can also specify how many characters to scan from\neach side of point, see =zzz-to-char-reach=.\n\nThis package uses avy as backend.\n\nGitHub: https://github.com/mrkkrp/zzz-to-char\n\n#+BEGIN_SRC emacs-lisp\n  (req-package zzz-to-char)\n#+END_SRC\n\n* Interactive Commands                                              :command:\n\nIn emacs, we can use =M-x= to execute interactive commands, I\nimplement some of them to make my emacs more easy to use.\n\n** Buffers                                                          :buffer:\n\n*** Kill all buffers except *scratch* buffer\n\nSometimes I just want to kill all buffers, this command will kill all\nof them and make =*scratch*= buffer alone.\n\n#+BEGIN_SRC emacs-lisp\n  (defun nuke-all-buffers ()\n    \"Kill all buffers, leaving *scratch* only.\"\n    (interactive)\n    (mapcar (lambda (x) (kill-buffer x)) (buffer-list))\n    (delete-other-windows))\n#+END_SRC\n\n*** Make emacs can always save buffers (even if file is not modified)\n\nThe default command *save-buffer* will not really save file when it\nuntouched, use this command can let me force save file even if file is\nnot modified.\n\n#+BEGIN_SRC emacs-lisp\n  (defun save-buffer-always ()\n    \"Save the buffer even if it is not modified.\"\n    (interactive)\n    (set-buffer-modified-p t)\n    (save-buffer))\n#+END_SRC\n\n*** Abort minibuffer recursive edit\n\n#+BEGIN_SRC emacs-lisp\n  (defun minibuffer-keyboard-quit ()\n    \"Abort recursive edit.\n  In Delete Selection mode, if the mark is active, just deactivate it;\n  then it takes a second \\\\[keyboard-quit] to abort the minibuffer.\"\n    (interactive)\n    (if (and delete-selection-mode transient-mark-mode mark-active)\n        (setq deactivate-mark t)\n      (when (get-buffer \"*Completions*\") (delete-windows-on \"*Completions*\"))\n      (abort-recursive-edit)))\n#+END_SRC\n\n*** Make buffer untabify\n\n#+BEGIN_SRC emacs-lisp\n  (defun untabify-buffer ()\n    (interactive)\n    (save-excursion\n      (untabify (point-min) (point-max))))\n#+END_SRC\n\n*** Indent whole buffer\n\n#+BEGIN_SRC emacs-lisp\n  (defun indent-whole-buffer ()\n    \"Indent whole buffer.\"\n    (interactive)\n    (save-excursion\n      (indent-region (point-min) (point-max))))\n#+END_SRC\n\n*** Remove buffers trailing whitespace and untabify\n\n#+BEGIN_SRC emacs-lisp\n  (defun cleanup-buffer ()\n    \"Perform a bunch of operations on the whitespace content of a buffer.\"\n    (interactive)\n    (save-excursion\n      (delete-trailing-whitespace)\n      (indent-region (point-min) (point-max))\n      (untabify (point-min) (point-max))))\n#+END_SRC\n\n*** Replace the preceding sexp with its value\n\n#+BEGIN_SRC emacs-lisp\n  (defun eval-and-replace ()\n    \"Replace the preceding sexp with its value.\"\n    (interactive)\n    (backward-kill-sexp)\n    (condition-case nil\n        (prin1 (eval (read (current-kill 0)))\n               (current-buffer))\n      (error (message \"Invalid expression\")\n             (insert (current-kill 0)))))\n#+END_SRC\n\n*** Quick folding source block\n\n#+BEGIN_SRC emacs-lisp\n  (defun quick-folding-source ()\n    \"Use emacs buildin easy to folding code.\"\n    (interactive)\n    (set-selective-display\n     (if selective-display nil 1)))\n#+END_SRC\n\n** Edit (Insert/Remove)\n\n*** Insert U200B char\n\n=\u003cU200B\u003e= character is a =zero width space character= which is nice to\nuse under org-mode.\n\nFor 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]]\n\n#+BEGIN_SRC emacs-lisp\n  (defun insert-U200B-char ()\n    \"Insert \u003cU200B\u003e char, this character is nice use in org-mode.\"\n    (interactive)\n    (insert \"\\ufeff\"))\n#+END_SRC\n\n*** Insert empty line after current line\n\n#+BEGIN_SRC emacs-lisp\n  (defun insert-empty-line ()\n    \"Insert an empty line after current line and position cursor on newline.\"\n    (interactive)\n    (move-end-of-line nil)\n    (open-line 1)\n    (next-line 1))\n#+END_SRC\n\n*** Insert lorem ipsum\n\n#+BEGIN_SRC emacs-lisp\n  (defun insert-lorem ()\n    \"Insert a lorem ipsum.\"\n    (interactive)\n    (insert \"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \"\n            \"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim\"\n            \"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut \"\n            \"aliquip ex ea commodo consequat. Duis aute irure dolor in \"\n            \"reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \"\n            \"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \"\n            \"culpa qui officia deserunt mollit anim id est laborum.\"))\n#+END_SRC\n\n*** Delete word\n\n#+BEGIN_SRC emacs-lisp\n  (defun delete-word (arg)\n    \"Delete characters forward until encountering the end of a word.\n  With argument, do this that many times.\"\n    (interactive \"p\")\n    (delete-region (point) (progn (forward-word arg) (point))))\n#+END_SRC\n\n*** Backward delete word\n\n#+BEGIN_SRC emacs-lisp\n  (defun backward-delete-word (arg)\n    \"Delete characters backward until encountering the end of a word.\n  With argument, do this that many times.\"\n    (interactive \"p\")\n    (delete-word (- arg)))\n#+END_SRC\n\n*** Set mark or expand region\n\n#+BEGIN_SRC emacs-lisp\n  (defun set-mark-mode/rectangle-mark-mode ()\n    \"toggle between set-mark-command or rectangle-mark-mode\"\n    (interactive)\n    (if (not mark-active)\n       (call-interactively 'set-mark-command)\n      (call-interactively 'rectangle-mark-mode)))\n#+END_SRC\n\n*** Indent region/buffer and cleanup\n\n#+BEGIN_SRC emacs-lisp\n  (defun indent-region-or-buffer-and-cleanup ()\n    \"Indents a region if selected, otherwise the whole buffer.\"\n    (interactive)\n    (cl-flet ((format-fn (BEG END) (indent-region BEG END) (untabify BEG END)))\n      (save-excursion\n        (if (region-active-p)\n            (progn\n              (delete-trailing-whitespace (region-beginning) (region-end))\n              (format-fn (region-beginning) (region-end))\n              (message \"Indented selected region and clear whitespace and untabify.\"))\n          (progn\n            (delete-trailing-whitespace)\n            (format-fn (point-min) (point-max))\n            (message \"Indented whole buffer and clear whitespace and untabify.\"))))))\n#+END_SRC\n\n** File Handle\n\n*** Reopen file as root\n\n#+BEGIN_SRC emacs-lisp\n  (defun file-reopen-as-root ()\n    (interactive)\n    (when buffer-file-name\n      (find-alternate-file\n       (concat \"/sudo:root@localhost:\"\n               buffer-file-name))))\n#+END_SRC\n\n*** Delete current buffer file\n\n#+BEGIN_SRC emacs-lisp\n  (defun delete-current-buffer-file ()\n    \"Removes file connected to current buffer and kills buffer.\"\n    (interactive)\n    (let ((filename (buffer-file-name))\n          (buffer (current-buffer))\n          (name (buffer-name)))\n      (if (not (and filename (file-exists-p filename)))\n          (ido-kill-buffer)\n        (when (yes-or-no-p \"Are you sure you want to remove this file? \")\n          (delete-file filename)\n          (kill-buffer buffer)\n          (message \"File '%s' successfully removed\" filename)))))\n#+END_SRC\n\n*** Rename current Buffer and file\n\n#+BEGIN_SRC emacs-lisp\n  (defun rename-current-buffer-file ()\n    \"Renames current buffer and file it is visiting.\"\n    (interactive)\n    (let ((name (buffer-name))\n          (filename (buffer-file-name)))\n      (if (not (and filename (file-exists-p filename)))\n          (error \"Buffer '%s' is not visiting a file!\" name)\n        (let ((new-name (read-file-name \"New name: \" filename)))\n          (if (get-buffer new-name)\n              (error \"A buffer named '%s' already exists!\" new-name)\n            (rename-file filename new-name 1)\n            (rename-buffer new-name)\n            (set-visited-file-name new-name)\n            (set-buffer-modified-p nil)\n            (message \"File '%s' successfully renamed to '%s'\"\n                     name (file-name-nondirectory new-name)))))))\n#+END_SRC\n\n*** Add executable attribute to file\n\nActually this command is the same as =chmod +x= but it doesn't use any shell\ncommand, it use emacs's logior function to change file attribute.\n\nI only make =owener= can has executable permission, not change it for gourp or\nothers user.\n\n#+BEGIN_SRC emacs-lisp\n  (defun set-file-executable()\n    \"Add executable permissions on current file.\"\n    (interactive)\n    (when (buffer-file-name)\n      (set-file-modes buffer-file-name\n                      (logior (file-modes buffer-file-name) #o100))\n      (message (concat \"Made \" buffer-file-name \" executable\"))))\n#+END_SRC\n\n*** Clone current file to new one\n\n#+BEGIN_SRC emacs-lisp\n  (defun clone-file-and-open (filename)\n    \"Clone the current buffer writing it into FILENAME and open it\"\n    (interactive \"FClone to file: \")\n    (save-restriction\n      (widen)\n      (write-region (point-min) (point-max) filename nil nil nil 'confirm))\n    (find-file filename))\n#+END_SRC\n\n** Debug\n\n*** Eval emacs buffer until error\n\nA really nice command help me to find error on elisp buffer.\n\n#+BEGIN_SRC emacs-lisp\n  (defun eval-buffer-until-error ()\n    \"Evaluate emacs buffer until error occured.\"\n    (interactive)\n    (goto-char (point-min))\n    (while t (eval (read (current-buffer)))))\n#+END_SRC\n\n* Theme                                                               :theme:\n\nI always use dark theme for coding, [[https://github.com/kuanyui/moe-theme.el][moe-theme]] is a good start point, it's bright\nand has good default faces for most modes. It also has dark and light versions,\nwhich is convenient.\n\nHowever, I always want to customize everything on my own, so I rebuild another\nemacs theme called =coldnew-theme-night= and =coldnew-theme-day=, you can find\nthem at [[file:theme/coldnew-theme.el]].\n\nBefore use emacs's =load-theme= function, I advise it to it fully\nunload previous theme before loading a new one.\n\n#+BEGIN_SRC emacs-lisp\n  ;; Make `load-theme' fully unload previous theme before loading a new one.\n  (defadvice load-theme\n      (before theme-dont-propagate activate)\n    (mapc #'disable-theme custom-enabled-themes))\n\n  ;; My light theme\n  (req-package coldnew-theme-day-theme\n    :require (powerline powerline-evil))\n\n  ;; My night them (default)\n  (req-package coldnew-theme-night-theme\n    :config (coldnew-theme-night))\n\n  ;; (req-package coldnew-modeline-config\n  ;;   :require (powerline powerline-evil))\n  ;; TODO:\n  (req-package spaceline)\n#+END_SRC\n\n* Minibuffer                                                    :minibuffer:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package minibuffer\n    :config\n    (progn\n      ;; Make cursor in minibufer use bar shape\n      (add-hook 'minibuffer-setup-hook '(lambda () (setq cursor-type 'bar)))))\n#+END_SRC\n\n** Setup keybindings                                            :keybinding:\n\nSome general purpose keybinding I famillier with.\n\n#+BEGIN_SRC emacs-lisp\n  (define-key minibuffer-local-map (kbd \"C-w\") 'backward-kill-word)\n  (define-key minibuffer-local-map (kbd \"M-p\") 'previous-history-element)\n  (define-key minibuffer-local-map (kbd \"M-n\") 'next-history-element)\n  (define-key minibuffer-local-map (kbd \"C-g\") 'minibuffer-keyboard-quit)\n#+END_SRC\n\nSome shortcuts let me access system path more easily.\n\n#+BEGIN_SRC emacs-lisp\n  (add-hook\n   'minibuffer-setup-hook\n   '(lambda ()\n      ;; switch to tmp dir\n      (define-key minibuffer-local-map\n        (kbd \"M-t\") '(lambda()\n                       (interactive)\n                       (let ((dir (if (eq system-type 'darwin)\n                                      \"/Volumes/ramdisk/\" \"/tmp/\")))\n                         (kill-line 0) (insert dir))))\n\n      ;; switch to home dir\n      (define-key minibuffer-local-map\n        (kbd \"M-h\") '(lambda() (interactive) (kill-line 0)\n                       (insert (file-name-as-directory (getenv \"HOME\")))))\n\n      ;; other with C-x prefix to prevent conflict with helm\n      (define-key minibuffer-local-map\n        (kbd \"C-x r\") '(lambda() (interactive) (kill-line 0) (insert \"/\")))\n\n      ;; More easy for tramp connect\n      (define-key minibuffer-local-map\n        (kbd \"C-x s\") '(lambda() (interactive) (kill-line 0) (insert \"/ssh:\")))\n      ))\n#+END_SRC\n\n* Editors                                                            :editor:\n\nWhy emacs config has an editor section, doesn't means emacs is not an editor ?\nYes, Emacs is an OS :)\n\nI put some editor/IDE relative functions and packages here.\n\n** Line Numbers                                                      :linum:\n\nIn most case, I'll make line numers display globally by =linum=.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package linum :init (global-linum-mode 1))\n#+END_SRC\n\nDisable line number in some mode, for example, since =org-mode= can\nhas many lines, it's not recommand to enable linum-mode.\n\nI use =linum-off= to disable some mode.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package linum-off\n    :config\n    (progn\n      (setq linum-disabled-mode-list\n            '(eshell-mode shell-mode term-mode erc-mode compilation-mode\n                          woman-mode w3m-mode calendar-mode org-mode\n                          ))))\n#+END_SRC\n\n** Keeping files in sync\n\nBy default, Emacs will not update the contents of open buffers when a file\nchanges on disk. This is inconvenient when switching branches in Git - as you’d\nrisk editing stale buffers.\n\nThis problem can be solved by:\n\n#+BEGIN_SRC emacs-lisp\n  (global-auto-revert-mode 1)\n  (setq global-auto-revert-non-file-buffers t)\n  (setq auto-revert-verbose nil)\n  (setq revert-without-query '(\".*\")) ;; disable revert query\n#+END_SRC\n\n** Colorfy delimters\n\n[[https://github.com/Fanael/rainbow-delimiters][rainbow-delimiters]] is a \"rainbow parentheses\"-like mode which\nhighlights delimiters such as parentheses, brackets or braces\naccording to their depth. Each successive level is highlighted in a\ndifferent color. This makes it easy to spot matching delimiters,\norient yourself in the code, and tell which statements are at a given\ndepth.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package rainbow-delimiters\n    :config\n    (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))\n#+END_SRC\n\n** Vim Emulation                                                      :evil:\n\nThough I am really familier with emacs, I still like some vim command.\n\n#+BEGIN_SRC emacs-lisp :noweb no-export :exports code\n  (req-package evil\n    :require (undo-tree)\n    :init (evil-mode t)\n    :config\n    (progn\n      ;; default state set to insert-state\n      (setq evil-default-state 'insert)\n      ;; Bind all emacs-state key to insert state\n      (setcdr evil-insert-state-map nil)\n      (define-key evil-insert-state-map\n        (read-kbd-macro evil-toggle-key) 'evil-emacs-state)\n      ;; Make sure `ESC' in insert-state will call `evil-normal-state'\n      (define-key evil-insert-state-map [escape] 'evil-normal-state)\n      ;; Make all emacs-state buffer become to insert-state\n      (dolist (m evil-emacs-state-modes)\n        (add-to-list 'evil-insert-state-modes m))\n      ))\n#+END_SRC\n\n** Add support for editorconfig                               :editorconfig:\n\n[[http://editorconfig.org/][EditorConfig]] helps developers define and maintain consistent coding\nstyles between different editors and IDEs. The EditorConfig project\nconsists of a file format for defining coding styles and a collection\nof text editor plugins that enable editors to read the file format and\nadhere to defined styles. EditorConfig files are easily readable and\nthey work nicely with version control systems.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package editorconfig)\n#+END_SRC\n\n** En/Decrypt files by EasyPG\n\n#+BEGIN_SRC emacs-lisp\n  (req-package epa-file\n    :init (epa-file-enable)\n    :config\n    (progn\n      ;; Control whether or not to pop up the key selection dialog.\n      (setq epa-file-select-keys 0)\n      ;; Cache passphrase for symmetric encryption.\n      (setq epa-file-cache-passphrase-for-symmetric-encryption t)))\n#+END_SRC\n\n** Remote file editing                                               :tramp:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package tramp\n    :config\n    (progn\n      (setq tramp-default-method \"rsync\")))\n#+END_SRC\n\n** Intelligently call whitespace-cleanup on save                :whitespace:\n\nThis Emacs library minor mode will intelligently call =whitespace-cleanup= before\nbuffers are saved.\n\n=whitespace-cleanup= is a handy function, but putting it in =before-save-hook=\nfor every buffer is overkill, and causes messy diffs when editing third-party\ncode that did not initially have clean whitespace.\n\nAdditionally, whitespace preferences are often project-specific, and it's\ninconvenient to set up =before-save-hook= in a =.dir-locals.el= file.\n\n=whitespace-cleanup-mode= is a minor mode which calls =whitespace-cleanup=\nbefore saving the current buffer, but only if the whitespace in the buffer was\ninitially clean. It determines this by quickly checking to see if\n=whitespace-cleanup= would have any effect on the buffer.\n\nGitHub: https://github.com/purcell/whitespace-cleanup-mode\n\n#+BEGIN_SRC emacs-lisp\n  (req-package whitespace-cleanup-mode\n    :init (add-hook 'prog-mode-hook 'whitespace-cleanup-mode))\n#+END_SRC\n\n** Highlight numbers\n\n=highlight-numbers= is an Emacs minor mode that highlights numeric literals in\nsource code.\n\nGitHub: https://github.com/Fanael/highlight-numbers\n\n#+BEGIN_SRC emacs-lisp\n  (req-package highlight-numbers\n    :init\n    ;; json-mode has it's own highlight numbers method\n    (add-hook 'prog-mode-hook '(lambda()\n                                 (if (not (derived-mode-p 'json-mode))\n                                     (highlight-numbers-mode)))))\n#+END_SRC\n\n** Highlight escape charset\n\nGitHub: https://github.com/dgutov/highlight-escape-sequences\n\n#+BEGIN_SRC emacs-lisp\n  (req-package highlight-escape-sequences\n    :config\n    (progn\n      ;; Make face the same as builtin face\n      (put 'font-lock-regexp-grouping-backslash 'face-alias 'font-lock-builtin-face)\n\n      ;; Add extra modes\n      (add-to-list 'hes-simple-modes 'c-mode)\n      (add-to-list 'hes-simple-modes 'c++-mode)\n\n      ;; Enable globally\n      (hes-mode 1)))\n#+END_SRC\n\n** Highlight FIXME, TODO\n\n#+begin_src emacs-lisp\n  (defun font-lock-comment-annotations ()\n    \"Highlight a bunch of well known comment annotations.\n  This functions should be added to the hooks of major modes for programming.\"\n    (font-lock-add-keywords\n     nil\n     '((\"\\\\\u003c\\\\(FIX\\\\(ME\\\\)?\\\\|BUG\\\\|HACK\\\\):\" 1 font-lock-warning-face t)\n       (\"\\\\\u003c\\\\(NOTE\\\\):\" 1 'org-level-2 t)\n       (\"\\\\\u003c\\\\(TODO\\\\):\" 1 'org-todo t)\n       (\"\\\\\u003c\\\\(DONE\\\\):\" 1 'org-done t))\n     ))\n\n  (add-hook 'prog-mode-hook 'font-lock-comment-annotations)\n#+end_src\n\n** Project management with projectile\n\n#+BEGIN_SRC emacs-lisp\n  (req-package projectile\n    :interpreter (\"projectile\" . projectil-mode))\n#+END_SRC\n\n** Completion with Company mode                                    :company:\n\n[[http://company-mode.github.io/][Company]] is a text completion framework for Emacs. The name stands for \"complete\nanything\". It uses pluggable back-ends and front-ends to retrieve and display\ncompletion candidates.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package company\n    :init (global-company-mode 1)\n    :config (setq company-idle-delay nil))\n#+END_SRC\n\n*** Completion C/C++ headers\n\n#+BEGIN_SRC emacs-lisp\n  (req-package company-c-headers\n    :require company\n    :init (add-to-list 'company-backends 'company-c-headers))\n#+END_SRC\n\n*** Add quickhelp in company-mode\n\n#+BEGIN_SRC emacs-lisp\n  (req-package company-quickhelp\n    :require company\n    :init (company-quickhelp-mode 1))\n#+END_SRC\n\n*** Sort completion candidates by previous completion choices\n\nCompany-statistics is a global minor mode built on top of the in-buffer\ncompletion system company-mode. The idea is to keep a log of a certain number of\ncompletions you choose, along with some context information, and use that to\nrank candidates the next time you have to choose — hopefully showing you\nlikelier candidates at the top of the list.\n\nGitHub: https://github.com/company-mode/company-statistics\n\n#+BEGIN_SRC emacs-lisp\n  (req-package company-statistics\n    :config\n    (progn\n      (setq company-statistics-file (concat user-cache-directory\n                                            \"company-statistics-cache.el\"))\n      (add-hook 'after-init-hook 'company-statistics-mode)))\n#+END_SRC\n\n*** Setup keybindings                                          :keybinding:\n\n#+BEGIN_SRC emacs-lisp\n  (add-hook\n   'company-mode-hook\n   '(lambda()\n      (define-key company-active-map (kbd \"C-g\") 'company-abort)\n      (define-key company-active-map (kbd \"C-n\") 'company-select-next)\n      (define-key company-active-map (kbd \"C-p\") 'company-select-previous)\n      (define-key company-active-map (kbd \"TAB\") 'company-complete-selection)\n      (define-key company-active-map (kbd \"\u003ctab\u003e\") 'company-complete-selection)))\n#+END_SRC\n\n** Snippet handle by yasnippet                                   :yasnippet:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package yasnippet\n    :init (yas-global-mode 1)\n    :mode (\"emacs.+/snippets/\" . snippet-mode)\n    :config\n    (progn\n      (setq yas/prompt-functions '(yas-dropdown-prompt\n                                   yas-completing-prompt\n                                   yas-ido-prompt))\n\n      (setq yas/snippet-dirs (concat user-emacs-directory \"snippets\"))))\n#+END_SRC\n\n*** Implement org-mode's easy-template like function\n\nI really like org-mode's =easy-template= function, so I implement one called\n=major-mode-expand= which will let you use easy-template like function in any\nmajor-mode.\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'yasnippet\n    '(progn\n       (defadvice yas-expand (around major-mode-expand activate)\n         \"Try to complete a structure template before point like org-mode does.\n    This looks for strings like \\\"\u003ce\\\" on an otherwise empty line and\n    expands them.\n    Before use this function, you must setup `major-mode-name'-expand-alist variable.\n\n    Take emacs-lisp-mode as example, if you wand to use \u003cr to expand your snippet `require'\n    in yasnippet, you muse setup the emacs-lisp-mode-expand-alist variable.\n\n     (setq emacs-lisp-expand-alist '((\\\"r\\\" . \\\"require\\\")))\"\n         (let* ((l (buffer-substring (point-at-bol) (point)))\n                (expand-symbol (intern (concat (symbol-name major-mode) \"-expand-alist\")))\n                (expand-alist (if (boundp expand-symbol) (symbol-value expand-symbol) nil))\n                a)\n           (when (and (looking-at \"[ \\t]*$\")\n                      (string-match \"^[ \\t]*\u003c\\\\([a-zA-Z]+\\\\)$\" l)\n                      (setq a (assoc (match-string 1 l) expand-alist)))\n             (backward-delete-char (1+ (length (car-safe a))))\n             (if (symbolp (cdr-safe a))\n                 (funcall (cdr-safe a))\n               (insert (cdr-safe a)))\n             t)\n           ad-do-it))\n       ))\n#+END_SRC\n\nTake emacs-lisp-mode as example, if I want to use =\u003cr= and press =TAB=\nthen yasnippet will expand the command, just add following code:\n\n#+BEGIN_SRC emacs-lisp :tangle no\n  (setq emacs-lisp-mode-expand-alist '((\"r\" . \"require\")))\n#+END_SRC\n\nFor c-mode, just do the same but change the relative\n*major-mode-expand-alist* like following\n\n#+BEGIN_SRC emacs-lisp :tangle no\n  (setq c-mode-expand-alist '((\"i\" . \"include\")))\n#+END_SRC\n\n* Buffer                                                             :buffer:\n** Create *scratch* automatically\n\nSometimes I'll clean the =*scratch*= buffer by kill it, add following function\nto let emacs re-create it automatically.\n\n#+BEGIN_SRC emacs-lisp\n  ;; Create *scratch* automatically\n  (run-with-idle-timer 1 t\n                       '(lambda ()\n                          (unless (get-buffer \"*scratch*\")\n                            (with-current-buffer (get-buffer-create \"*scratch*\")\n                              (lisp-interaction-mode)))))\n#+END_SRC\n\n* Helm                                                                 :helm:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package helm\n    :require helm-config\n    :init (helm-mode 1)\n    :config\n    (progn\n      ;; Use fuzzy match in helm\n      (setq helm-M-x-fuzzy-match t)\n      (setq helm-buffers-fuzzy-matching t)\n      (setq helm-recentf-fuzzy-match t)\n      ;; make helm can select anything even not match\n      (setq helm-move-to-line-cycle-in-source nil)\n      (setq helm-ff-search-library-in-sexp t)\n      (setq helm-ff-file-name-history-use-recentf t)\n      ))\n#+END_SRC\n\n** Setup keybindings                                          :keybinding:\n\n#+BEGIN_SRC emacs-lisp :noweb yes :results silent\n  (add-hook\n   'helm-mode-hook\n   '(lambda()\n      ;; use TAB to complete helm\n      (define-key helm-map (kbd \"TAB\")   'helm-execute-persistent-action)\n      (define-key helm-map (kbd \"\u003ctab\u003e\") 'helm-execute-persistent-action)\n      (define-key helm-map (kbd \"C-w\") 'backward-kill-word)))\n#+END_SRC\n\n* Org                                                                   :org:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package org\n    :require (org-crypt)\n    :mode ((\"\\\\.org\\\\'\" . org-mode)\n           (\"\\\\.org_archive\\\\'\" . org-mode))\n  :config\n  (progn\n    ;; Always enable auto indent mode\n    (setq org-indent-mode t)\n    ;; fontify source code\n    (setq org-src-fontify-natively t)\n    ;; Use current window when switch to source block\n    (setq org-src-window-setup 'current-window)\n    ;; Disable prompting to evaluate babel blocks\n    (setq org-confirm-babel-evaluate nil)\n    ;; Disable add validation link when export to HTML\n    (setq org-html-validation-link nil)))\n#+END_SRC\n\n** Capture and Agenda\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'org\n    '(progn\n       ;; make agenda show on current window\n       (setq org-agenda-window-setup 'current-window)\n       ;; highlight current in agenda\n       (add-hook 'org-agenda-mode-hook 'hl-line-mode)\n       ;; Setup files for agenda\n       (setq org-agenda-files (list \"~/Org/task/Office.org\" \"~/Org/task/Personal.org\"))\n       ;;\n       (setq org-directory \"~/Org\")\n       (setq org-default-notes-file (f-join org-directory \"task\" \"Office.org\"))\n       ;; Always use `C-g' to exit agenda\n       (add-hook 'org-agenda-mode-hook\n                 '(lambda ()\n                    (local-set-key (kbd \"C-g\") 'org-agenda-exit)))\n       ))\n#+END_SRC\n\n** Extend org-mode's easy templates\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'org\n    '(progn\n      (add-to-list 'org-structure-template-alist\n                   '(\"E\" \"#+BEGIN_SRC emacs-lisp\\n?\\n#+END_SRC\"))\n      (add-to-list 'org-structure-template-alist\n                   '(\"S\" \"#+BEGIN_SRC sh\\n?\\n#+END_SRC\"))\n      (add-to-list 'org-structure-template-alist\n                   '(\"p\" \"#+BEGIN_SRC plantuml :file uml.png \\n?\\n#+END_SRC\"))\n      ))\n#+END_SRC\n\n** Extend babel support languages\n\n#+BEGIN_SRC emacs-lisp\n    (eval-after-load 'org\n      '(progn\n         (org-babel-do-load-languages\n          'org-babel-load-languages\n          '((emacs-lisp . t)\n            (C . t)\n            (ditaa . t)\n            (dot . t)\n            (js . t)\n            (latex . t)\n            (perl . t)\n            (python . t)\n            (ruby . t)\n            (sh . t)\n            (plantuml . t)\n            (clojure . t)\n            ))\n         (add-to-list 'org-src-lang-modes '(\"dot\" . graphviz-dot))\n  ))\n#+END_SRC\n\n** Setup link abbreviations\n\n[[https://www.gnu.org/software/emacs/manual/html_node/org/Link-abbreviations.html][Link abbreviations]]\n\nAn abbreviated link looks like\n\n: [[linkword:tag][description]]\n\n#+BEGIN_SRC emacs-lisp\n  (setq org-link-abbrev-alist\n        '((\"google\" . \"http://www.google.com/search?q=\")\n          (\"google-map\" . \"http://maps.google.com/maps?q=%s\")\n          ))\n#+END_SRC\n\n** Make spell-checking tool ignore some org-mode section\n\nsee: http://emacs.stackexchange.com/questions/450/intelligent-spell-checking-in-org-mode\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'ispell\n    '(progn\n       (add-to-list 'ispell-skip-region-alist '(\":\\\\(PROPERTIES\\\\|LOGBOOK\\\\):\" . \":END:\"))\n       (add-to-list 'ispell-skip-region-alist '(\"#\\\\+BEGIN_SRC\" . \"#\\\\+END_SRC\"))\n       ))\n#+END_SRC\n\n** Latex Export\n\n#+BEGIN_SRC emacs-lisp\n  (setq org-format-latex-options\n        '(:forground \"black\" :background \"white\"\n                     :scale 1.5\n                     :html-foreground \"Black\" :html-background \"Transparent\"\n                     :html-scale 1.0\n                     :matchers (\"begin\" \"$1\" \"$\" \"$$\" \"\\\\(\" \"\\\\[\")))\n#+END_SRC\n\n** Setup keybindings                                          :keybinding:\n\n#+BEGIN_SRC emacs-lisp :noweb yes :results silent\n  (add-hook\n   'org-mode-hook\n   '(lambda()\n      (define-key org-mode-map (kbd \"C-c b\") 'org-metaleft)\n      (define-key org-mode-map (kbd \"C-c f\") 'org-metaright)\n      (define-key org-mode-map (kbd \"C-c p\") 'org-metaup)\n      (define-key org-mode-map (kbd \"C-c p\") 'org-metadown)\n      (define-key org-mode-map (kbd \"C-c i\") 'org-insert-link)\n      (define-key org-mode-map (kbd \"C-c I\") 'org-toggle-inline-images)))\n#+END_SRC\n\n* Programming Languages\n\n** Bash                                                               :bash:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package flymake-shell\n    :require (flymake shell)\n    :config (add-hook 'sh-set-shell-hook 'flymake-shell-load))\n#+END_SRC\n\n** Batch                                                               :bat:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package batch-mode :mode \"\\\\.bat\\\\'\")\n#+END_SRC\n\n** C / C++                                                              :cpp:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cc-mode\n    :mode\n    ((\"\\\\.h\\\\'\" . c-mode)\n     (\"\\\\.c\\\\'\" . c-mode)\n     (\"\\\\.hpp\\\\'\" . c++-mode)\n     (\"\\\\.cpp\\\\'\" . c++-mode))\n    :config\n    (progn\n      ;; use regexp to check if it's C++ header\n      (add-to-list 'magic-mode-alist\n                   `(,(lambda ()\n                        (and (string= (file-name-extension (or (buffer-file-name) \"\")) \"h\")\n                             (or (re-search-forward \"#include \u003c\\\\w+\u003e\"\n                                                    magic-mode-regexp-match-limit t)\n                                 (re-search-forward \"\\\\W\\\\(class\\\\|template\\\\namespace\\\\)\\\\W\"\n                                                    magic-mode-regexp-match-limit t)\n                                 (re-search-forward \"std::\"\n                                                    magic-mode-regexp-match-limit t))))\n                     . c++-mode))\n      ))\n#+END_SRC\n\n*** Add eldoc support for C/C++                                     :eldoc:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package c-eldoc\n    :config\n    (progn\n      (add-hook 'c-mode-common-hook\n                '(lambda ()\n                   (setq c-eldoc-includes \"`pkg-config gtk+-3.0 --cflags --libs` -I./ -I../\")\n                   (c-turn-on-eldoc-mode)))))\n#+END_SRC\n\n*** Highlight a few dangerous types in C/C++                   :cwarn:\n\n[[http://www.emacswiki.org/emacs/CWarnMode][cwarn-mode]] is a minor mode that ca highlight a few dangerous types in C/C++.\n\nBy default it highlights:\n\n- Semicolons right after conditions and loops (e.g. ~if (x == y);~)\n- Assignments in tests (e.g. ~if (x = y) {~)\n- Functions with reference parameters (e.g. ~void funct(string \u0026p) {~)\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cwarn\n    :init (add-hook 'c-mode-common-hook '(lambda () (cwarn-mode 1))))\n#+END_SRC\n\n*** Use dummy-h-mode to help detect header's major mode\n\n[[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\nfile.\n\nGitHub: https://github.com/yascentur/dummy-h-mode-el\n\n#+BEGIN_SRC emacs-lisp\n  (req-package dummy-h-mode\n    :require cc-mode\n    :mode \"\\\\.h$\"\n    :config\n    (progn\n      (add-hook 'dummy-h-mode-hook\n                (lambda ()\n                  (setq dummy-h-mode-default-major-mode 'c-mode)))\n      (add-hook 'dummy-h-mode-hook\n                (lambda ()\n                  (setq dummy-h-mode-search-limit 60000)))))\n#+END_SRC\n\n*** Extra highlight keywords for C/C++\n\nExtra hightlight for =stdint.h=\n\n#+BEGIN_SRC emacs-lisp\n  (dolist (m '(c-mode c++-mode))\n    (font-lock-add-keywords\n     m\n     '((\"\\\\\u003c\\\\(int8_t\\\\|int16_t\\\\|int32_t\\\\|int64_t\\\\|uint8_t\\\\|uint16_t\\\\|uint32_t\\\\|uint64_t\\\\)\\\\\u003e\" . font-lock-keyword-face))))\n#+END_SRC\n\n*** Syntax check and code-completion with CMake project    :cmake:\n\n[[https://github.com/redguardtoo/cpputils-cmake][cpputils-cmake]] is a nice tool for cmake project.\n\nGitHub: https://github.com/redguardtoo/cpputils-cmake\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cpputils-cmake\n    :require (flymake flycheck)\n    :config\n    (progn\n      (add-hook 'c-mode-common-hook\n                (lambda ()\n                  (when (derived-mode-p 'c-mode 'c++-mode)\n                    (cppcm-reload-all))))))\n#+END_SRC\n\n*** Emacs extension allowing quick switch between header and source file in C/C++\n\nThis extension allows to quickly switch between header and a source file with\nthe same name located in the directory tree or repository. It is an alternatife\nto =ff-find-other-file=.\n\nGitHub: https://github.com/fourier/cff\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cff\n    :config\n    (progn\n      (add-hook 'c++-mode-hook\n                '(lambda ()\n                   (define-key c-mode-base-map (kbd \"M-o\") 'cff-find-other-file)))\n      (add-hook 'c-mode-hook\n                '(lambda ()\n                   (define-key c-mode-base-map (kbd \"M-o\") 'cff-find-other-file)))))\n#+END_SRC\n\n*** C language coding style\n\nI always use =linux coding style= for c language by default.\n\n#+BEGIN_SRC emacs-lisp\n  (add-hook 'c-mode-hook\n            '(lambda ()\n               (c-set-style \"linux\")\n               (setq c-basic-offset 8)\n               ;; Make TAB equivilent to 8 spaces\n               (setq tab-width 8)))\n#+END_SRC\n\nAs part of Linux Kernel developer, I add =linux-kernel= coding style rule, which\nuse =tabs= as indent and follow linux kernel development rules. Use following\ncode to make emacs switch to =linux-kernel= style automatically when enter linux\nkernel directories.\n\nThis coding style is document in https://www.kernel.org/doc/Documentation/CodingStyle.\n\n#+BEGIN_SRC emacs-lisp\n  (defun c-lineup-arglist-tabs-only (ignored)\n    \"Line up argument lists by tabs, not spaces\"\n    (let* ((anchor (c-langelem-pos c-syntactic-element))\n           (column (c-langelem-2nd-pos c-syntactic-element))\n           (offset (- (1+ column) anchor))\n           (steps (floor offset c-basic-offset)))\n      (* (max steps 1)\n         c-basic-offset)))\n\n  ;; Add Linux kernel style\n  (add-hook 'c-mode-common-hook\n            (lambda ()\n              (c-add-style \"linux-kernel\"\n                           '(\"linux\" (c-offsets-alist\n                                      (arglist-cont-nonempty\n                                       c-lineup-gcc-asm-reg\n                                       c-lineup-arglist-tabs-only))))))\n\n  (defun linux-kernel-development-setup ()\n    (let ((filename (buffer-file-name)))\n      ;; Enable kernel mode for the appropriate files\n      (when (and filename\n                 (or (locate-dominating-file filename \"Kbuild\")\n                     (locate-dominating-file filename \"Kconfig\")\n                     (save-excursion (goto-char 0)\n                                     (search-forward-regexp \"^#include \u003clinux/\\\\(module\\\\|kernel\\\\)\\\\.h\u003e$\" nil t))))\n        ;; (setq indent-tabs-mode t)\n        ;; (setq show-trailing-whitespace t)\n        (c-set-style \"linux-kernel\")\n        (message \"Setting up indentation for the linux kernel\"))))\n\n  (add-hook 'c-mode-hook 'linux-kernel-development-setup)\n#+END_SRC\n\n*** C++ language coding style\n\nUse my C++ coding style.\n\n#+BEGIN_SRC emacs-lisp\n  (add-hook 'c++-mode-hook\n            '(lambda ()\n\n               ;; Use stroustrup style\n               (c-set-style \"stroustrup\")\n\n               ;; Setting indentation lvel\n               (setq c-basic-offset 4)\n\n               ;; Make TAB equivilent to 4 spaces\n               (setq tab-width 4)\n\n               ;; Use spaces to indent instead of tabs.\n               (setq indent-tabs-mode nil)\n\n               ;; Indent the continuation by 2\n               (setq c-continued-statement-offset 2)\n\n               ;; Brackets should be at same indentation level as the statements they open\n               ;; for example:\n               ;;                 if (0)        becomes        if (0)\n               ;;                     {                        {\n               ;;                        ;                         ;\n               ;;                     }                        }\n               (c-set-offset 'substatement-open 0)\n\n               ;; make open-braces after a case\n               (c-set-offset 'case-label '+)\n\n               ;; Not indent code inside a namespace\n               ;; for example:\n               ;;                namespace A {\n               ;;\n               ;;                int namespace_global_variable;\n               ;;\n               ;;                class Class {\n               ;;\n               ;;                Class();\n               ;;                //...\n               ;;                };\n               ;;\n               ;;                }\n               (c-set-offset 'innamespace 0)\n               ))\n#+END_SRC\n\n*** Setup keybindings                                          :keybinding:\n\n#+BEGIN_SRC emacs-lisp\n  ;; C\n  (add-hook\n   'c-mode-hook\n   '(lambda()\n      (define-key helm-map (kbd \"C-c C-o\") 'ff-find-other-file)))\n#+END_SRC\n\n#+BEGIN_SRC emacs-lisp\n  ;; C++\n  (add-hook\n   'c++-mode-hook\n   '(lambda()\n      (define-key helm-map (kbd \"C-c C-o\") 'ff-find-other-file)))\n#+END_SRC\n\n** CMake                                                             :c:cpp:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cmake-font-lock\n    :require (cmake-mode)\n    :init (add-hook 'cmake-mode-hook 'cmake-font-lock-activate))\n#+END_SRC\n\n** GLSL                                                               :glsl:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package glsl-mode\n    :mode ((\"\\\\.vs\\\\'\" . glsl-mode)\n           (\"\\\\.fs\\\\'\" . glsl-mode)\n           (\"\\\\.gs\\\\'\" . glsl-mode))\n    :config (setq glsl-other-file-alist '((\"\\\\.fs$\" (\".vs\"))\n                                          (\"\\\\.vs$\" (\".fs\")))))\n#+END_SRC\n\n** Go                                                               :golang:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package go-mode\n    :mode \"\\\\.go$\"\n    :config\n    (progn\n      ;; Use gofmt to format code before save\n      (add-hook 'before-save-hook 'gofmt-before-save)))\n#+END_SRC\n\n** Graphviz                                                       :graphviz:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package graphviz-dot-mode\n    :init (defalias 'dot-mode 'graphviz-dot-mode))\n#+END_SRC\n\n** Java                                                               :java:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package malabar-mode\n    :mode \"\\\\.java$\")\n\n  (req-package gradle-mode\n    :mode \"\\\\.gradle$\")\n#+END_SRC\n\n** javascript                                                   :javascript:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package js2-mode\n    :init (setq js2-highlight-level 3)\n    :mode \"\\\\.js$\")\n#+END_SRC\n\n*** Simplify importing JS modules\n\n=import-js= is a tool to automatically import dependencies in your JavaScript\nproject. Use it in Vim or Emacs by placing your cursor on a variable and hit\n=\u003cleader\u003ej (Vim)=, or =(M-x) import-js-import (Emacs)=.\n\nGitHub: https://github.com/trotzig/import-js\n\n#+BEGIN_SRC emacs-lisp\n  (req-package import-js)\n#+END_SRC\n\n** Json                                                    :javascript:json:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package json-reformat :commands json-reformat-region)\n\n  (req-package flymake-json :require flymake)\n\n  (req-package json-mode\n    :require flymake-json\n    :mode (\"\\\\.json$\" . json-mode)\n    :init (add-hook 'json-mode-hook (lambda () (flymake-json-load))))\n#+END_SRC\n\n** Markdown                                                       :markdown:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package markdown-mode\n    :mode \"\\\\.\\\\(md\\\\|markdown\\\\)\\\\'\")\n#+END_SRC\n\n** Python                                                           :python:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package jinja2-mode)\n#+END_SRC\n\n** QML                                                              :qml:qt:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package qml-mode\n    :init (add-to-list 'auto-mode-alist '(\"\\\\.qml$\" . qml-mode)))\n#+END_SRC\n\n** Ruby                                                               :ruby:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package ruby-mode\n    :mode ((\"Rakefile\\\\'\" . ruby-mode)\n           (\"\\\\.rake$\" . ruby-mode)\n           (\"\\\\.gemspec$\" . ruby-mode)\n           (\"\\\\.rb$'\" . ruby-mode)\n           (\"\\\\.ru$\" . ruby-mode)\n           (\"Gemfile$\" . ruby-mode)\n           (\"Guardfile$\" . ruby-mode))\n    :config\n    (progn\n      ;; We never want to edit Rubinius bytecode\n      (add-to-list 'completion-ignored-extensions \".rbc\")\n      ))\n#+END_SRC\n\n#+BEGIN_SRC emacs-lisp\n  (req-package rake)\n#+END_SRC\n** Rust                                                               :rust:\n\n[[https://github.com/rust-lang/rust-mode][rust-mode]] is a major emacs-mode for editing Rust source code.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package rust-mode\n    :mode \"\\\\.rs\\\\'\")\n#+END_SRC\n\n** scala                                                             :scala:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package scala-mode\n    :mode ((\"\\\\.scala$\" . scala-mode)))\n\n  (req-package sbt-mode\n    :mode ((\"\\\\.sbt$\" . sbt-mode)))\n#+END_SRC\n\n** SSH Config                                                          :ssh:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package ssh-config-mode\n    :mode ((\"\\\\.ssh/config\\\\'\"  . ssh-config-mode)\n           (\"sshd?_config\\\\'\"   . ssh-config-mode)\n           (\"known_hosts\\\\'\"    . ssh-known-hosts-mode)\n           (\"authorized_keys2?\\\\'\" . ssh-authorized-keys-mode))\n    :init (add-hook 'ssh-config-mode-hook 'turn-on-font-lock))\n#+END_SRC\n\n** XML                                                                 :xml:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package nxml-mode\n    :mode ((\"\\\\.pom$\" . nxml-mode))\n    :config\n    (progn\n      ;; Any file start with xml will be treat as nxml-mode\n      (add-to-list 'magic-mode-alist '(\"\u003c\\\\?xml\" . nxml-mode))\n\n      ;; Use nxml-mode instead of sgml, xml or html mode.\n      (mapc\n       (lambda (pair)\n         (if (or (eq (cdr pair) 'xml-mode)\n                 (eq (cdr pair) 'sgml-mode))\n             (setcdr pair 'nxml-mode)))\n       auto-mode-alist)\n      ))\n#+END_SRC\n\n** YAML                                                               :yaml:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package yaml-mode\n    :mode \"\\\\.yml$\")\n#+END_SRC\n\n* LISP Development                                                    :lisp:\n\nThough =LISP= has many dialet, it still is the best programming language I ever\nmet.\n\n** Emacs Lisp                                                        :elisp:\n\n*** Add eldoc support                                               :eldoc:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package eldoc\n    :init\n    (add-hook 'emacs-lisp-mode-hook\n              '(lambda ()\n                 ;; enable eldoc\n                 (turn-on-eldoc-mode)\n                 ;; fix for paredit if exist\n                 (eval-after-load 'paredit\n                   '(progn\n                      (eldoc-add-command 'paredit-backward-delete\n                                         'paredit-close-round))))))\n#+END_SRC\n\n*** Additional flavour to emacs-lisp programming                 :el@spice:\n\nel-spice is a minor mode that provides additional configuration to make\nprogramming in Emacs Lisp more enjoyable.\n\nGitHub: https://github.com/vedang/el-spice\n\n#+BEGIN_SRC emacs-lisp\n  (req-package el-spice)\n#+END_SRC\n\n*** On-the-fly evaluation/substitution of emacs lisp code         :litable:\n\n[[https://github.com/Fuco1/litable][litable]] keeps a list of pure functions as a safeguard for unwanted evaluations.\nA function must first be accepted into this list (using =M-x litable-accept-as-pure=)\nbefore it can be evaluated on-the-fly.\n\nYou should take care of what function you accept as pure to avoid any\nunfortunate accidents. Also, note that the pure functions list persists across\nsessions.\n\nGitHub: https://github.com/Fuco1/litable\n\n#+BEGIN_SRC emacs-lisp\n  (req-package litable :init (litable-mode))\n#+END_SRC\n\n*** Highlight defined symbols\n\n#+BEGIN_SRC emacs-lisp :tangle no\n  (req-package hl-defined\n    :config\n    (add-hook 'emacs-lisp-mode-hook 'hdefd-highlight-mode)\n    (add-hook 'lisp-interaction-mode-hook 'hdefd-highlight-mode))\n#+END_SRC\n\n*** Highlight functions or macros belone to cl.el\n\n#+BEGIN_SRC emacs-lisp\n  (req-package highlight-cl\n    :init\n    (add-hook 'emacs-lisp-mode-hook\n              '(lambda ()\n                 (highlight-cl-add-font-lock-keywords))))\n#+END_SRC\n\n*** Remove *.elc when save\n\n#+BEGIN_SRC emacs-lisp\n  (defun remove-elc-on-save ()\n    \"If you're saving an elisp file, likely the .elc is no longer valid.\"\n    (make-local-variable 'after-save-hook)\n    (add-hook 'after-save-hook\n              (lambda ()\n                (if (file-exists-p (concat buffer-file-name \"c\"))\n                    (delete-file (concat buffer-file-name \"c\"))))))\n\n  (add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)\n#+END_SRC\n\n** Clojure                                                         :clojure:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package clojure-mode\n    :require (clojure-mode-extra-font-locking flycheck-clojure)\n    :mode \"\\\\.\\\\(clj\\\\|boot\\\\|cljx\\\\|edn\\\\|cljs\\\\|cljs.hl\\\\)\\\\'\")\n#+END_SRC\n\n*** Add refactor function support\n\nhttps://github.com/clojure-emacs/clj-refactor.el\n\n#+BEGIN_SRC emacs-lisp\n  (req-package clj-refactor\n    :config\n    (progn\n      ;; Add clj-refactor to clojure-mode\n      (add-hook 'clojure-mode-hook '(lambda () (clj-refactor-mode 1)))\n      ;; Use `C-c C-x' as prefix\n      (cljr-add-keybindings-with-prefix \"C-c C-x\")))\n#+END_SRC\n\n*** Use cider for interactive development\n\n[[https://github.com/clojure-emacs/cider][cider]] is a Clojure Interactive Development Environment that Rocks for Emacs\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cider\n    :require (cider-decompile cider-eval-sexp-fu eldoc)\n    :config\n    (progn\n\n      ;; Enable eldoc in Clojure buffers\n      (eval-after-load 'eldoc\n        '(progn\n           (add-hook 'cider-mode-hook #'eldoc-mode)))\n\n      ;; Hide `*nrepl-connection*' and `*nrepl-server*' buffers from appearing\n      ;; in some buffer switching commands like switch-to-buffer\n      (setq nrepl-hide-special-buffers t)\n\n      ;; Enabling CamelCase support for editing commands(like forward-word,\n      ;; backward-word, etc) in the REPL is quite useful since we often have\n      ;; to deal with Java class and method names. The built-in Emacs minor\n      ;; mode subword-mode provides such functionality\n      (add-hook 'cider-repl-mode-hook #'subword-mode)\n\n      ;; The use of paredit when editing Clojure (or any other Lisp) code is\n      ;; highly recommended. You're probably using it already in your\n      ;; clojure-mode buffers (if you're not you probably should). You might\n      ;; also want to enable paredit in the REPL buffer as well.\n      ;; (add-hook 'cider-repl-mode-hook #'paredit-mode)\n\n      ;; Auto-select the error buffer when it's displayed:\n      (setq cider-auto-select-error-buffer t)\n\n      ;; Controls whether to pop to the REPL buffer on connect.\n      (setq cider-repl-pop-to-buffer-on-connect nil)\n\n      ;; Controls whether to auto-select the error popup buffer.\n      (setq cider-auto-select-error-buffer t)\n\n      ;; T to wrap history around when the end is reached.\n      (setq cider-repl-wrap-history t)\n\n      ;; Log protocol messages to the `nrepl-message-buffer-name' buffer.\n      (setq nrepl-log-messages t)\n\n      ;; Toggle between test and implementation, instead of showing test report buffer.\n      (eval-adter-load 'projectile\n                       (define-key cider-mode-map (kbd \"C-c C-t\") 'projectile-toggle-between-implementation-and-test))\n      ))\n#+END_SRC\n\n*** Insert libraries in project more easily\n\n[[https://github.com/AdamClements/latest-clojure-libraries][latest-clojure-libraries]] helps to looks up the latest version of clojure\nlibraries on clojars/maven and automatically populates the buffer with the\nappropriate dependency vector. Optionally uses pomegranate to load the\ndependency directly into your running nrepl.\n\nTo use this plugin, you need to edit your =~/.lein/profiles.clj= :plugins vector\nto include =[lein-ancient \"0.5.1\"]= and optionally add\n=[com.cemerick/pomegranate \"0.2.0\"]= to your :dependencies vector if you want\nthe feature which automatically adds the library to your classpath without\nrestarting the repl.\n\nAfter all step done, use =M-x latest-clojure-libraries-insert-dependency= to\ninsert latest clojure libraries to your project.\n\nGitHub: https://github.com/AdamClements/latest-clojure-libraries\n\n#+BEGIN_SRC emacs-lisp\n  (req-package latest-clojure-libraries)\n#+END_SRC\n\n* Web Development                                                       :web:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package web-mode\n    :mode ((\"\\\\.html?\\\\'\" . web-mode)\n           (\"\\\\.ejs?\\\\'\" . web-mode)))\n#+END_SRC\n\n** CSS                                                                 :css:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package css-mode :mode \"\\\\.css\\\\'\")\n#+END_SRC\n\n*** Add support for eldoc                                           :eldoc:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package css-eldoc\n    :config\n    (progn\n      (add-hook 'css-mode-hook 'turn-on-css-eldoc)\n      (add-hook 'scss-mode-hook 'turn-on-css-eldoc)\n      (add-hook 'less-css-mode-hook 'turn-on-css-eldoc)))\n#+END_SRC\n\n** Less                                                               :less:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package less-css-mode\n    :init (add-to-list 'auto-mode-alist '(\"\\\\.less$\" . less-css-mode))\n    :mode \"\\\\.less$\")\n#+END_SRC\n\n** SCSS                                                           :css:scss:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package scss-mode\n    :mode \"\\\\.scss\\\\'\"\n    :config\n    (progn\n      ;; dont' build scss to css after save file\n      (setq scss-compile-at-save nil)))\n#+END_SRC\n\n** mustache                                                       :mustache:\n\nSometimes we will use [[https://mustache.github.io/][mustache]] as template system, [[https://github.com/mustache/emacs][mustache-mode]] is a nice\nhelper.\n\nGitHub: https://github.com/mustache/emacs\n\n#+BEGIN_SRC emacs-lisp\n  (req-package mustache-mode :mode \"\\\\.mustache$\")\n#+END_SRC\n\n** Use emmet-mode to add Zen Coding support\n\n[[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\nfor Zen Coding by producing HTML from CSS-like selectors.\n\nGitHub: https://github.com/smihica/emmet-mode\n\n#+BEGIN_SRC emacs-lisp :tangle no\n  (req-package emmet-mode\n    :config\n    (progn\n      ;; Following mode support emmet-mode\n      (add-hook 'html-mode-hook 'emmet-mode)\n      (add-hook 'sgml-mode-hook 'emmet-mode)\n      (add-hook 'nxml-mode-hook 'emmet-mode)\n      (add-hook 'css-mode-hook  'emmet-mode)\n\n      ;; Move cursor between quotes after expand\n      (add-hook 'emmt-mode-hook\n                '(lambda()\n                   (setq emmet-move-cursor-between-quotes t)))\n\n      ;; Make tab can also expand emmt instead of use yasnippet directly\n      (define-key emmt-mode-keymap (kbd \"TAB\") 'emmt-expand-yas)\n      (define-key emmt-mode-keymap (kbd \"\u003ctab\u003e\") 'emmt-expand-yas)))\n#+END_SRC\n\n* Terminal Emulator                                                    :term:\n\n** Sane Term\n\nAnsi Term with sane options and the ability to cycle/create terms.\n\nGitHub: https://github.com/adamrt/sane-term\n\n#+BEGIN_SRC emacs-lisp\n  (req-package sane-term\n    :config\n    (progn\n      ;; shell to use for sane-term\n      (setq sane-term-shell-command \"/bin/bash\")\n      ;; sane-term will create first term if none exist\n      (setq sane-term-initial-create t)\n      ;; `C-d' or `exit' will kill the term buffer.\n      (setq sane-term-kill-on-exit t)\n      ;; After killing a term buffer, not cycle to another.\n      (setq sane-term-next-on-kill nil)))\n#+END_SRC\n\n** Eshell                                                           :eshell:\n\neshell is not really a system shell, it's written in pure lisp. What I\nlike is it fully integrated with emacs.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package eshell\n    :init\n    ;; move eshell cache dir to ~/.emacs.d/.cache\n    (setq eshell-directory-name (concat user-cache-directory \"eshell\")))\n#+END_SRC\n\n*** Use bash like prompt with color\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'eshell\n    '(progn\n       ;; Make eshell prompt look likes default bash prompt\n       (setq eshell-prompt-function\n             '(lambda ()\n                (concat\n                 user-login-name \"@\" system-name \" \"\n                 (if (search (directory-file-name (expand-file-name (getenv \"HOME\"))) (eshell/pwd))\n                     (replace-regexp-in-string (expand-file-name (getenv \"HOME\")) \"~\" (eshell/pwd))\n                   (eshell/pwd))\n                 (if (= (user-uid) 0) \" # \" \" $ \"))))\n       ;; Add color for eshell prompt like Gentoo does\n       (defun colorfy-eshell-prompt ()\n         (let* ((mpoint)\n                (user-string-regexp (concat \"^\" user-login-name \"@\" system-name)))\n           (save-excursion\n             (goto-char (point-min))\n             (while (re-search-forward (concat user-string-regexp \".*[$#]\") (point-max) t)\n               (setq mpoint (point))\n               (overlay-put (make-overlay (point-at-bol) mpoint) 'face '(:foreground \"dodger blue\")))\n             (goto-char (point-min))\n             (while (re-search-forward user-string-regexp (point-max) t)\n               (setq mpoint (point))\n               (overlay-put (make-overlay (point-at-bol) mpoint) 'face '(:foreground \"green3\"))))))\n       ;; Make eshell prompt more colorful\n       (add-hook 'eshell-output-filter-functions 'colorfy-eshell-prompt)))\n#+END_SRC\n\n*** Use ansi-term to render visual commands\n\n#+BEGIN_SRC emacs-lisp\n  (eval-after-load 'eshell\n    '(progn\n      (setq eshell-visual-commands\n            '(\"less\" \"tmux\" \"htop\" \"top\" \"bash\" \"zsh\" \"fish\" \"ssh\" \"tail\"))\n\n      (setq eshell-visual-subcommands\n            '((\"git\" \"log\" \"diff\" \"show\")))\n      ))\n#+END_SRC\n\n*** Support for multi-eshell instance\n\n#+BEGIN_SRC emacs-lisp\n  (req-package multi-eshell\n    :require eshell\n    :config\n    (progn\n      (setq multi-eshell-shell-function '(eshell))\n      (setq multi-eshell-name \"*eshell*\")))\n#+END_SRC\n\n*** Add autojump command\n\n[[http://www.emacswiki.org/emacs/EshellAutojump][Eshell Autojump]] is an [[https://github.com/joelthelion/autojump][autojump]] like command written in pure elisp,\nwhich add a =j= command to let you jump to folder you has been access.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package eshell-autojump :require eshell)\n#+END_SRC\n\n*** Eshell commands setup\n\n**** ..\n\n#+BEGIN_SRC emacs-lisp\n  (defun eshell/.. (\u0026optional level)\n    \"Go up LEVEL directories\"\n    (interactive)\n    (let ((level (or level 1)))\n      (eshell/cd (make-string (1+ level) ?.))\n      (eshell/ls)))\n#+END_SRC\n\n**** clear\n\n#+BEGIN_SRC emacs-lisp\n  (defun eshell/clear ()\n    \"Clears the shell buffer ala Unix's clear or DOS' cls\"\n    ;; the shell prompts are read-only, so clear that for the duration\n    (let ((inhibit-read-only t))\n      ;; simply delete the region\n      (delete-region (point-min) (point-max))))\n#+END_SRC\n\n**** emacs\n\n#+BEGIN_SRC emacs-lisp\n  (defun eshell/emacs (\u0026rest args)\n    \"Open a file in emacs. Some habits die hard.\"\n    (if (null args)\n        ;; If I just ran \"emacs\", I probably expect to be launching\n        ;; Emacs, which is rather silly since I'm already in Emacs.\n        ;; So just pretend to do what I ask.\n        (bury-buffer)\n      ;; We have to expand the file names or else naming a directory in an\n      ;; argument causes later arguments to be looked for in that directory,\n      ;; not the starting directory\n      (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))\n\n  (defalias 'eshell/e 'eshell/emacs)\n#+END_SRC\n\n**** unpack\n\n#+BEGIN_SRC emacs-lisp\n  (defun eshell/unpack (file)\n    (let ((command (some (lambda (x)\n                           (if (string-match-p (car x) file)\n                               (cadr x)))\n                         '((\".*\\.tar.bz2\" \"tar xjf\")\n                           (\".*\\.tar.gz\" \"tar xzf\")\n                           (\".*\\.bz2\" \"bunzip2\")\n                           (\".*\\.rar\" \"unrar x\")\n                           (\".*\\.gz\" \"gunzip\")\n                           (\".*\\.tar\" \"tar xf\")\n                           (\".*\\.tbz2\" \"tar xjf\")\n                           (\".*\\.tgz\" \"tar xzf\")\n                           (\".*\\.zip\" \"unzip\")\n                           (\".*\\.Z\" \"uncompress\")\n                           (\".*\" \"echo 'Could not unpack the file:'\")))))\n      (eshell-command-result (concat command \" \" file))))\n#+END_SRC\n\n* Window Management                                                  :window:\n\n** Maximized window after emac start\n\n#+BEGIN_SRC emacs-lisp\n  (modify-all-frames-parameters '((fullscreen . maximized)))\n#+END_SRC\n\n** winner-mode                                                      :winner:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package winner\n    :config\n    (progn\n      ;; I use my own keymap for winner-mode\n      (setq winner-dont-bind-my-keys t)\n      ;; Start winner-mode globally\n      (winner-mode t)))\n#+END_SRC\n\n* Version Control\n\n** Git                                                                 :git:\n\n*** Add suport for git configuration files\n\n\n#+BEGIN_SRC emacs-lisp\n  (req-package gitconfig-mode\n    :mode ((\"/\\\\.?git/?config\\\\'\" . gitconfig-mode)\n           (\"/\\\\.gitmodules\\\\'\" . gitconfig-mode)\n           (\"/_gitconfig\\\\'\" . gitconfig-mode))\n    :config\n    (add-hook 'gitconfig-mode-hook 'flyspell-mode))\n\n  (req-package gitignore-mode\n    :mode ((\"/\\\\.gitignore\\\\'\" . gitignore-mode)\n           (\"/\\\\.git/info/exclude\\\\'\" . gitignore-mode)\n           (\"/git/ignore\\\\'\" . gitignore-mode)))\n#+END_SRC\n\n*** Use git-wip to view your WIP commit\n\nhttps://github.com/itsjeyd/git-wip-timemachine\n\n#+BEGIN_SRC emacs-lisp\n  (req-package git-wip-timemachine)\n#+END_SRC\n\n*** Setup keybindings                                          :keybinding:\n\n#+BEGIN_SRC emacs-lisp :noweb yes :results silent\n  (add-hook\n   'magit-mode-hook\n   '(lambda()\n      (define-key magit-mode-map (kbd \"C-g\") 'magit-mode-quit-window)))\n#+END_SRC\n\n* Cedet                                                               :cedet:\n\n#+BEGIN_SRC emacs-lisp\n  (req-package cedet\n    :config\n    (progn\n      (setq ede-project-placeholder-cache-file (concat user-cache-directory \"ede-projects.el\"))\n      (setq semanticdb-default-save-directory (concat user-cache-directory \"semanticdb\"))\n      (setq srecode-map-save-file (concat user-cache-directory \"srecode-map.el\"))\n      ))\n#+END_SRC\n\n* Keybinding                                                     :keybinding:\n\nCreate my minor-mode to control all keybindings\n\n#+begin_src emacs-lisp\n  (defvar coldnew-editor-map (make-keymap))\n\n  (define-minor-mode coldnew-editor-mode\n    \"coldnew's editor minor mode.\"\n    :init-value t\n    :keymap coldnew-editor-map)\n\n  (define-globalized-minor-mode global-coldnew-editor-mode\n    coldnew-editor-mode (lambda ()\n                          (if (not (minibufferp (current-buffer)))\n                              (coldnew-editor-mode 1))))\n\n  ;; Gloabal enable\n  (global-coldnew-editor-mode t)\n#+end_src\n\n** Spacemacs Map\n\nspacemacs reserve the =SPC-o= for user setup theirs own keymap, I think I should add something here :(\n\n** Normal State\n\n#+BEGIN_SRC emacs-lisp\n  (evil-define-key 'normal coldnew-editor-map\n      (kbd \"C-x C-f\") 'helm-find-files\n      (kbd \"C-x C-q\") 'read-only-mode\n      (kbd \"C-x C-s\") 'save-buffer-always\n      (kbd \"C-x M-1\") 'deft-or-close\n      (kbd \"C-x M-2\") 'multi-eshell\n      (kbd \"C-x M-3\") 'mu4e\n      (kbd \"C-x M-4\") 'erc-start-or-switch\n      (kbd \"C-x vl\") 'magit-log\n      (kbd \"C-x vp\") 'magit-push\n      (kbd \"C-x vs\") 'magit-status\n      (kbd \"C-x b\") 'helm-buffers-list\n      (kbd \"M-[\") 'winner-undo\n      (kbd \"M-]\") 'winner-redo\n      (kbd \"M-x\") 'helm-M-x\n      (kbd \"M-s\") 'helm-occur\n      (kbd \"C-x C-o\") 'other-frame\n      (kbd \"M-o\") 'other-window\n      (kbd \"C--\") 'text-scale-decrease\n      (kbd \"C-=\") 'text-scale-increase\n      )\n#+END_SRC\n\n** Insert State\n\n#+BEGIN_SRC emacs-lisp\n  (evil-define-key 'insert coldnew-editor-map\n    (kbd \"\u003cdelete\u003e\") 'hungry-delete-backward\n    (kbd \"TAB\") 'yas/expand\n    (kbd \"C-;\") 'iedit-mode\n    (kbd \"C-d\") 'hungry-delete-forward\n    (kbd \"C-l\") 'hungry-delete-backward\n    (kbd \"C-n\") 'evil-next-line\n    (kbd \"M-z\")   'zzz-to-char\n    (kbd \"C-o\") 'evil-execute-in-normal-state\n    (kbd \"C-p\") 'evil-previous-line\n    (kbd \"C-w\") 'backward-kill-word\n    (kbd \"C-x C-f\") 'helm-find-files\n    (kbd \"C-x C-n\") 'company-complete\n    (kbd \"C-x C-q\") 'read-only-mode\n    (kbd \"C-x C-s\") 'save-buffer-always\n    (kbd \"C-x M-1\") 'deft-or-close\n    (kbd \"C-x M-2\") 'multi-eshell\n    (kbd \"C-x M-3\") 'mu4e\n    (kbd \"C-x M-4\") 'erc-start-or-switch\n    (kbd \"C-x vl\") 'magit-log\n    (kbd \"C-x vp\") 'magit-push\n    (kbd \"C-x vs\") 'magit-status\n    (kbd \"C-x b\") 'helm-buffers-list\n    (kbd \"M-\u003cSPC\u003e\") 'insert-U200B-char\n    (kbd \"M-[\") 'winner-undo\n    (kbd \"M-]\") 'winner-redo\n    (kbd \"M-s\") 'helm-occur\n    (kbd \"s-\u003cRET\u003e\") 'insert-empty-line\n    (kbd \"s-\u003cSPC\u003e\") 'insert-U200B-char\n    (kbd \"C-v\") 'set-mark-mode/rectangle-mark-mode\n    (kbd \"C-x C-i\") 'indent-region-or-buffer-and-cleanup\n    (kbd \"M-v\") 'er/expand-region\n    (kbd \"M-x\") 'helm-M-x\n    (kbd \"M-y\") 'helm-show-kill-ring\n    (kbd \"M-o\") 'other-window\n    (kbd \"C-x C-o\") 'other-frame\n    (kbd \"C--\") 'text-scale-decrease\n    (kbd \"C-x t\") 'sane-term\n    (kbd \"C-x T\") 'sane-term\n    )\n#+END_SRC\n\n** Ex Command\n\n#+BEGIN_SRC emacs-lisp\n  (evil-ex-define-cmd \"ag\" 'helm-ag)\n  (evil-ex-define-cmd \"agp[roject]\" 'helm-projectile-ag)\n  (evil-ex-define-cmd \"agi[nteractive]\" 'helm-do-ag)\n  (evil-ex-define-cmd \"google\" 'helm-google)\n  (evil-ex-define-cmd \"google-suggest\" 'helm-google-suggest)\n  (evil-ex-define-cmd \"gtag\" 'ggtags-create-tags)\n  (evil-ex-define-cmd \"howdoi\" 'howdoi-query)\n#+END_SRC\n\n* End of configuration\n\nOh YA!! We finish loading emacs configuration :)\n\nHowever, since we use =req-package= for loading and installing packages, be sure\nto execute following line to send =req-package= on its merry way.\n\n#+BEGIN_SRC emacs-lisp\n  (req-package-finish)\n#+END_SRC\n\nIn the end of configuration, I'll load my private config from =~/.personal.el=,\nwhich contains something like password or account settings.\n\n#+BEGIN_SRC emacs-lisp\n  (let ((secret \"~/.personal.el\"))\n    (when (file-exists-p secret) (load-file secret)))\n#+END_SRC\n\n* Reference\n\nFollowing link is refrence for my emac config.\n\n~[1]~ https://github.com/r0man/.emacs.d/blob/master/init.el.org\n\n~[2]~ https://github.com/bodil/emacs.d\n\n~[3]~ https://github.com/mgalgs/.emacs.d\n\n~[4]~ https://raw.githubusercontent.com/sbisaacson/literate-emacs/master/README.org\n\n~[5]~ https://github.com/jhenahan/emacs.d/blob/master/emacs-init.org\n\n~[6]~ https://ryuslash.org/dotfiles/emacs/init.html\n\n~[7]~ http://www.wisdomandwonder.com/wordpress/wp-content/uploads/2014/03/C3F.org_.txt\n\n~[8]~ https://github.com/howardabrams/dot-files\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2Fcoldnew-spacemacs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoldnew%2Fcoldnew-spacemacs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoldnew%2Fcoldnew-spacemacs/lists"}