* Introduction
-Most config copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s dotfiles
+Most config are just copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s dotfiles
* Basic Settings
-** Setting Path
+** Setting loading Path
-Set the system PATH environment
+Set the emacs load path
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
+ (add-to-list 'load-path "~/.emacs.d/elisp")
#+END_SRC
-Set the emacs load path
+** Package Initialization
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+#+BEGIN_SRC emacs-lisp :tangle yes
- (add-to-list 'load-path "~/.emacs.d/elisp")
+ (require 'package)
+
+ (setq package-archives '(("mepla" . "http://melpa.milkbox.net/packages/")
+ ("org" . "http://orgmode.org/elpa/")))
+
+ (package-initialize)
#+END_SRC
(setq inhibit-startup-message t)
(defalias 'yes-or-no-p 'y-or-n-p)
-
-
-#+END_SRC
-
-** Package Initialization
-
-#+BEGIN_SRC emacs-lisp :tangle yes
-
- (require 'package)
-
- (setq package-archives '(("mepla" . "http://melpa.milkbox.net/packages/")
- ("org" . "http://orgmode.org/elpa/")))
-
- (package-initialize)
+ (show-paren-mode 1)
#+END_SRC
#+END_SRC
+** Font Setting
+
+syntax highlighting
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (global-font-lock-mode 1)
+
+#+END_SRC
+
+[[https://github.com/i-tu/Hasklig][Hasklig]] and Source Code Pro, defined fonts family
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (if window-system
+ (defvar sd/fixed-font-family
+ (cond ((x-list-fonts "Hasklig") "Hasklig")
+ ((x-list-fonts "Source Code Pro") "Source Code Pro")
+ ((x-list-fonts "Anonymous Pro") "Anonymous Pro")
+ ((x-list-fonts "M+ 1mn") "M+ 1mn"))
+ "The fixed width font based on what is installed, `nil' if not defined."))
+
+#+END_SRC
+
+Setting the fonts
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (if window-system
+ (when sd/fixed-font-family
+ (set-frame-font sd/fixed-font-family)
+ (set-face-attribute 'default nil :font sd/fixed-font-family :height 140)
+ (set-face-font 'default sd/fixed-font-family)))
+
+#+END_SRC
+
** Color Theme
Loading theme should be after all required loaded, refere [[https://github.com/jwiegley/use-package][:defer]] in =use-package=
#+END_SRC
-syntax highlighting
+Change the Org-mode colors
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (global-font-lock-mode 1)
+ (defun org-src-color-blocks-light ()
+ "Colors the block headers and footers to make them stand out more for lighter themes"
+ (interactive)
+ (custom-set-faces
+ '(org-block-begin-line
+ ((t (:underline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
+ '(org-block-background
+ ((t (:background "#FFFFEA"))))
+ '(org-block
+ ((t (:background "#FFFFEA"))))
+ '(org-block-end-line
+ ((t (:overline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF"))))
+
+ '(mode-line-buffer-id ((t (:foreground "#005000" :bold t))))
+ '(which-func ((t (:foreground "#008000"))))))
+
+ (defun org-src-color-blocks-dark ()
+ "Colors the block headers and footers to make them stand out more for dark themes"
+ (interactive)
+ (custom-set-faces
+ '(org-block-begin-line
+ ((t (:foreground "#008ED1" :background "#002E41"))))
+ '(org-block-background
+ ((t (:background "#000000"))))
+ '(org-block
+ ((t (:background "#000000"))))
+ '(org-block-end-line
+ ((t (:foreground "#008ED1" :background "#002E41"))))
+
+ '(mode-line-buffer-id ((t (:foreground "black" :bold t))))
+ '(which-func ((t (:foreground "green"))))))
+
+ (org-src-color-blocks-dark)
#+END_SRC
-** Font Setting
-
-[[https://github.com/i-tu/Hasklig][Hasklig]] and Source Code Pro, defined fonts family
-
+improve color for org-mode
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+ (deftheme ha/org-theme "Sub-theme to beautify org mode")
(if window-system
- (defvar sd/fixed-font-family
- (cond ((x-list-fonts "Hasklig") "Hasklig")
- ((x-list-fonts "Source Code Pro") "Source Code Pro")
- ((x-list-fonts "Anonymous Pro") "Anonymous Pro")
- ((x-list-fonts "M+ 1mn") "M+ 1mn"))
- "The fixed width font based on what is installed, `nil' if not defined."))
+ (defvar sd/variable-font-tuple
+ (cond ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
+ ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande"))
+ ((x-list-fonts "Verdana") '(:font "Verdana"))
+ ((x-family-fonts "Sans Serif") '(:family "Sans Serif"))
+ (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro.")))
+ "My variable width font available to org-mode files and whatnot."))
+
+ (defun sd/org-color ()
+ (let* ((sd/fixed-font-tuple (list :font sd/fixed-font-family))
+ (base-font-color (face-foreground 'default nil 'default))
+ (background-color (face-background 'default nil 'default))
+ (primary-color (face-foreground 'mode-line nil))
+ (secondary-color (face-background 'secondary-selection nil 'region))
+ (base-height (face-attribute 'default :height))
+ (headline `(:inherit default :weight bold :foreground ,base-font-color)))
+ (custom-theme-set-faces 'ha/org-theme
+ `(org-agenda-structure ((t (:inherit default :height 2.0 :underline nil))))
+ `(org-verbatim ((t (:inherit 'fixed-pitched :foreground "#aef"))))
+ `(org-table ((t (:inherit 'fixed-pitched))))
+ `(org-block ((t (:inherit 'fixed-pitched))))
+ `(org-block-background ((t (:inherit 'fixed-pitched))))
+ `(org-block-begin-line ((t (:inherit 'fixed-pitched))))
+ `(org-block-end-line ((t (:inherit 'fixed-pitched))))
+ `(org-level-8 ((t (,@headline ,@sd/variable-font-tuple))))
+ `(org-level-7 ((t (,@headline ,@sd/variable-font-tuple))))
+ `(org-level-6 ((t (,@headline ,@sd/variable-font-tuple))))
+ `(org-level-5 ((t (,@headline ,@sd/variable-font-tuple))))
+ `(org-level-4 ((t (,@headline ,@sd/variable-font-tuple
+ :height ,(round (* 1.1 base-height))))))
+ `(org-level-3 ((t (,@headline ,@sd/variable-font-tuple
+ :height ,(round (* 1.25 base-height))))))
+ `(org-level-2 ((t (,@headline ,@sd/variable-font-tuple
+ :height ,(round (* 1.5 base-height))))))
+ `(org-level-1 ((t (,@headline ,@sd/variable-font-tuple
+ :height ,(round (* 1.75 base-height))))))
+ `(org-document-title ((t (,@headline ,@sd/variable-font-tuple :height 1.5 :underline nil)))))))
+
#+END_SRC
-Setting the fonts
+* 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
- (if window-system
- (when sd/fixed-font-family
- (set-frame-font sd/fixed-font-family)
- (set-face-attribute 'default nil :font sd/fixed-font-family :height 150)
- (set-face-font 'default sd/fixed-font-family)))
+ (use-package org
+ :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)))
#+END_SRC
-* Org-mode Settings
-
** Org-bullets
use [[https://github.com/sabof/org-bullets][org-bullets]] package to show utf-8 charactes
#+END_SRC
-** Org-mode Basic setting
+** Worf Mode
-Always indents header, and hide header leading starts so that no need type =#+STATUP: indent=
+[[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-]=
#+BEGIN_SRC emacs-lisp :tangle yes :results silent
- (setq org-startup-indented t)
- (setq org-hide-leading-starts t)
- ;(setq org-src-fontify-natively t)
- (setq org-src-tab-acts-natively t)
+ (use-package worf
+ :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))
#+END_SRC
** Capture
+* Magit
+
+[[https://github.com/magit/magit][Magit]] is a very cool git interface on Emacs.
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (use-package magit
+ :ensure t
+ :commands magit-status magit-blame)
+
+
+#+END_SRC
+
+* IDO & SMEX
+
+** IDO
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (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"))
+
+#+END_SRC
+
+** FLX
+
+#+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))
+
+#+END_SRC
+
+** IDO-vertically
+
+#+BEGIN_SRC emacs-lisp :tangle yes :result 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))
+
+#+END_SRC
+
+** SMEX
+
+#+BEGIN_SRC emacs-lisp :tangle yes :result silent
+
+ (use-package smex
+ :ensure t
+ :init (smex-initialize)
+ :bind
+ ("M-x" . smex)
+ ("M-X" . smex-major-mode-commands))
+
+#+END_SRC
+
+* Misc Settings
+
+** Line Number
+
+Enable linum mode on programming modes
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (add-hook 'prog-mode-hook 'linum-mode)
+
+#+END_SRC
+
+Fix the font size of line number
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (defun fix-linum-size ()
+ (interactive)
+ (set-face-attribute 'linum nil :height 110))
+
+ (add-hook 'linum-mode-hook 'fix-linum-size)
+
+#+END_SRC
+
+I like [[https://github.com/coldnew/linum-relative][linum-relative]], just like the =set relativenumber= on =vim=
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (use-package linum-relative
+ :ensure t
+ :config
+ (defun linum-new-mode ()
+ "If line numbers aren't displayed, then display them.
+ Otherwise, toggle between absolute and relative numbers."
+ (interactive)
+ (if linum-mode
+ (linum-relative-toggle)
+ (linum-mode 1)))
+
+ :bind
+ ("A-k" . linum-new-mode))
+
+ ;; auto enable linum-new-mode in programming modes
+ (add-hook 'prog-mode-hook 'linum-relative-mode)
+
+#+END_SRC
+
+** Save File Position
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (require 'saveplace)
+ (setq-default save-place t)
+ (setq save-place-forget-unreadable-files t)
+ (setq save-place-skip-check-regexp "\\`/\\(?:cdrom\\|floppy\\|mnt\\|/[0-9]\\|\\(?:[^@/:]*@\\)?[^@/:]*[^@/:.]:\\)")
+
+#+END_SRC
+
+** Multi-term
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (use-package multi-term
+ :ensure t)
+
+#+END_SRC
+
+** ace-link
+
+[[https://github.com/abo-abo/ace-link][ace-link]] is a package written by [[https://github.com/abo-abo][Oleh Krehel]]. It is convenient to jump to link in help mode, info-mode, etc
+Type =o= to go to the link
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (use-package ace-link
+ :ensure t
+ :init
+ (ace-link-setup-default))
+
+#+END_SRC
+
+* Programming Languages
+
+** Emacs Lisp
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (use-package color-identifiers-mode
+ :ensure t
+ :init
+ (add-hook 'emacs-lisp-mode-hook 'color-identifiers-mode)
+
+ :diminish color-identifiers-mode)
+
+#+END_SRC
+
+** Perl
+
+[[https://www.emacswiki.org/emacs/CPerlMode][CPerl mode]] has more features than =PerlMode= for perl programming. Alias this to =CPerlMode=
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+
+ (defalias 'perl-mode 'cperl-mode)
+
+#+END_SRC
+
+* Others
+
+** Shell pop mode
+
+** Smartparens mode
+
+***