archan’s emacs 20022014

February 20, 2014

;; emacs 18022014

;; add package repository and install missing packages
(require 'package)
(setq package-archives '(("melpa" . "")))
(setq package-list '(autopair dart-mode flymake-cursor flymake-google-cpplint flymake-python-pyflakes flymake-easy google-c-style jedi-direx direx jedi auto-complete epc ctable concurrent deferred pony-mode popup web-mode))
;; find : C-h v package-activated-list
(when (not package-archive-contents)
(dolist (package package-list)
  (when (not (package-installed-p package))
    (package-install package)))

;; default customization
 '(inhibit-splash-screen t)
 '(inhibit-startup-message t)
 '(tool-bar-mode nil)
 '(column-number-mode t)
 '(cua-mode 1 nil (cua-base))
 '(global-font-lock-mode 1)
 '(global-linum-mode t)
 '(ido-mode t nil (ido))
 '(make-backup-files nil)
 '(show-paren-mode t)

;; set all windows (emacs's “frames”) to some defaults
(setq initial-frame-alist '((width . 100) (height . 54)))
(setq default-frame-alist
      '((menu-bar-lines . 1)
        (tool-bar-lines . 0)
        (width . 100)
        (height . 52)
(set-frame-parameter nil 'font "Dejavu Sans Mono-9")
(global-hl-line-mode 1)
;(load-theme 'misterioso)
(set-face-background 'highlight "white smoke")

;; Prevent accidentally killing emacs.
(global-set-key [(control x) (control c)]
  '(lambda ()
     (if (y-or-n-p-with-timeout "Exit Emacs ? " 4 nil)

;; enable autopairing
(require 'autopair)
(setq autopair-autowrap t)

;; custom key-bindings
(define-key global-map (kbd "RET") 'newline-and-indent)
(global-set-key "\M-l" 'goto-line)
(global-set-key (kbd "<f2>") 'save-buffer)
(global-set-key (kbd "<f10>") 'switch-to-buffer)
(global-set-key (kbd "<f11>") 'next-buffer)
(global-set-key (kbd "<f12>") 'prev-window)
(defun prev-window ()
   (other-window -1))

;; text-mode hooks
(add-hook 'text-mode-hook 'text-file-handle)
(defun text-file-handle()
  (set-fill-column 80)
  (setq indent-tabs-mode nil )
  (setq tab-width 4 )

;; python-mode hooks
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-hook 'python-mode-hook 'python-file-handle)
(defun python-file-handle()
  ; remove whitespaces
  (add-hook 'before-save-hook 'delete-trailing-whitespace)
  ; python indentation
  (setq indent-tabs-mode t)
  (setq tab-width (default-value 'tab-width))
; flymake-python-pyflakes
(require 'flymake-python-pyflakes)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
(setq flymake-python-pyflakes-executable "flake8")
; python-jedi auto-complete
(require 'jedi)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
; flymake faces
 '(flymake-errline ((((class color)) (:background "ivory1"))))
 '(flymake-warnline ((((class color)) (:background "ivory2")))))

;; dart-mode hooks
(require 'dart-mode)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
(add-hook 'dart-mode-hook 'dart-file-handle)
(defun python-file-handle()