Skip to content

Instantly share code, notes, and snippets.

@ainame
Created September 20, 2011 18:44
Show Gist options
  • Save ainame/1229927 to your computer and use it in GitHub Desktop.
Save ainame/1229927 to your computer and use it in GitHub Desktop.
;;; Time-stamp: <2011-09-19 19:59:30 namai>
;;ファイル保存時にコンパイル
(add-hook 'after-save-hook
(function (lambda ()
(if (string= (expand-file-name "~/.emacs")
(buffer-file-name))
(save-excursion
(byte-compile-file (expand-file-name "~/.emacs")))))))
(add-to-list 'load-path "~/.emacs.d/elisp/")
;; auto-install
(setq auto-install-directory "~/.emacs.d/auto-install/")
(add-to-list 'load-path auto-install-directory)
(add-to-list 'load-path (expand-file-name "~/.emacs.d/auto-install"))
;;(add-to-list 'custom-theme-load-path "~/.emacs.d/elisp/")
(require 'auto-install)
;;(auto-install-update-emacswiki-package-name t)
;(auto-install-compatibility-setup)
;(setq ediff-window-setup-function 'ediff-setup-window-plain)
;; C-h
(global-set-key (kbd "C-h") 'delete-backward-char)
;; forward-word
;;(global-set-key (kbd "C-f") 'forward-word)
;;(global-set-key (kbd "C-b") 'backward-word)
;; *scratch*のメッセージを消す
(setq initial-scratch-message nil)
;;; ホイールマウス
(mouse-wheel-mode t)
(setq mouse-wheel-follow-mouse t)
;;; 対応する括弧を光らせる。
(show-paren-mode 1)
;;; バックアップファイルを作らない
(setq backup-inhibited t)
;;; 終了時にオートセーブファイルを消す
(setq delete-auto-save-files t)
;;; emacs -nw で起動した時にメニューバーを消す
(if window-system (menu-bar-mode 1) (menu-bar-mode -1))
;;; 現在の関数名をモードラインに表示
(which-function-mode 1)
;;coolな行ハイライト
(global-hl-line-mode t)
(set-face-background 'hl-line "black")
;;; Time stamp
;;; ファイルの中で最初に表れる「Last modified:」という文字列が
;;; あったらそこに「曜日 月 日 時間 年 タイムゾーン」の順にタイムスタンプ
(require 'time-stamp)
(if (not (memq 'time-stamp write-file-functions))
(setq write-file-functions
(cons 'time-stamp write-file-functions)))
;; ruby-mode等
(add-to-list 'load-path "~/.emacs.d/elisp/ruby-mode")
(autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t)
;;(setq auto-mode-alist (cons '("\\.rb$" . ruby-mode) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist))
(autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys)))
;;ruby-electric.el
(require 'ruby-electric)
(add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t)))
;; set ruby-mode indent
(setq ruby-indent-level 2)
(setq ruby-indent-tabs-mode nil)
;; Interactively Do Things (highly recommended, but not strictly required)
(require 'ido)
(ido-mode t)
;; Rinari
(add-to-list 'load-path "~/.emacs.d/elisp/rinari")
(require 'rinari)
;;; rhtml-mode
(add-to-list 'load-path "~/.emacs.d/elisp/rhtml")
(require 'rhtml-mode)
(setq auto-mode-alist (cons '("\\.erb$" . rhtml-mode) auto-mode-alist))
(add-hook 'rhtml-mode-hook
(lambda () (rinari-launch)))
(require 'slim-mode)
;;shell-mode
(require 'multi-term)
(setq multi-term-program shell-file-name)
;;(add-to-list 'term-unbind-key-list '"M-x")
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(global-set-key (kbd "C-c t") '(lambda ()
(interactive)
(multi-term)))
(add-hook 'term-mode-hook
'(lambda ()
;; C-h を term 内文字削除にする
(define-key term-raw-map (kbd "C-h") 'term-send-backspace)
;; C-y を term 内ペーストにする
(define-key term-raw-map (kbd "C-y") 'term-paste)))
(require 'shell-pop)
;; multi-term に対応
(add-to-list 'shell-pop-internal-mode-list '("multi-term" "*terminal<1>*" '(lambda () (multi-term))))
(shell-pop-set-internal-mode "multi-term")
;; 25% の高さに分割する
(shell-pop-set-window-height 50)
(shell-pop-set-internal-mode-shell shell-file-name)
;; ショートカットも好みで変更してください
(global-set-key (kbd "C-x t") 'shell-pop)
(put 'downcase-region 'disabled nil)
;; dired-x
(require 'dired-x)
;; リネームが便利にwdired
(require 'wdired)
(define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
;; termでバッファ間の共有がしたい
;; (add-hook 'term-mode-hook '(lambda ()
;; (define-key term-raw-map "\C-y" 'term-paste)
;; (define-key term-raw-map "\C-q" 'move-beginning-of-line)
;; (define-key term-raw-map "\C-r" 'term-send-raw)
;; (define-key term-raw-map "\C-s" 'term-send-raw)
;; (define-key term-raw-map "\C-f" 'forward-char)
;; (define-key term-raw-map "\C-b" 'backward-char)
;; (define-key term-raw-map "\C-t" 'set-mark-command)
;; (define-key term-raw-map (kbd "ESC") 'term-send-raw)
;; (define-key term-raw-map [delete] 'term-send-raw)
;; (define-key term-raw-map "\C-z"
;; (lookup-key (current-global-map) "\C-z"))))
;;; バックアップファイルを作らない
(setq backup-inhibited t)
;;; 終了時にオートセーブファイルを消す
(setq delete-auto-save-files t)
;; gist
(require 'gist)
(load "dark-theme")
;; るりまサーチ
(defun rurema-search ()
(interactive)
(let ((word (read-from-minibuffer "search word:")))
(browse-url (format "http://rurema.clear-code.com/query:%s/" word))))
(defalias 'r 'rurema-search)
;; cperl-mode
(defalias 'perl-mode 'cperl-mode)
(setq auto-mode-alist (cons '("\\.t$" . cperl-mode) auto-mode-alist))
(add-hook 'cperl-mode-hook
(function (lambda ()
(set-face-background 'cperl-hash-face "black")
(set-face-background 'cperl-array-face "black")
)))
;; cmigemo
(require 'migemo)
(if (not window-system)
(progn (setq migemo-command "cmigemo")
(setq migemo-options '("-q" "--emacs"))
(setq migemo-dictionary "/usr/local/share/migemo/utf-8/migemo-dict")
(setq migemo-user-dictionary nil)
(setq migemo-regex-dictionary nil)
(setq migemo-coding-system 'utf-8-unix)
(load-library "migemo")
(migemo-init)
(set-process-query-on-exit-flag migemo-process nil)))
;; anything.el
(require 'anything)
;;auto-complete
(add-to-list 'load-path "~/.emacs.d/elisp/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elisp/ac-dict")
(ac-config-default)
(setq ac-auto-start nil)
(ac-set-trigger-key "TAB")
;;gcccsense
(require 'gccsense)
;; (add-hook 'c++-mode-common-hook
;; (lambda ()
;; (local-set-key (kbd "\C-c.") 'ac-complete-gccsense)))
(define-key global-map "\C-]" 'ac-complete-gccsense)
;; ;;rsense
;; (setq rsense-home (expand-file-name "~/.emacs.d/elisp/rsense"))
;; (add-to-list 'load-path (concat rsense-home "/etc"))
;; (require 'rsense)
;; ;; C-c .で補完
;; (add-hook 'ruby-mode-hook
;; (lambda ()
;; (local-set-key (kbd "C-c .") 'ac-complete-rsense)))
;; (add-hook 'ruby-mode-hook
;; (lambda ()
;; (add-to-list 'ac-sources 'ac-source-rsense-method)
;; (add-to-list 'ac-sources 'ac-source-rsense-constant)))
;; org-modeの初期化
(require 'org-install)
;; キーバインドの設定
(setq org-startup-truncated nil)
(setq org-return-follows-link t)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(org-remember-insinuate)
(setq org-directory "~/workspace/memo/")
(setq org-default-notes-file (concat org-directory "agenda.org"))
(setq org-remember-templates
'(("Todo" ?t "** TODO %?\n %i\n %a\n %t" nil "Inbox")
("Bug" ?b "** TODO %? :bug:\n %i\n %a\n %t" nil "Inbox")
("Idea" ?i "** %?\n %i\n %a\n %t" nil "New Ideas")
))
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(define-key global-map "\C-cr" 'org-remember)
;; org-modeでの強調表示を可能にする
(add-hook 'org-mode-hook 'turn-on-font-lock)
;; Flymake
(require 'flymake)
;; (defun flymake-cc-init ()
;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
;; 'flymake-create-temp-inplace))
;; (local-file (file-relative-name
;; temp-file
;; (file-name-directory buffer-file-name))))
;; (list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
;; (push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks)
;; (add-hook 'c++-mode-hook
;; '(lambda ()
;; (flymake-mode t)))
(add-hook 'c++-mode-common-hook
(lambda ()
(flymake-mode)
(gccsense-flymake-setup)))
(setq flymake-growl-warning-priority 1)
(setq flymake-growl-error-priority 2)
(setq flymake-growl-warning-sticky t)
(setq flymake-growl-error-sticky t)
(setq flymake-growl-sticky-list nil)
(defun flymake-growl-notify (file line-no message priority sticky)
(let* ((title (concat file ":" (int-to-string line-no) ":"))
(command (concat "growlnotify --appIcon Emacs"
" -H localhost"
" --progress 0.1"
" --title \"" title "\""
" --identifier \"" title "\""
" --message \"" message "\""
" --priority " (int-to-string priority))))
(shell-command (concat command (if sticky " --sticky")))
(if sticky (add-to-list 'flymake-growl-sticky-list (list file line-no message priority)))))
(defun flymake-growl-delete-notify (buffer-name)
(interactive "b")
(let ((sticky-list flymake-growl-sticky-list))
(setq flymake-growl-sticky-list nil)
(mapc (lambda (sticky)
(if (string= buffer-name (car sticky))
(apply 'flymake-growl-notify (append sticky '(nil)))
(add-to-list 'flymake-growl-sticky-list sticky)))
sticky-list)))
(defun flymake-growl-delete-all-notify ()
(interactive)
(mapc (lambda (sticky)
(apply 'flymake-growl-notify (append sticky '(nil))))
flymake-growl-sticky-list)
(setq flymake-growl-sticky-list nil))
(defun flymake-growl-rename-notify (old-name new-name)
(mapc (lambda (sticky)
(when (string= old-name (car sticky))
(flymake-growl-delete-notify old-name)
(flymake-growl-notify new-name
(nth 1 sticky)
(nth 2 sticky)
(nth 3 sticky)
t)))
flymake-growl-sticky-list))
(defadvice flymake-make-overlay (after flymake-growl-make-overlay activate)
(let* ((face (ad-get-arg 3))
(priority (case face
('flymake-warnline flymake-growl-warning-priority)
('flymake-errline flymake-growl-error-priority)
(t 0)))
(sticky (case face
('flymake-warnline flymake-growl-warning-sticky)
('flymake-errline flymake-growl-error-sticky)
(t nil))))
(flymake-growl-notify (buffer-name) line-no (ad-get-arg 2) priority sticky)))
(defadvice flymake-delete-own-overlays (after flymake-growl-delete-own-overlays activate)
(flymake-growl-delete-notify (buffer-name)))
(defadvice kill-buffer (before flymake-growl-kill-buffer activate)
(flymake-growl-delete-notify (buffer-name)))
(add-hook 'kill-emacs-hook 'flymake-growl-delete-all-notify)
(defadvice rename-buffer (around flymake-growl-rename-buffer activate)
(let ((old-name (buffer-name))
new-name)
ad-do-it
(setq new-name (buffer-name))
(flymake-growl-rename-notify old-name new-name)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment