Skip to content

Latest commit

 

History

History
181 lines (138 loc) · 5.54 KB

emacs-kh.org

File metadata and controls

181 lines (138 loc) · 5.54 KB

The Emacs Configuration of Kelvin Hu

Now it’s time to configure Emacs through org-mode, I should catch up the fashion, shouldn’t I? :-p

General Configuration

  1. disable loading vc plugins, it will obviously slow down emacs booting:
    (setq vc-handled-backends nil)
        
  2. start the server:
    (require 'server)
    ;; fix directory unsafe error
    (when (and (>= emacs-major-version 23)
               (equal window-system 'w32))
      (defun server-ensure-safe-dir (dir) "Noop" t))
    (unless (server-running-p)
      (server-start))
        
  3. extend the loading path:
    (add-to-list 'load-path "~/.emacs.d/conf")
    (add-to-list 'load-path "~/.emacs.d/util")
        

Sub Packages

  1. setup the proxy server if it is an office machine, as all traffic without proxy will be blocked, so emacs package update will always fail
    (require 'util-common)
    (if is-os-windows
        (setq url-proxy-services '(("http" . "web-proxy.oa.com:8080"))))
        
  2. make sure the package dependency verification module is loaded at the first step
    (require 'conf-package)
        
  3. other modules
    (require 'conf-theme)
    (require 'conf-misc)
    (require 'conf-ido)
    (require 'conf-smex)
    (require 'conf-editing)
    (require 'conf-programming)
    ;;; now, use company instead of auto-complete
    ;; (require 'conf-auto-complete)
    (require 'conf-markdown)
    (require 'conf-ace-jump)
    (require 'conf-smartparens)
    (require 'conf-org)
    (require 'conf-org-page)
    (require 'conf-ibuffer)
    (require 'conf-yasnippet)
    (require 'conf-flyspell)
    (require 'conf-encoding)
    (require 'conf-undo-tree)
    (require 'conf-highlight-symbol)
        
  4. read the desktop configuration at the last step
    (require 'conf-desktop)
        

also use org-mode to configure other sub modules

recentf

(require 'recentf)
(recentf-mode 1)
(setq recentf-max-saved-items 200
      recentf-max-menu-items 15)

helm

TODO: improve the following code block

(require 'helm)
(require 'helm-config)

(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-unset-key (kbd "C-x c"))

(define-key isearch-mode-map (kbd "M-i") 'helm-swoop-from-isearch)
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to do persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z")  'helm-select-action) ; list actions using C-z

(global-set-key (kbd "C-x f") 'helm-recentf)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-c i") 'helm-imenu)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x b") 'helm-mini)
(global-set-key (kbd "C-c h o") 'helm-occur)
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
(global-set-key (kbd "C-c h x") 'helm-register)
(global-set-key (kbd "C-c h g") 'helm-google-suggest)

(setq helm-split-window-in-side-p           t ; open helm buffer inside current window, not occupy whole other window
      helm-move-to-line-cycle-in-source     t ; move to end or beginning of source when reaching top or bottom of source.
      helm-ff-search-library-in-sexp        t ; search for library in `require' and `declare-function' sexp.
      helm-scroll-amount                    8 ; scroll 8 lines other window using M-<next>/M-<prior>
      helm-ff-file-name-history-use-recentf t)

(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x
(setq helm-recentf-fuzzy-match t)
(setq helm-buffers-fuzzy-matching t)

(helm-mode 1)

company-mode

It should be the next generation completion engine. :-)

(require 'company)

(add-hook 'after-init-hook 'global-company-mode)

irony-mode

A great mode for C/C++ completion using libclang.

(require 'irony)

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)

(eval-after-load 'company
  '(add-to-list 'company-backends 'company-irony))

;; (optional) adds CC special commands to `company-begin-commands' in order to
;; trigger completion at interesting places, such as after scope operator
;;     std::|
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)

(if is-os-windows
    (setq w32-pipe-read-delay 0))

neotree

(require 'neotree)
;; the following hook is to solve key conflict with evil-mode
(add-hook 'neotree-mode-hook
          (lambda ()
            (define-key evil-normal-state-local-map (kbd "TAB") 'neotree-enter)
            (define-key evil-normal-state-local-map (kbd "SPC") 'neotree-enter)
            (define-key evil-normal-state-local-map (kbd "q") 'neotree-hide)
            (define-key evil-normal-state-local-map (kbd "RET") 'neotree-enter)))