emacs - tidy up init.el file
[dotfiles.git] / emacs.d / init.el
index dca0552..fc7fee9 100644 (file)
 
 (setq debug-on-error t)
 
-(scroll-bar-mode -1)
-(tool-bar-mode -1)
-;(menu-bar-mode -1)
-(add-to-list 'default-frame-alist '(width  . 120))
-(add-to-list 'default-frame-alist '(height . 40))
-;(add-to-list 'default-frame-alist '(font . "Source Code Pro for Powerline-12:weight:light" ))
-(add-to-list 'default-frame-alist '(font . "Source Code Pro for Powerline-12" ))
-
-
-(put 'set-goal-column 'disabled nil)
-(setq vc-follow-symlinks t)
-(setq visible-bell 1)
-(setq ring-bell-function 'ignore)
-(setq resize-mini-windows t)
-
-
-(add-to-list 'auto-mode-alist '("emacs\\'" . emacs-lisp-mode))
-(fringe-mode 0)
 
+(add-to-list 'load-path "~/.emacs.d/config")
 
+(require 'init-base)
 
-;;; Set symbol for the border
-(set-display-table-slot standard-display-table
-                        'vertical-border 
-                        (make-glyph-code ?┃))
+(require 'my-packages)
 
-(set-face-attribute 'vertical-border nil  :foreground "gray")
+(require 'init-color-theme)
 
+(require 'init-ido)
 
-(add-to-list 'load-path "~/.emacs.d/config")
-(require 'my-packages)
+(require 'init-magit)
 
-;; elscreen should be placed begin of https://github.com/knu/elscreen/issues/6
-(elscreen-start)
-(require 'init-elscreen)
-(require 'init-color-theme)
+(require 'init-evil)
 
+(require 'init-project)
 
-;---------------------------------------------------------------------------------------
-;; Ido
-;;
-(require 'ido-vertical-mode)
-(ido-vertical-mode 1)
-(require 'flx-ido)
-(ido-mode 1)
-(ido-everywhere 1)
-(flx-ido-mode 1)
-(setq ido-use-faces nil)
+(require 'projectile-speedbar)
 
-(setq org-completion-use-ido t)
-(setq magit-completing-read-function 'magit-ido-completing-read)
 
-(require 'ido-ubiquitous)
-(ido-ubiquitous-mode 1)
+(require 'init-ggtags)
 
-;; smex
-(require 'smex) 
-(global-set-key (kbd "M-x") 'smex)
-(global-set-key (kbd "M-X") 'smex-major-mode-commands)
 
-;;---------------------------------------------------------------------------------------
-;; Magit
-;;
-(require 'magit)
-(setq magit-last-seen-setup-instructions "1.4.0")
-(global-set-key (kbd "C-x g") 'magit-status)
-;(setq magit-auto-revert-mode nil)
+(setq scroll-margin 5)
+(setq scroll-conservatively 10000)
+(show-paren-mode t)
 
 
-;(require 'init-evil)
+(require 'init-c-cpp)
 
+(require 'recentf)
+(recentf-mode 1)
+(setq recentf-max-menu-items 100)
 
 
-;;---------------------------------------------------------------------------------------
-;; Fiplr
-;;
-(setq fiplr-root-markers '(".git" ".svn" "*.DS_Store"))
-(setq fiplr-ignored-globs '((directories (".git" ".svn"))
-                            (files ("*.jpg" "*.png" "*.zip" "*~" "*.o" ".obj" "*.swp" "*.hg" ".pyc" ".*" ))))
+(require 'recentf-ext)
 
-(global-set-key (kbd "C-x f") 'fiplr-find-file)
+(require 'init-key-binding)
 
-;;---------------------------------------------------------------------------------------
-;; Wind-move
-;;
-(global-set-key (kbd "C-x C-l") 'windmove-right)
-(global-set-key (kbd "C-x C-h") 'windmove-left)
-(global-set-key (kbd "C-x C-k") 'windmove-up)
-(global-set-key (kbd "C-x C-j") 'windmove-down)
+(winner-mode 1)
 
-;;---------------------------------------------------------------------------------------
-;; sr-speedbar
-;;
-;(require 'sr-speedbar)
-;(setq speedbar-use-images nil)
-;(setq speedbar-show-unknown-files t)
+(global-set-key (kbd "C-c C-l") 'winner-redo)
+(global-set-key (kbd "C-c C-h") 'winner-undo)
 
 
-;(toggle-frame-fullscreen)
 
 
-(require 'projectile)
-(projectile-global-mode)
-(setq projectile-enable-caching t)
-(require 'projectile-speedbar)
 
-;(require 'cc-mode)
-;(require 'ecb)
 
-;(setq ecb-layout-name "leftright3")
+;;; set font size of minibuffer
+;;;; http://stackoverflow.com/questions/7869429/altering-the-font-size-for-the-emacs-minibuffer-separately-from-default-emacs
+(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup)
+(defun my-minibuffer-setup ()
+       (set (make-local-variable 'face-remapping-alist)
+          '((default :height 120))))
 
 
-;(setq mac-command-modifier 'super) ; make cmd key do Meta
-(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)
+
+(add-hook 'minibuffer-setup-hook
+          (lambda ()
+            (make-local-variable 'face-remapping-alist)
+            (add-to-list 'face-remapping-alist '(default (:background "green")))))
 
 
 
 
-(global-set-key (kbd "M-g M-v") 'split-window-right)
-(global-set-key (kbd "M-g M-s") 'split-window-below)
-(global-set-key (kbd "M-g M-o") 'delete-other-windows)
+;;;;;(require 'escape)
+;(setq-default evil-escape-delay 0.2)  
+;(setq evil-escape-excluded-major-modes '(dired-mode))
+;(setq-default evil-escape-key-sequence "jj")
+;(evil-escape-mode 1)
+
 
-(global-set-key (kbd "M-g M-w") 'other-window)
+;; ---------------
+;; recent file
+(require 'recentf)
+(recentf-mode)
+;(setq recentf-max-menu-items 100)
 
-;; gnu global support
-;(require 'semantic/db)
-;(global-semanticdb-minor-mode 1)
+;; http://www.emacswiki.org/emacs/RecentFiles
+(defun recentf-ido-find-file ()
+  "Find a recent file using Ido."
+  (interactive)
+  (let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
+    (when file
+      (find-file file))))
 
-(require 'init-ggtags)
 
-(global-unset-key "\C-o")
-(global-set-key (kbd "C-o C-f") 'ido-find-file)
-(global-set-key (kbd "C-o C-b") 'ido-switch-buffer)
 
-(global-set-key (kbd "C-o g") 'ggtags-find-file)
-(global-set-key (kbd "C-o t") 'ggtags-find-tag-dwim)
+;; http://stackoverflow.com/questions/11484225/fix-an-auto-complete-mode-and-linum-mode-annoyance
+(ac-linum-workaround)
 
-(global-set-key (kbd "M-g M-g") 'magit-status)
 
+;; ---------------------------------
+;; linum-relative
 
-(setq scroll-margin 5)
-(setq scroll-conservatively 10000)
-(show-paren-mode t)
 
-;;; next, cedet & ecb for c++ development
-;(require 'cc-mode)
-;(require 'semantic)
-
-;(global-semanticdb-minor-mode 1)
-;(global-semantic-idle-scheduler-mode 1)
-
-;(semantic-mode 1)
-
-
-(add-hook 'c++-mode-hook 'irony-mode)
-(add-hook 'c-mode-hook 'irony-mode)
-(add-hook 'objc-mode-hook 'irony-mode)
-
-
-;;---------------------------------------------------------------------------------------
-;; irony-mode
-;;
-;; replace the `completion-at-point' and `complete-symbol' bindings in
-;; irony-mode's buffers by irony-mode's function
-(defun my-irony-mode-hook ()
-  (define-key irony-mode-map [remap completion-at-point]
-    'irony-completion-at-point-async)
-  (define-key irony-mode-map [remap complete-symbol]
-    'irony-completion-at-point-async))
-(add-hook 'irony-mode-hook 'my-irony-mode-hook)
-(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
-
-
-
-
-;; c/c++ auto-complete, yasnippet, auto-complet-c-headers
-;;https://www.youtube.com/watch?v=HTUE03LnaXA&list=PL-mFLc7R_MJet8ItKipCtYc7PWoS5KTfM
-(require 'auto-complete)
-(require 'auto-complete-config)
-(ac-config-default)
-;; input TAB to 
-(require 'yasnippet)
-(yas-global-mode 1)
-
-;; auto-complete-c-headers
-(defun my:ac-c-header-init ()
-  (require 'auto-complete-c-headers)
-  (add-to-list 'ac-sources 'ac-source-c-headers)
-  (add-to-list 'achead:include-directories "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include")
-)
-;; call this function from c/c++ hooks
-(add-hook 'c++-mode-hook 'my:ac-c-header-init)
-(add-hook 'c-mode-hook 'my:ac-c-header-init)
-
-;;; iedit, fix iedit bug in Mac, C-c ; to trigger multiple cursor edit
-(define-key global-map (kbd "C-c ;") 'iedit-mode)
-
-;; flymake-google-cpplint-load
-;; define a function for flymake initialization
-(defun my:flymake-google-init ()
-  (require 'flymake-google-cpplint)
-  (custom-set-variables
-   '(flymake-google-cpplint-command "/usr/local/bin/cpplint"))
-  (flymake-google-cpplint-load)
-  )
-(add-hook 'c-mode-hook 'my:flymake-google-init)
-(add-hook 'c++-mode-hook 'my:flymake-google-init)
-
-;; start google-c-style with emacs
-;(require 'google-c-style)
-(add-hook 'c-mode-hook 'google-set-c-style)
-(add-hook 'c++-mode-hook 'google-make-newline-indent)
-
-;; cedet
-(semantic-mode 1)
-;; let's define a function which adds semantic as a suggestion backend to auto complete
-(defun my:add-semantic-to-autocomplete()
-  (add-to-list 'ac-sources 'ac-source-semantic)
-  )
-(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
-;; turn on ede mode
-(global-ede-mode 1)
-
-;(ede-cpp-root-project "my project" :file "~/demos/my_program/src/main.cpp"
-;                    :include-path '("/../my_inc"))
-;; you can use system-include-path for setting up the system header file locations.
-
-;; turn on automatic reparsing of open buffers in semantic
-(global-semantic-idle-scheduler-mode 1)
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(fringe-mode (quote (4 . 0)) nil (fringe))
+ '(ggtags-split-window-function (quote split-window-vertically))
+ '(hes-mode-alist
+   (quote
+    ((c-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
+     (cperl-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
+     (c++-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
+     (objc-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
+     (java-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|u[[:xdigit:]]\\{4\\}\\|[\"'\\bfnrt]\\)\\)")
+     (js-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{2\\}\\|u[[:xdigit:]]\\{4\\}\\|.\\)\\)")
+     (js2-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{2\\}\\|u[[:xdigit:]]\\{4\\}\\|.\\)\\)")
+     (ruby-mode
+      ("\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{1,2\\}\\|u\\(?:[[:xdigit:]]\\{4\\}\\|{[[:xdigit:]]\\{1,6\\}\\(?:[[:space:]]+[[:xdigit:]]\\{1,6\\}\\)*}\\)\\|.\\)\\)"
+       (0
+        (let*
+            ((state
+              (syntax-ppss))
+             (term
+              (nth 3 state)))
+          (when
+              (or
+               (and
+                (eq term 39)
+                (member
+                 (match-string 2)
+                 (quote
+                  ("\\" "'"))))
+               (if
+                   (fboundp
+                    (quote ruby-syntax-expansion-allowed-p))
+                   (ruby-syntax-expansion-allowed-p state)
+                 (memq term
+                       (quote
+                        (34 47 10 96 t)))))
+            (add-face-text-property
+             (match-beginning 1)
+             (match-end 1)
+             (quote hes-escape-backslash-face))
+            (add-face-text-property
+             (match-beginning 2)
+             (match-end 2)
+             (quote hes-escape-sequence-face))
+            nil))
+        prepend))))))
+ '(org-agenda-files (quote ("~/Private/org/diary.org" "~/temp/org-note.org")))
+ '(powerline-text-scale-factor 0.85))
+
+;; maybe better to fix the size of line number rather scaled 0.8
+;; https://github.com/howardabrams/dot-files/blob/master/emacs.org
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(highlight-current-line-face ((t (:background "gray22"))))
+ '(linum ((t (:background "#000000" :foreground "gray40" :height 0.8 :slant italic :weigth light))))
+ '(linum-relative-current-face ((t (:inherit linum :foreground "Yellow" :weight light :height 0.8))))
+ '(mode-line ((t (:foreground "#030303" :background "#bdbdbd" :box nil :family "Source Code Pro for Powerline" :height 100))))
+ '(mode-line-inactive ((t (:foreground "#f9f9f9" :background "#666666" :box nil :family "Source Code Pro for Powerline" :height 100)))))
+
+
+;; enable linum-relative in programming mode
+;https://github.com/howardabrams/dot-files/blob/master/emacs.org
+(add-hook 'prog-mode-hook 'linum-mode)
+
+
+;; hight current line
+(require 'highlight-current-line)
+(highlight-current-line-on t)
+
+
+
+
+(require 'workgroups2)
+
+
+(setq wg-prefix-key (kbd "C-c z"))
+(setq wg-session-file "~/.emacs.d/.emacs_workgroups")
+(setq wg-mode-line-display-on t)          ; Default: (not (featurep 'powerline))
+(setq wg-flag-modified t)                 ; Display modified flags as well
+(setq wg-mode-line-decor-left-brace "["
+      wg-mode-line-decor-right-brace "]"  ; how to surround it
+      wg-mode-line-decor-divider ":")
+;(workgroups-mode 1)
+
+(defalias 'perl-mode 'cperl-mode)
+;(setq cperl-invalid-face nil)
+ (setq cperl-invalid-face (quote off))
+;(add-hook 'prog-mode-hook '(lambda () 
+;        (highlight-regexp "%[[:alpha:]]\\|\\\\[[:alpha:]]")))
+
+(require 'highlight-escape-sequences)
+(hes-mode)
+;(setq cperl-font-lock t)
+(put 'hes-escape-backslash-face 'face-alias 'font-lock-builtin-face)
+(put 'hes-escape-sequence-face 'face-alias 'font-lock-builtin-face)
+
+
+;(add-to-list 'load-path "~/.emacs.d/Emacs-PDE-0.2.16/lisp/")
+;(load "pde-load")                       ;
+
+(require 'init-linum)