emacs - re-order head, move ido key-bindings before org-mode magit setting
authorPeng Li <seudut@gmail.com>
Sat, 2 Jul 2016 16:48:34 +0000 (00:48 +0800)
committerPeng Li <seudut@gmail.com>
Sat, 2 Jul 2016 16:48:34 +0000 (00:48 +0800)
emacs.d/config.org

index af91237..97ca5d2 100644 (file)
@@ -469,720 +469,720 @@ set height in mode line
 
 #+END_SRC
 
-* Org-mode Settings
-
-** Org-mode Basic setting
+* IDO & SMEX
 
-Always indents header, and hide header leading starts so that no need type =#+STATUP: indent= 
+** IDO
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package org
+  (use-package ido
     :ensure t
-    :init
-    (setq org-startup-indented t)
-    (setq org-hide-leading-starts t)
-    (setq org-src-fontify-natively t)
-    (setq org-src-tab-acts-natively t)
-    (setq org-confirm-babel-evaluate nil)
-    (setq org-use-speed-commands t)
-    (setq org-completion-use-ido t))
-
-  (org-babel-do-load-languages
-   'org-babel-load-languages
-   '((python . t)
-     (C . t)
-     (perl . t)
-     (calc . t)
-     (latex . t)
-     (java . t)
-     (ruby . t)
-     (lisp . t)
-     (scheme . t)
-     (sh . t)
-     (sqlite . t)
-     (js . t)))
+    :init (setq ido-enable-flex-matching t
+                ido-ignore-extensions t
+                ido-use-virtual-buffers t
+                ido-everywhere t)
+    :config
+    (ido-mode 1)
+    (ido-everywhere 1)
+    (add-to-list 'completion-ignored-extensions ".pyc"))
 
-  ;; use current window for org source buffer editting
-  (setq org-src-window-setup 'current-window )
+  (icomplete-mode t)
 
 #+END_SRC
 
-** Org-bullets
-
-use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 charactes
+** FLX
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (use-package org-bullets
+
+  (use-package flx-ido
     :ensure t
-    :init
-    (add-hook 'org-mode-hook
-              (lambda ()
-                (org-bullets-mode t))))
+    :init (setq ido-enable-flex-matching t
+                ido-use-faces nil)
+    :config (flx-ido-mode 1))
 
-  (setq org-bullets-bullet-list '("⦿" "✪" "◉" "○" "►" "◆"))
 #+END_SRC
 
-** Worf Mode
-
-[[https://github.com/abo-abo/worf][worf]] mode is an extension of vi-like binding for org-mode. 
-In =worf-mode=, it is mapping =[=, =]= as =worf-backward= and =worf-forward= in global, wich
-cause we cannot input =[= and =]=, so here I unset this mappings. And redifined this two to
-=M-[= and =M-]=. see this [[https://github.com/abo-abo/worf/issues/19#issuecomment-223756599][issue]]
+** IDO-vertically
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package worf
+  (use-package ido-vertical-mode
     :ensure t
-    :commands worf-mode
-    :init (add-hook 'org-mode-hook 'worf-mode)
-    ;; :config
-    ;; (define-key worf-mode-map "[" nil)
-    ;; (define-key worf-mode-map "]" nil)
-    ;; (define-key worf-mode-map (kbd "M-[") 'worf-backward)
-    ;; (define-key worf-mode-map (kbd "M-]") 'worf-forward)
-    )
+    :init
+    (setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
+    :config
+    (ido-vertical-mode 1))
 
 #+END_SRC
 
-** Get Things Done
+** SMEX
 
-Refer to [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
-*** basic setup
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-standard key binding
+  (use-package smex
+    :ensure t
+    :init (smex-initialize)
+    :bind
+    ("M-x" . smex)
+    ("M-X" . smex-major-mode-commands))
 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (global-set-key "\C-cl" 'org-store-link)
-  (global-set-key "\C-ca" 'org-agenda)
-  (global-set-key "\C-cb" 'org-iswitchb)
 #+END_SRC
 
-*** Plain List 
+** Ido-ubiquitous
 
-Replace the list bullet =-=, =+=,  with =•=, a litter change based [[https://github.com/howardabrams/dot-files/blob/master/emacs-org.org][here]]
+Use [[https://github.com/DarwinAwardWinner/ido-ubiquitous][ido-ubiquitous]] for ido everywhere. It makes =describe-function= can also use ido
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;; (use-package org-mode
-  ;;   :init
-  ;;   (font-lock-add-keywords 'org-mode
-  ;;    '(("^ *\\([-+]\\) "
-  ;;           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))))
+
+  (use-package ido-ubiquitous
+    :ensure t
+    :init
+    (setq magit-completing-read-function 'magit-ido-completing-read)
+    (setq gnus-completing-read-function 'gnus-ido-completing-read)
+    :config
+    (ido-ubiquitous-mode 1))
+
 #+END_SRC
-*** Todo Keywords
 
-refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][fancy todo states]], 
+** Ido-exit-target
 
-To track TODO state changes, the =!= is to insert a timetamp, =@= is to insert a note with
-timestamp for the state change.
+[[https://github.com/waymondo/ido-exit-target][ido-exit-target]] let you open file/buffer on =other-windows= when call =ido-switch-buffer=
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-    ;; (setq org-todo-keywords
-    ;;        '((sequence "☛ TODO(t)" "|" "✔ DONE(d)")
-    ;;          (sequence "⚑ WAITING(w)" "|")
-    ;;          (sequence "|" "✘ CANCELLED(c)")))
-  ; (setq org-todo-keyword-faces
-  ;        (quote ("TODO" .  (:foreground "red" :weight bold))
-  ;               ("NEXT" .  (:foreground "blue" :weight bold))
-  ;               ("WAITING" . (:foreground "forest green" :weight bold))
-  ;               ("DONE" .  (:foreground "magenta" :weight bold))
-  ;               ("CANCELLED" . (:foreground "forest green" :weight bold))))
-
 
-  (setq org-todo-keywords
-        (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
-                ;; (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")
-                (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" ))))
+  (use-package ido-exit-target
+    :ensure t
+    :init
+    (define-key ido-common-completion-map (kbd "C-j") #'ido-exit-target-split-window-right)
+    (define-key ido-common-completion-map (kbd "C-l") #'ido-exit-target-split-window-below))
 
-  (setq org-todo-keyword-faces
-        (quote (("TODO" :foreground "red" :weight bold)
-                ("NEXT" :foreground "blue" :weight bold)
-                ("DONE" :foreground "forest green" :weight bold)
-                ("WAITING" :foreground "orange" :weight bold)
-                ("HOLD" :foreground "magenta" :weight bold)
-                ("CANCELLED" :foreground "forest green" :weight bold)
-                ;; ("MEETING" :foreground "forest green" :weight bold)
-                ;; ("PHONE" :foreground "forest green" :weight bold)
-                )))
 #+END_SRC
 
-Fast todo selections
+* 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
-  (setq org-use-fast-todo-selection t)
-  (setq org-treat-S-cursor-todo-selection-as-state-change nil)
+
+  ;; (define-key key-translation-map (kbd "ESC") (kbd "C-g"))
+
 #+END_SRC
 
-TODO state triggers and tags, [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
+** Esc on Minibuffer
 
-- Moving a task to =CANCELLED=, adds a =CANCELLED= tag
-- Moving a task to =WAITING=, adds a =WAITING= tag
-- Moving a task to =HOLD=, add =HOLD= tags
-- Moving a task to =DONE=, remove =WAITING=, =HOLD= tag
-- Moving a task to =NEXT=, remove all waiting/hold/cancelled tags
+Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
 
-This tags are used to filter tasks in agenda views
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (setq org-todo-state-tags-triggers
-        (quote (("CANCELLED" ("CANCELLED" . t))
-                ("WAITING" ("WAITING" . t))
-                ("HOLD" ("WAITING") ("HOLD" . t))
-                (done ("WAITING") ("HOLD"))
-                ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
-                ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
-                ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
-#+END_SRC
 
-Logging Stuff 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;; log time when task done
-  ;; (setq org-log-done (quote time))
-  ;; save clocking into to LOGBOOK
-  (setq org-clock-into-drawer t)
-  ;; save state change notes and time stamp into LOGBOOK drawer
-  (setq org-log-into-drawer t)
-  (setq org-clock-into-drawer "CLOCK")
+  (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
 
-*** Tags
+** =Ctrl= key bindings
+
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (setq org-tag-alist (quote ((:startgroup)
-                              ("@office" . ?e)
-                              ("@home" . ?h)
-                              (:endgroup)
-                              ("WAITING" . ?w)
-                              ("HOLD" . ?h)
-                              ("CANCELLED" . ?c))))
+  ;;
 
-  ;; Allow setting single tags without the menu
-  (setq org-fast-tag-selection-single-key (quote expert))
-#+END_SRC
+  ;; 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  
 
-*** Capture - Refile - Archive
+  ;; C-n    next-line
+  ;; C-m
+  ;; C-,
+  ;; C-.
+  ;; C-/
 
-Capture lets you quickly store notes with little interruption of your work flow.
+  ;; C-y
+  ;; C-u
+  ;; C-i
+  ;; C-o
+  ;; C-p
+  ;; C-[
+  ;; C-]
+  ;; C-\
 
-**** Capture Templates
+  ;; C-=
+  ;; C--
+  ;; C-0
+  ;; C-9
+  ;; C-8
+  ;; C-7
 
-When a new taks needs to be added, categorize it as 
+  ;; C-Space
 
-All captured file which need next actions are stored in =refile.org=, 
-- A new task / note (t) =refile.org=
-- A work task in office =office.org=
-- A jourenl =diary.org=
-- A new habit (h) =refile.org=
 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (setq org-directory "~/org")
-  (setq org-default-notes-file "~/org/refile.org")
-  (setq sd/org-diary-file "~/org/diary.org")
 
-  (global-set-key (kbd "C-c c") 'org-capture)
 
-  (setq org-capture-templates
-        (quote (("t" "Todo" entry (file org-default-notes-file)
-                 "* TODO %?\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
-                ("n" "Note" entry (file org-default-notes-file)
-                 "* %? :NOTE:\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
-                ("j" "Journal" entry (file+datetree sd/org-diary-file)
-                 "* %?\n:LOGBOOK:\n:END:" :clock-in t :clock-resume t)
-                ("h" "Habit" entry (file org-default-notes-file)
-                 "* NEXT %?\n:LOGBOOK:\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:END:\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n "))))
-#+END_SRC
 
-**** Refiling Tasks
-
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (setq org-refile-targets (quote (;; (nil :maxlevel . 9)
-                                   (org-agenda-files :maxlevel . 9))))
 
-  (setq org-refile-use-outline-path t)
 
-  (setq org-refile-allow-creating-parent-nodes (quote confirm))
 #+END_SRC
 
-*** Agenda Setup
-Setting agenda files and the agenda view
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (setq org-agenda-files (quote ("~/org/gtd.org"
-                                 "~/org/work.org")))
-
-  ;; only show today's tasks in agenda view
-  (setq org-agenda-span 'day)
-  ;; Use current windows for agenda view
-  (setq org-agenda-window-setup 'current-window)
-
-  ;; show all feature entries for repeating tasks,
-  ;; this is already setting by default
-  (setq org-agenda-repeating-timestamp-show-all t)
-
-  ;; Show all agenda dates - even if they are empty
-  (setq org-agenda-show-all-dates t)
-#+END_SRC
+** =Super= bindings for file, buffer and windows
 
-** Export PDF
+Some global bindings on =Super=, on Mac, it is =Command=
 
-Install MacTex-basic and some tex packages
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-#+BEGIN_SRC bash 
+  (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)
 
-  sudo tlmgr update --self
+  ;; (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)
 
-  sudo tlmgr install titlesec framed threeparttable wrapfig multirow enumitem bbding titling tabu mdframed tcolorbox textpos import varwidth needspace tocloft ntheorem environ trimspaces collection-fontsrecommended capt-of
+  (global-set-key (kbd "s-`") 'mode-line-other-buffer)
 
-#+END_SRC
+  (global-set-key (kbd "s-n") 'persp-next)
+  (global-set-key (kbd "s-p") 'persp-prev)
 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;; ;; allow for export=>beamer by placing
 
-  ;; http://emacs-fu.blogspot.com/2011/04/nice-looking-pdfs-with-org-mode-and.html
-  ;; #+LaTeX_CLASS: beamer in org files
-  (unless (boundp 'org-export-latex-classes)
-    (setq org-export-latex-classes nil))
-  (add-to-list 'org-export-latex-classes
-    ;; beamer class, for presentations
-    '("beamer"
-       "\\documentclass[11pt]{beamer}\n
-        \\mode<{{{beamermode}}}>\n
-        \\usetheme{{{{beamertheme}}}}\n
-        \\usecolortheme{{{{beamercolortheme}}}}\n
-        \\beamertemplateballitem\n
-        \\setbeameroption{show notes}
-        \\usepackage[utf8]{inputenc}\n
-        \\usepackage[T1]{fontenc}\n
-        \\usepackage{hyperref}\n
-        \\usepackage{color}
-        \\usepackage{listings}
-        \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
-    frame=single,
-    basicstyle=\\small,
-    showspaces=false,showstringspaces=false,
-    showtabs=false,
-    keywordstyle=\\color{blue}\\bfseries,
-    commentstyle=\\color{red},
-    }\n
-        \\usepackage{verbatim}\n
-        \\institute{{{{beamerinstitute}}}}\n          
-         \\subject{{{{beamersubject}}}}\n"
 
-       ("\\section{%s}" . "\\section*{%s}")
-       ("\\begin{frame}[fragile]\\frametitle{%s}"
-         "\\end{frame}"
-         "\\begin{frame}[fragile]\\frametitle{%s}"
-         "\\end{frame}")))
+  ;; someothers default mapping on super (command) key
+  ;; s-s save-buffer
+  ;; s-k kill-this-buffer
 
-    ;; letter class, for formal letters
 
-    (add-to-list 'org-export-latex-classes
+  ;; 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 +
 
-    '("letter"
-       "\\documentclass[11pt]{letter}\n
-        \\usepackage[utf8]{inputenc}\n
-        \\usepackage[T1]{fontenc}\n
-        \\usepackage{color}"
-       ("\\section{%s}" . "\\section*{%s}")
-       ("\\subsection{%s}" . "\\subsection*{%s}")
-       ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
-       ("\\paragraph{%s}" . "\\paragraph*{%s}")
-       ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
+  ;; 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
 
-  (require 'ox-md)
-  (require 'ox-beamer)
+  ;; s-n  -->  make-frame
+  ;; s-m  -->  iconify-frame
+  ;; s-b  -->  undefined
+  ;; s-,  -->  customize
+  ;; s-.  -->  undefined
+  ;; s-/  -->  undefined
 
-  (setq org-latex-pdf-process
-        '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
-          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
-          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
+  ;; s-g  -->  isearch-repeat-forward
+  ;; s-f  -->  projectile-find-file   +
+  ;; s-d  -->  isearch-repeat-background
+  ;; s-s  -->  save-buffer
+  ;; s-a  -->  make-whole-buffer
 
-  (setq TeX-parse-self t)
+  ;; s-b  -->  undefined
+  ;; s-v  -->  yank
+  ;; s-c  -->  ns-copy-including-secondary
 
-  (setq TeX-PDF-mode t)
-  (add-hook 'LaTeX-mode-hook
-            (lambda ()
-              (LaTeX-math-mode)
-              (setq TeX-master t)))
+  ;; 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
 
-** others
+** =M-s= bindings for searching
 
-extend org-mode's easy templates, refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][Extend org-modes' esay templates]]
+I use the prefix =M-s= for searching in buffers
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (add-to-list 'org-structure-template-alist
-               '("E" "#+BEGIN_SRC emacs-lisp :tangle yes :results silent\n?\n#+END_SRC"))
-  (add-to-list 'org-structure-template-alist
-               '("S" "#+BEGIN_SRC sh\n?\n#+END_SRC"))
-  (add-to-list 'org-structure-template-alist
-               '("p" "#+BEGIN_SRC plantuml :file uml.png \n?\n#+END_SRC"))
+  (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))
 
-#+END_SRC
+  (define-key minibuffer-local-map "\M-s" nil)
 
-* Magit
-[[https://github.com/magit/magit][Magit]] is a very cool git interface on Emacs.
-and Defined keys, using vi keybindings, Refer abo-abo's setting [[https://github.com/abo-abo/oremacs/blob/c5cafdcebc88afe9e73cc8bd40c49b70675509c7/modes/ora-nextmagit.el][here]]
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (use-package magit
-    :ensure t
-    :commands magit-status magit-blame
-    :config
-    (dolist (map (list magit-status-mode-map
-                       magit-log-mode-map
-                       magit-diff-mode-map
-                       magit-staged-section-map))
-      (define-key map "j" 'magit-section-forward)
-      (define-key map "k" 'magit-section-backward)
-      (define-key map "D" 'magit-discard-file)
-      (define-key map "n" nil)
-      (define-key map "p" nil)
-      (define-key map "v" 'recenter-top-bottom)
-      (define-key map "i" 'magit-section-toggle)))
-#+END_SRC
+  (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)
 
-* IDO & SMEX
+  (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)
 
-** IDO
 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (set-face-background 'ido-first-match "white")
 
-  (use-package ido
-    :ensure t
-    :init (setq ido-enable-flex-matching t
-                ido-ignore-extensions t
-                ido-use-virtual-buffers t
-                ido-everywhere t)
-    :config
-    (ido-mode 1)
-    (ido-everywhere 1)
-    (add-to-list 'completion-ignored-extensions ".pyc"))
+  ;; 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
 
-  (icomplete-mode t)
+  ;; 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
 
-** FLX
+Occur search key bindings
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package flx-ido
-    :ensure t
-    :init (setq ido-enable-flex-matching t
-                ido-use-faces nil)
-    :config (flx-ido-mode 1))
+  (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
 
-** IDO-vertically
+
+** =M-o= as prefix key for windows
+
+** =M-g= as prefix key for launcher
+
+** others
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package ido-vertical-mode
-    :ensure t
-    :init
-    (setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
-    :config
-    (ido-vertical-mode 1))
 
+  ;; C-'    undefined
+  ;; C-.    undefined
 #+END_SRC
 
-** SMEX
+* Org-mode Settings
+
+** Org-mode Basic setting
+
+Always indents header, and hide header leading starts so that no need type =#+STATUP: indent= 
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package smex
+  (use-package org
     :ensure t
-    :init (smex-initialize)
-    :bind
-    ("M-x" . smex)
-    ("M-X" . smex-major-mode-commands))
+    :init
+    (setq org-startup-indented t)
+    (setq org-hide-leading-starts t)
+    (setq org-src-fontify-natively t)
+    (setq org-src-tab-acts-natively t)
+    (setq org-confirm-babel-evaluate nil)
+    (setq org-use-speed-commands t)
+    (setq org-completion-use-ido t))
+
+  (org-babel-do-load-languages
+   'org-babel-load-languages
+   '((python . t)
+     (C . t)
+     (perl . t)
+     (calc . t)
+     (latex . t)
+     (java . t)
+     (ruby . t)
+     (lisp . t)
+     (scheme . t)
+     (sh . t)
+     (sqlite . t)
+     (js . t)))
+
+  ;; use current window for org source buffer editting
+  (setq org-src-window-setup 'current-window )
 
 #+END_SRC
 
-** Ido-ubiquitous
+** Org-bullets
 
-Use [[https://github.com/DarwinAwardWinner/ido-ubiquitous][ido-ubiquitous]] for ido everywhere. It makes =describe-function= can also use ido
+use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 charactes
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
-  (use-package ido-ubiquitous
+  (use-package org-bullets
     :ensure t
     :init
-    (setq magit-completing-read-function 'magit-ido-completing-read)
-    (setq gnus-completing-read-function 'gnus-ido-completing-read)
-    :config
-    (ido-ubiquitous-mode 1))
+    (add-hook 'org-mode-hook
+              (lambda ()
+                (org-bullets-mode t))))
 
+  (setq org-bullets-bullet-list '("⦿" "✪" "◉" "○" "►" "◆"))
 #+END_SRC
 
-** Ido-exit-target
+** Worf Mode
 
-[[https://github.com/waymondo/ido-exit-target][ido-exit-target]] let you open file/buffer on =other-windows= when call =ido-switch-buffer=
+[[https://github.com/abo-abo/worf][worf]] mode is an extension of vi-like binding for org-mode. 
+In =worf-mode=, it is mapping =[=, =]= as =worf-backward= and =worf-forward= in global, wich
+cause we cannot input =[= and =]=, so here I unset this mappings. And redifined this two to
+=M-[= and =M-]=. see this [[https://github.com/abo-abo/worf/issues/19#issuecomment-223756599][issue]]
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (use-package ido-exit-target
+  (use-package worf
     :ensure t
-    :init
-    (define-key ido-common-completion-map (kbd "C-j") #'ido-exit-target-split-window-right)
-    (define-key ido-common-completion-map (kbd "C-l") #'ido-exit-target-split-window-below))
+    :commands worf-mode
+    :init (add-hook 'org-mode-hook 'worf-mode)
+    ;; :config
+    ;; (define-key worf-mode-map "[" nil)
+    ;; (define-key worf-mode-map "]" nil)
+    ;; (define-key worf-mode-map (kbd "M-[") 'worf-backward)
+    ;; (define-key worf-mode-map (kbd "M-]") 'worf-forward)
+    )
 
 #+END_SRC
 
-* Key bindings
+** Get Things Done
 
-** Remove prefix =ESC=, refer [[http://emacs.stackexchange.com/questions/14755/how-to-remove-bindings-to-the-esc-prefix-key][here]]
+Refer to [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
+*** basic setup
+
+standard key binding
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (global-set-key "\C-cl" 'org-store-link)
+  (global-set-key "\C-ca" 'org-agenda)
+  (global-set-key "\C-cb" 'org-iswitchb)
+#+END_SRC
 
-  ;; (define-key key-translation-map (kbd "ESC") (kbd "C-g"))
+*** Plain List 
 
+Replace the list bullet =-=, =+=,  with =•=, a litter change based [[https://github.com/howardabrams/dot-files/blob/master/emacs-org.org][here]]
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  ;; (use-package org-mode
+  ;;   :init
+  ;;   (font-lock-add-keywords 'org-mode
+  ;;    '(("^ *\\([-+]\\) "
+  ;;           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))))
 #+END_SRC
+*** Todo Keywords
 
-** Esc on Minibuffer
+refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][fancy todo states]], 
 
-Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
+To track TODO state changes, the =!= is to insert a timetamp, =@= is to insert a note with
+timestamp for the state change.
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
+    ;; (setq org-todo-keywords
+    ;;        '((sequence "☛ TODO(t)" "|" "✔ DONE(d)")
+    ;;          (sequence "⚑ WAITING(w)" "|")
+    ;;          (sequence "|" "✘ CANCELLED(c)")))
+  ; (setq org-todo-keyword-faces
+  ;        (quote ("TODO" .  (:foreground "red" :weight bold))
+  ;               ("NEXT" .  (:foreground "blue" :weight bold))
+  ;               ("WAITING" . (:foreground "forest green" :weight bold))
+  ;               ("DONE" .  (:foreground "magenta" :weight bold))
+  ;               ("CANCELLED" . (:foreground "forest green" :weight bold))))
 
-  (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)
+  (setq org-todo-keywords
+        (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
+                ;; (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")
+                (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" ))))
 
+  (setq org-todo-keyword-faces
+        (quote (("TODO" :foreground "red" :weight bold)
+                ("NEXT" :foreground "blue" :weight bold)
+                ("DONE" :foreground "forest green" :weight bold)
+                ("WAITING" :foreground "orange" :weight bold)
+                ("HOLD" :foreground "magenta" :weight bold)
+                ("CANCELLED" :foreground "forest green" :weight bold)
+                ;; ("MEETING" :foreground "forest green" :weight bold)
+                ;; ("PHONE" :foreground "forest green" :weight bold)
+                )))
 #+END_SRC
 
-** =Ctrl= key bindings
+Fast todo selections
 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;;
+  (setq org-use-fast-todo-selection t)
+  (setq org-treat-S-cursor-todo-selection-as-state-change nil)
+#+END_SRC
 
-  ;; 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  
+TODO state triggers and tags, [[http://doc.norang.ca/org-mode.html][Organize Your Life in Plain Text]]
 
-  ;; C-n    next-line
-  ;; C-m
-  ;; C-,
-  ;; C-.
-  ;; C-/
+- Moving a task to =CANCELLED=, adds a =CANCELLED= tag
+- Moving a task to =WAITING=, adds a =WAITING= tag
+- Moving a task to =HOLD=, add =HOLD= tags
+- Moving a task to =DONE=, remove =WAITING=, =HOLD= tag
+- Moving a task to =NEXT=, remove all waiting/hold/cancelled tags
 
-  ;; C-y
-  ;; C-u
-  ;; C-i
-  ;; C-o
-  ;; C-p
-  ;; C-[
-  ;; C-]
-  ;; C-\
+This tags are used to filter tasks in agenda views
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq org-todo-state-tags-triggers
+        (quote (("CANCELLED" ("CANCELLED" . t))
+                ("WAITING" ("WAITING" . t))
+                ("HOLD" ("WAITING") ("HOLD" . t))
+                (done ("WAITING") ("HOLD"))
+                ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
+                ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
+                ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
+#+END_SRC
 
-  ;; C-=
-  ;; C--
-  ;; C-0
-  ;; C-9
-  ;; C-8
-  ;; C-7
+Logging Stuff 
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  ;; log time when task done
+  ;; (setq org-log-done (quote time))
+  ;; save clocking into to LOGBOOK
+  (setq org-clock-into-drawer t)
+  ;; save state change notes and time stamp into LOGBOOK drawer
+  (setq org-log-into-drawer t)
+  (setq org-clock-into-drawer "CLOCK")
+#+END_SRC
 
-  ;; C-Space
+*** Tags
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq org-tag-alist (quote ((:startgroup)
+                              ("@office" . ?e)
+                              ("@home" . ?h)
+                              (:endgroup)
+                              ("WAITING" . ?w)
+                              ("HOLD" . ?h)
+                              ("CANCELLED" . ?c))))
 
+  ;; Allow setting single tags without the menu
+  (setq org-fast-tag-selection-single-key (quote expert))
+#+END_SRC
 
+*** Capture - Refile - Archive
 
+Capture lets you quickly store notes with little interruption of your work flow.
 
+**** Capture Templates
 
+When a new taks needs to be added, categorize it as 
 
+All captured file which need next actions are stored in =refile.org=, 
+- A new task / note (t) =refile.org=
+- A work task in office =office.org=
+- A jourenl =diary.org=
+- A new habit (h) =refile.org=
 
-#+END_SRC
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq org-directory "~/org")
+  (setq org-default-notes-file "~/org/refile.org")
+  (setq sd/org-diary-file "~/org/diary.org")
 
-** =Super= bindings for file, buffer and windows
+  (global-set-key (kbd "C-c c") 'org-capture)
 
-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)
+  (setq org-capture-templates
+        (quote (("t" "Todo" entry (file org-default-notes-file)
+                 "* TODO %?\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
+                ("n" "Note" entry (file org-default-notes-file)
+                 "* %? :NOTE:\n:LOGBOOK:\n- Added: %U\t\tAt: %a\n:END:")
+                ("j" "Journal" entry (file+datetree sd/org-diary-file)
+                 "* %?\n:LOGBOOK:\n:END:" :clock-in t :clock-resume t)
+                ("h" "Habit" entry (file org-default-notes-file)
+                 "* NEXT %?\n:LOGBOOK:\n%a\nSCHEDULED: %(format-time-string \"%<<%Y-%m-%d %a .+1d/3d>>\")\n:END:\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n "))))
+#+END_SRC
 
-  (global-set-key (kbd "s-`") 'mode-line-other-buffer)
+**** Refiling Tasks
 
-  (global-set-key (kbd "s-n") 'persp-next)
-  (global-set-key (kbd "s-p") 'persp-prev)
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq org-refile-targets (quote (;; (nil :maxlevel . 9)
+                                   (org-agenda-files :maxlevel . 9))))
 
+  (setq org-refile-use-outline-path t)
 
+  (setq org-refile-allow-creating-parent-nodes (quote confirm))
+#+END_SRC
 
-  ;; someothers default mapping on super (command) key
-  ;; s-s save-buffer
-  ;; s-k kill-this-buffer
+*** Agenda Setup
+Setting agenda files and the agenda view
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq org-agenda-files (quote ("~/org/gtd.org"
+                                 "~/org/work.org")))
 
+  ;; only show today's tasks in agenda view
+  (setq org-agenda-span 'day)
+  ;; Use current windows for agenda view
+  (setq org-agenda-window-setup 'current-window)
 
-  ;; 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 +
+  ;; show all feature entries for repeating tasks,
+  ;; this is already setting by default
+  (setq org-agenda-repeating-timestamp-show-all t)
 
-  ;; 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 +
+  ;; Show all agenda dates - even if they are empty
+  (setq org-agenda-show-all-dates t)
+#+END_SRC
 
-  ;; s-0  -->  undefined
-  ;; s-9  -->  undefined
-  ;; s-8  -->  undefined
-  ;; s-7  -->  undefined
-  ;; s-6  -->  undefined
-  ;; s--  -->  center-line
-  ;; s-=  -->  undefined
+** Export PDF
 
-  ;; s-n  -->  make-frame
-  ;; s-m  -->  iconify-frame
-  ;; s-b  -->  undefined
-  ;; s-,  -->  customize
-  ;; s-.  -->  undefined
-  ;; s-/  -->  undefined
+Install MacTex-basic and some tex packages
 
-  ;; s-g  -->  isearch-repeat-forward
-  ;; s-f  -->  projectile-find-file   +
-  ;; s-d  -->  isearch-repeat-background
-  ;; s-s  -->  save-buffer
-  ;; s-a  -->  make-whole-buffer
+#+BEGIN_SRC bash 
 
-  ;; s-b  -->  undefined
-  ;; s-v  -->  yank
-  ;; s-c  -->  ns-copy-including-secondary
+  sudo tlmgr update --self
 
-  ;; s-t  -->  ns-popup-font-panel
-  ;; s-r  -->  undefined
-  ;; s-e  -->  isearch-yanqk-kill
-  ;; s-w  -->  delete-frame
-  ;; s-q  -->  same-buffers-kill-emacs
+  sudo tlmgr install titlesec framed threeparttable wrapfig multirow enumitem bbding titling tabu mdframed tcolorbox textpos import varwidth needspace tocloft ntheorem environ trimspaces collection-fontsrecommended capt-of
 
-  ;; 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
+  ;; ;; allow for export=>beamer by placing
 
-  (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))
+  ;; http://emacs-fu.blogspot.com/2011/04/nice-looking-pdfs-with-org-mode-and.html
+  ;; #+LaTeX_CLASS: beamer in org files
+  (unless (boundp 'org-export-latex-classes)
+    (setq org-export-latex-classes nil))
+  (add-to-list 'org-export-latex-classes
+    ;; beamer class, for presentations
+    '("beamer"
+       "\\documentclass[11pt]{beamer}\n
+        \\mode<{{{beamermode}}}>\n
+        \\usetheme{{{{beamertheme}}}}\n
+        \\usecolortheme{{{{beamercolortheme}}}}\n
+        \\beamertemplateballitem\n
+        \\setbeameroption{show notes}
+        \\usepackage[utf8]{inputenc}\n
+        \\usepackage[T1]{fontenc}\n
+        \\usepackage{hyperref}\n
+        \\usepackage{color}
+        \\usepackage{listings}
+        \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
+    frame=single,
+    basicstyle=\\small,
+    showspaces=false,showstringspaces=false,
+    showtabs=false,
+    keywordstyle=\\color{blue}\\bfseries,
+    commentstyle=\\color{red},
+    }\n
+        \\usepackage{verbatim}\n
+        \\institute{{{{beamerinstitute}}}}\n          
+         \\subject{{{{beamersubject}}}}\n"
 
-  (define-key minibuffer-local-map "\M-s" nil)
+       ("\\section{%s}" . "\\section*{%s}")
+       ("\\begin{frame}[fragile]\\frametitle{%s}"
+         "\\end{frame}"
+         "\\begin{frame}[fragile]\\frametitle{%s}"
+         "\\end{frame}")))
 
-  (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)
+    ;; letter class, for formal letters
 
-  (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)
+    (add-to-list 'org-export-latex-classes
 
+    '("letter"
+       "\\documentclass[11pt]{letter}\n
+        \\usepackage[utf8]{inputenc}\n
+        \\usepackage[T1]{fontenc}\n
+        \\usepackage{color}"
+       ("\\section{%s}" . "\\section*{%s}")
+       ("\\subsection{%s}" . "\\subsection*{%s}")
+       ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
+       ("\\paragraph{%s}" . "\\paragraph*{%s}")
+       ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
 
-  (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
+  (require 'ox-md)
+  (require 'ox-beamer)
 
-  ;; 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
+  (setq org-latex-pdf-process
+        '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
+          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
+          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
 
-  ;; 
-  ;; (global-set-key (kbd "M-s M-r") 'isearch-backward-regexp)
-  ;;
+  (setq TeX-parse-self t)
+
+  (setq TeX-PDF-mode t)
+  (add-hook 'LaTeX-mode-hook
+            (lambda ()
+              (LaTeX-math-mode)
+              (setq TeX-master t)))
 
-  ;; M-c
-  ;; M-r
-  ;; M-t
-  ;; M-u, 
 #+END_SRC
 
-Occur search key bindings
+** others
 
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+extend org-mode's easy templates, refer to [[http://coldnew.github.io/coldnew-emacs/#orgheadline94][Extend org-modes' esay templates]]
 
-  (define-key occur-mode-map (kbd "C-n")
-    (lambda ()
-      (interactive)
-      (occur-next)
-      (occur-mode-goto-occurrence-other-window)
-      (recenter)
-      (other-window 1)))
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
 
-  (define-key occur-mode-map (kbd "C-p")
-    (lambda ()
-      (interactive)
-      (occur-prev)
-      (occur-mode-goto-occurrence-other-window)
-      (recenter)
-      (other-window 1)))
+  (add-to-list 'org-structure-template-alist
+               '("E" "#+BEGIN_SRC emacs-lisp :tangle yes :results silent\n?\n#+END_SRC"))
+  (add-to-list 'org-structure-template-alist
+               '("S" "#+BEGIN_SRC sh\n?\n#+END_SRC"))
+  (add-to-list 'org-structure-template-alist
+               '("p" "#+BEGIN_SRC plantuml :file uml.png \n?\n#+END_SRC"))
 
 #+END_SRC
 
-
-** =M-o= as prefix key for windows
-
-** =M-g= as prefix key for launcher
-
-** others
-
+* Magit
+[[https://github.com/magit/magit][Magit]] is a very cool git interface on Emacs.
+and Defined keys, using vi keybindings, Refer abo-abo's setting [[https://github.com/abo-abo/oremacs/blob/c5cafdcebc88afe9e73cc8bd40c49b70675509c7/modes/ora-nextmagit.el][here]]
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
-
-  ;; C-'    undefined
-  ;; C-.    undefined
+  (use-package magit
+    :ensure t
+    :commands magit-status magit-blame
+    :config
+    (dolist (map (list magit-status-mode-map
+                       magit-log-mode-map
+                       magit-diff-mode-map
+                       magit-staged-section-map))
+      (define-key map "j" 'magit-section-forward)
+      (define-key map "k" 'magit-section-backward)
+      (define-key map "D" 'magit-discard-file)
+      (define-key map "n" nil)
+      (define-key map "p" nil)
+      (define-key map "v" 'recenter-top-bottom)
+      (define-key map "i" 'magit-section-toggle)))
 #+END_SRC
 
 * Eshell