Skip to content

Instantly share code, notes, and snippets.

@fukubaya
Last active January 18, 2017 18:32
Show Gist options
  • Save fukubaya/b9ca57cddaf5f9ac2936a9062b13e5c9 to your computer and use it in GitHub Desktop.
Save fukubaya/b9ca57cddaf5f9ac2936a9062b13e5c9 to your computer and use it in GitHub Desktop.
emacs configuration at 2017/01/06
;; -*- coding: utf-8 -*-
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
;; MELPA
(add-to-list 'package-archives '("melpa"."http://melpa.org/packages/") t)
;; スタートアップメッセージの禁止
(setq inhibit-startup-message t)
;; ツールバーは不要
(tool-bar-mode 0)
;; 配色
(set-background-color "black")
(set-foreground-color "white")
;; 行間を開ける
(add-to-list 'default-frame-alist '(line-spacing . 0))
;; 透明度
(add-to-list 'default-frame-alist '(alpha . (0.8 0.7)))
;; scroll-barを右につける
(set-scroll-bar-mode 'right)
;; line-numberを表示する
(line-number-mode t)
(global-linum-mode t)
;; フォント設定など
(if (eq window-system 'ns)
(progn
;; フォントの設定
;; http://leadproject.web.fc2.com/FC2/Unix_App_on_Lion_files/emacs.pdf
(when (>= emacs-major-version 23)
(set-face-attribute 'default nil :family "monaco" :height 140)
(set-fontset-font
(frame-parameter nil 'font)
'japanese-jisx0208
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font
(frame-parameter nil 'font)
'japanese-jisx0212
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font
(frame-parameter nil 'font)
'mule-unicode-0100-24ff
'("monaco" . "iso10646-1"))
(setq face-font-rescale-alist
'(("^-apple-hiragino.*" . 1.2)
(".*osaka-bold.*" . 1.2)
(".*osaka-medium.*" . 1.2)
(".*courier-bold-.*-mac-roman" . 1.0)
(".*monaco cy-bold-.*-mac-cyrillic" . 0.9) (".*monaco-bold-.*-mac-roman" . 0.9)
("-cdac$" . 1.3))))))
;; autoinsert
(load "autoinsert")
(auto-insert-mode t)
(add-hook 'file-file-hook 'auto-insert)
(setq auto-insert-alist
(append '(
("\\.htm" . "html-insert.html")
("\\.html" . "html-insert.html")
("\\.py$" . ["default.py" my-template])
("\\.js$" . ["default.js" my-template])
) auto-insert-alist))
(setq auto-insert-directory "~/.emacs.d/insert/")
;; autoinsert: テンプレート
;; from http://d.hatena.ne.jp/higepon/20080731/1217491155
(defvar template-replacements-alists
'(("%file%" . (lambda () (file-name-nondirectory (buffer-file-name))))
("%file-without-ext%" . (lambda () (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))))
("%year%" . (lambda () (format-time-string "%Y" (current-time))))
("%author-name%" . (lambda () (format "FUKUBAYASHI Yuichiro")))
("%date%" . (lambda () (format-time-string "%Y/%02m/%02d" (current-time))))
("%date-time%" . (lambda () (format-time-string "%Y/%02m/%02d %02H:%02M:%02S" (current-time))))
))
(defun my-template ()
(time-stamp)
(mapc #'(lambda(c)
(progn
(goto-char (point-min))
(replace-string (car c) (funcall (cdr c)) nil)))
template-replacements-alists)
(goto-char (point-max))
(message "done."))
(add-hook 'find-file-not-found-hooks 'auto-insert)
;;backup-files
(setq make-backup-files t)
(defun make-backup-file-name (filename)
(expand-file-name
(concat ; backup-file名を
"~/.emacs-backup/" ; ~/.emacs-backup/filename~にする
(file-name-nondirectory filename)
"~")
(file-name-directory filename)))
;; SKK
;; SKK: default-input-method
(setq default-input-method "japanese-skk")
;; SKK:自動ロードの設定
(autoload 'skk-mode "skk" nil t)
(autoload 'skk-auto-fill-mode "skk" nil t)
(autoload 'skk-tutorial "skk-tut" nil t)
(autoload 'skk-check-jisyo "skk-tools" nil t)
(autoload 'skk-merge "skk-tools" nil t)
(autoload 'skk-diff "skk-tools" nil t)
(autoload 'skk-isearch-mode-setup "skk-isearch" nil t)
(autoload 'skk-isearch-mode-cleanup "skk-isearch" nil t)
;; SKK:isearch モードのフック変更
(add-hook 'isearch-mode-hook
(function (lambda ()
(and (boundp 'skk-mode) skk-mode
(skk-isearch-mode-setup)))))
(add-hook 'isearch-mode-end-hook
(function (lambda ()
(and (boundp 'skk-mode) skk-mode
(skk-isearch-mode-cleanup)))))
;; SKK:キーバインド
(global-set-key "\C-x\C-j" 'skk-mode)
(global-set-key "\C-xj" 'skk-auto-fill-mode)
;; SKK: メッセージおよびエラー出力を日本語で行う
(setq skk-japanese-message-and-error t)
;; SKK: 日付表示("@")に関する設定
(setq skk-date-ad t) ;; 西暦表示
;; SKK: 数字には1バイト文字を利用
(setq skk-number-style nil)
;; auto-complete
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-modes 'sh-mode)
(add-to-list 'ac-modes 'js2-mode)
;; js2-mode
(setq-default c-basic-offset 4)
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;; shell-script-mode
(add-hook 'sh-mode-hook 'flycheck-mode)
(add-hook 'sh-mode-hook
(lambda ()
(sh-set-shell "bash")))
;; flycheck
(require 'flycheck)
(setq-default flycheck-sh-shellcheck-executable "/usr/local/bin/shellcheck")
(set-face-attribute 'flycheck-error nil :background "red")
(set-face-attribute 'flycheck-warning nil :background "yellow")
(set-face-attribute 'flycheck-info nil :background "dark cyan")
;; rainbow-delimiters
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;; 括弧の色を強調する設定
;; http://qiita.com/megane42/items/ee71f1ff8652dbf94cf7
(require 'cl-lib)
(require 'color)
(defun rainbow-delimiters-using-stronger-colors ()
(interactive)
(cl-loop
for index from 1 to rainbow-delimiters-max-face-count
do
(let ((face (intern (format "rainbow-delimiters-depth-%d-face" index))))
(cl-callf color-saturate-name (face-foreground face) 30))))
(add-hook 'emacs-startup-hook 'rainbow-delimiters-using-stronger-colors)
;;
(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.
'(package-selected-packages
(quote
(rainbow-delimiters highlight-symbol git-gutter+ auto-complete flycheck js2-mode ddskk))))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment