+#+END_SRC
+
+* Key bindings
+
+** Remove prefix =ESC=, refer [[http://emacs.stackexchange.com/questions/14755/how-to-remove-bindings-to-the-esc-prefix-key][here]]
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ ;; (define-key key-translation-map (kbd "ESC") (kbd "C-g"))
+
+#+END_SRC
+
+** Esc on Minibuffer
+
+Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (define-key minibuffer-local-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-ns-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-isearch-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-completion-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-must-match-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-must-match-filename-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-filename-completion-map [escape] 'keyboard-escape-quit)
+ (define-key minibuffer-local-filename-must-match-map [escape] 'keyboard-escape-quit)
+
+ ;; Also map s-h same as C-g
+ (define-key minibuffer-local-map (kbd "s-h") 'keyboard-escape-quit)
+
+#+END_SRC
+
+** =Ctrl= key bindings
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ ;;
+
+ ;; C-h help
+ ;; C-j newline and indent
+ ;; C-k kill line
+ ;; C-l recenter-top-bottom
+ ;; (global-set-key (kbd "C-;") 'ido-switch-buffer)
+ ;; C-;
+ ;; C-'
+ ;; C-ret
+
+ ;; C-n next-line
+ ;; C-m
+ ;; C-,
+ ;; C-.
+ ;; C-/
+
+ ;; C-y
+ ;; C-u
+ ;; C-i
+ ;; C-o
+ ;; C-p
+ ;; C-[
+ ;; C-]
+ ;; C-\
+
+ ;; C-=
+ ;; C--
+ ;; C-0
+ ;; C-9
+ ;; C-8
+ ;; C-7
+
+ ;; C-Space
+
+
+
+
+
+
+
+#+END_SRC
+
+** =Super= bindings for file, buffer and windows
+
+Some global bindings on =Super=, on Mac, it is =Command=
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (global-set-key (kbd "s-h") 'keyboard-quit)
+ (global-set-key (kbd "s-j") 'ido-switch-buffer)
+ (global-set-key (kbd "s-k") 'ido-find-file)
+ ;; s-k --> kill-this-buffer
+ (global-set-key (kbd "s-l") (lambda ()
+ (interactive)
+ (if (> (length (window-list)) 1)
+ (delete-window)
+ (message "Only one Windows now!"))))
+ ;; s-l --> goto-line
+ (global-set-key (kbd "s-;") 'swiper)
+ ;; s-; -->
+ ;; s-' --> 'next-multiframe-window
+ (global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
+
+ ;; (global-set-key (kbd "s-y") 'projectile-find-file)
+ (global-set-key (kbd "s-f") 'projectile-find-file)
+ (global-set-key (kbd "s-[") 'persp-next)
+ (global-set-key (kbd "s-]") 'persp-prev)
+
+ (global-set-key (kbd "s-`") 'mode-line-other-buffer)
+
+ (global-set-key (kbd "s-n") 'persp-next)
+ (global-set-key (kbd "s-p") 'persp-prev)
+
+
+
+ ;; someothers default mapping on super (command) key
+ ;; s-s save-buffer
+ ;; s-k kill-this-buffer
+
+
+ ;; s-h --> ns-do-hide-emacs
+ ;; s-j --> ido-switch-buffer +
+ ;; s-k --> kill-this-buffer
+ ;; s-l --> goto-line
+ ;; s-; --> undefined
+ ;; s-' --> next-multiframe-window
+ ;; s-ret --> toggle-frame-fullscreen +
+
+ ;; s-y --> ns-paste-secondary
+ ;; s-u --> revert-buffer
+ ;; s-i --> undefined - but used for iterm globally
+ ;; s-o --> used for emacs globally
+ ;; s-p --> projectile-persp-switch-project +
+ ;; s-[ --> next-buffer +
+ ;; s-] --> previous-buffer +
+
+ ;; s-0 --> undefined
+ ;; s-9 --> undefined
+ ;; s-8 --> undefined
+ ;; s-7 --> undefined
+ ;; s-6 --> undefined
+ ;; s-- --> center-line
+ ;; s-= --> undefined
+
+ ;; s-n --> make-frame
+ ;; s-m --> iconify-frame
+ ;; s-b --> undefined
+ ;; s-, --> customize
+ ;; s-. --> undefined
+ ;; s-/ --> undefined
+
+ ;; s-g --> isearch-repeat-forward
+ ;; s-f --> projectile-find-file +
+ ;; s-d --> isearch-repeat-background
+ ;; s-s --> save-buffer
+ ;; s-a --> make-whole-buffer
+
+ ;; s-b --> undefined
+ ;; s-v --> yank
+ ;; s-c --> ns-copy-including-secondary
+
+ ;; s-t --> ns-popup-font-panel
+ ;; s-r --> undefined
+ ;; s-e --> isearch-yanqk-kill
+ ;; s-w --> delete-frame
+ ;; s-q --> same-buffers-kill-emacs
+
+ ;; s-` --> other-frame
+#+END_SRC
+
+** =M-s= bindings for searching
+
+I use the prefix =M-s= for searching in buffers
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (defun pl-make-keymap (key bindings)
+ (setq keymap (make-sparse-keymap))
+ (dolist (binding bindings)
+ (define-key keymap (car binding) (cdr binding)))
+ (global-set-key key keymap))
+
+ (define-key minibuffer-local-map "\M-s" nil)
+
+ (global-set-key (kbd "M-s s") 'isearch-forward-regexp)
+ (define-key isearch-mode-map "\M-s" 'isearch-repeat-forward)
+ (global-set-key (kbd "M-s r") 'isearch-backward-regexp)
+ (define-key isearch-mode-map "\M-r" 'isearch-repeat-backward)
+
+ (global-set-key (kbd "s-/") 'isearch-forward-regexp)
+ (define-key isearch-mode-map (kbd "s-/") 'isearch-repeat-forward)
+ (define-key isearch-mode-map (kbd "C-n") 'isearch-repeat-forward)
+
+
+ (set-face-background 'ido-first-match "white")
+
+ ;; M-s o --> occur
+ ;; M-s s --> isearch-forward-regexp
+ ;; M-s r --> isearch-backward-regexp
+ ;; M-s w --> isearch-forward-word
+ ;; M-s . --> isearch-forward-symbol-at-point
+ ;; M-s _ --> isearch-forward-symbol
+
+ ;; highlight bindings
+ ;; M-s h . --> highlight-symbol-at-point
+ ;; M-s h r --> highlight-regexp
+ ;; M-s h u --> unhighlight-regexp
+ ;; M-s h l --> highlight-lines-match-regexp
+ ;; M-s h p --> highlight-phrase
+ ;; M-s h f --> hi-lock-find-patterns
+
+ ;;
+ ;; (global-set-key (kbd "M-s M-r") 'isearch-backward-regexp)
+ ;;
+
+ ;; M-c
+ ;; M-r
+ ;; M-t
+ ;; M-u,
+#+END_SRC
+
+Occur search key bindings
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (define-key occur-mode-map (kbd "C-n")
+ (lambda ()
+ (interactive)
+ (occur-next)
+ (occur-mode-goto-occurrence-other-window)
+ (recenter)
+ (other-window 1)))
+
+ (define-key occur-mode-map (kbd "C-p")
+ (lambda ()
+ (interactive)
+ (occur-prev)
+ (occur-mode-goto-occurrence-other-window)
+ (recenter)
+ (other-window 1)))
+
+#+END_SRC
+
+
+** =M-o= as prefix key for windows
+
+** =M-g= as prefix key for launcher
+
+** others
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+
+ ;; C-' undefined
+ ;; C-. undefined
+#+END_SRC
+
+* Eshell
+
+Eshell alias
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (defalias 'e 'ido-find-file)
+ (defalias 'ff 'ido-find-file)
+ (defalias 'ee 'ido-find-file-other-window)
+
+#+END_SRC
+
+Quickly start eshll in split window below, refer [[http://www.howardism.org/Technical/Emacs/eshell-fun.html][eshell-here]]
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (defun eshell-x ()
+ (insert "exit")
+ (eshell-send-input)
+ (delete-window))
+
+ (defun eshell-here ()
+ "Opens up a new shell in the directory associated with the
+ current buffer's file. The eshell is renamed to match that
+ directory to make multiple eshell windows easier."
+ (interactive)
+ (let* ((parent (if (buffer-file-name)
+ (file-name-directory (buffer-file-name))
+ default-directory))
+ (height (/ (window-total-height) 3))
+ (name (car (last (split-string parent "/" t))))
+ (eshell-name (concat "*eshell: " name "*")))
+ (split-window-vertically (- height))
+ (other-window 1)
+ (if (get-buffer eshell-name)
+ (progn
+ (message "buffer exist")
+ (switch-to-buffer eshell-name))
+ (progn
+ (eshell "new")
+ (rename-buffer eshell-name)
+
+ (insert (concat "ls"))
+ (eshell-send-input)))))
+
+ ;; (global-set-key (kbd "M-`") (lambda ()
+ ;; (interactive)
+ ;; (if (buffer-name))))
+
+#+END_SRC
+
+* Misc Settings