Skip to content

Instantly share code, notes, and snippets.

@caiorss
Forked from zonuexe/init.el
Last active August 29, 2015 14:24
Show Gist options
  • Save caiorss/a0a96aad2e55138a1905 to your computer and use it in GitHub Desktop.
Save caiorss/a0a96aad2e55138a1905 to your computer and use it in GitHub Desktop.
;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
;; for Emacs 24
;;; modes(UI)
(tool-bar-mode -1)
(when (and window-system (>= emacs-major-version 23))
(set-face-attribute 'default nil
:family "Migu 2M"
:height 160))
(load-theme 'manoj-dark t)
;;; variables
(set-language-environment 'Japanese)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-keyboard-coding-system 'utf-8)
(custom-set-variables
'(init-loader-show-log-after-init t)
'(inhibit-startup-message nil))
;;; macros
(defmacro require-with (name &rest body)
(declare (indent 1))
(let ((require-state `(require ,name nil t)))
(cond
(body `(when ,require-state ,@body))
(t require-state))))
(defmacro pkg-sync (name &optional require &rest body)
(declare (indent 1))
(let* ((is-require (eq require 'require))
(install-state
`(unless (package-installed-p ,name)
(package-install ,name)))
(when-state
(cond
(is-require `(require-with ,name ,@body))
(body `(progn ,@body))
(t '())))
(output
(cond
(when-state `(progn ,install-state ,when-state))
(t install-state))))
output))
(defmacro el-sync (name &optional require &rest body)
(declare (indent 1))
(let* ((is-require (eq require 'require))
(install-state `(el-get 'sync ,name))
(when-state
(cond
(is-require `(require-with ,name ,@body))
(body `(progn ,@body))
(t '())))
(output
(cond
(when-state `(progn ,install-state ,when-state))
(t install-state))))
output))
;;; package
(when (require 'package nil t)
(when (< emacs-major-version 24)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-refresh-contents)
(pkg-sync 'exec-path-from-shell
(require 'exec-path-from-shell nil t)
(exec-path-from-shell-initialize))
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch)
(goto-char (point-max))
(eval-print-last-sexp))))
(el-get 'sync)
;;; helm
(el-sync 'helm
(when (require 'helm-mode nil t)
(helm-mode t))
;;; development
(setq vc-handled-backends ())
(el-sync 'magit require
(eval-after-load 'magit
'(progn
(set-face-foreground 'magit-diff-add "green3")
(set-face-foreground 'magit-diff-del "red3")
(when (not window-system)
(set-face-background 'magit-item-highlight "white"))))
(global-set-key (kbd "C-x m") 'magit-status))
;;; languages
;; Emacs Lisp
(when (require 'eldoc nil t)
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode))
(el-sync 'paredit
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)
(add-hook 'lisp-interacton-mode-hook 'enable-paredit-mode))
;;; keybind
(cond
((eq window-system 'ns)
(global-set-key (kbd "M-¥") (lambda () (interactive) (insert "¥")))
(global-set-key (kbd "¥") (lambda () (interactive) (insert "\\")))))
(mapcar (lambda (k)
(global-set-key
(read-kbd-macro (concat "C-c " "<" k ">"))
(intern (concat "windmove-" k))))
'("right" "left" "up" "down"))
;;; modes
(show-paren-mode t)
(setq-default
tab-width 4
indent-tabs-mode nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment