Advertisement
TakesxiSximada

init.el

Dec 25th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 12.79 KB | None | 0 0
  1. ;; default load path
  2. ;;(defvar emacs-d (concat (getenv "HOME") "/.emacs.d/"))
  3.  
  4. ;;(setq load-path (cons “~/.emacs.d/” load-path))
  5. ;;(add-to-list ‘load-path “~/.emacs.d/site-lisp”)
  6.  
  7. ;; color theme select
  8. ;(require 'cc-mode)
  9. ;(require 'color-theme)
  10. ;(require 'menu-tree)
  11. (add-to-list 'load-path "/Users/takeshishimada/ng/home/common/twittering-mode")
  12. (add-hook 'html-helper-load-hook '(lambda () (require 'html-font)))
  13. (add-hook 'html-helper-mode "html-helper-mode" "Yay HTML" t)
  14.  
  15. ;; riece
  16. (autoload 'riece "riece" "Start Riece" t)
  17.  
  18. ;; python-mode.el
  19. (add-to-list 'load-path "/Users/takeshishimada/.emacs.d/site-lisp/python-mode.el-6.1.3")
  20. (setq py-install-directory "/Users/takeshishimada/.emacs.d/site-lisp/python-mode.el-6.1.3")
  21. (require 'python-mode)
  22. (setq py-shell-name "ipython")
  23.  
  24.  
  25. ;; c-mode style settings
  26. (setq c-default-style "k&r")
  27. (add-hook 'c-mode-command-hook
  28.       '(lambda ()
  29.          (progn
  30.            (c-toggle-hungry-style 1)
  31.            (setq c-basic-offset 4 indent-tabs-mode nil))))
  32.  
  33. (add-hook 'java-mode-command-hook
  34.       '(lambda ()
  35.          (progn
  36.            (c-toggle-hungry-style 1)
  37.            (setq c-basic-offset 4 indent-tabs-mode nil))))
  38.  
  39. (add-hook 'java-mode-hook
  40.           (lambda ()
  41.             (message "java-mode-hook!!")
  42.             (setq indent-tabs-mode nil)
  43.             (setq c-basic-offset 4)))
  44.  
  45. (add-hook 'javascript-mode-hook
  46.           (lambda ()
  47.             (message "javascript-mode-hook!!")
  48.             (setq indent-tabs-mode nil)
  49.             (setq tab-width 2)
  50.             (setq c-basic-offset 2)))
  51.  
  52. (setq auto-mode-alist
  53.       (append
  54.        '(("\\.hpp$" . c++-mode)
  55.      ("\\.h$" . c++-mode)
  56.      ("\\.ts$" . javascript-mode)
  57.      ) auto-mode-alist))
  58.  
  59. ;; settings
  60. (setq frame-title-format "%f - sakura 1.5.5.0")
  61.  
  62. (custom-set-variables
  63.  ;; custom-set-variables was added by Custom.
  64.  ;; If you edit it by hand, you could mess it up, so be careful.
  65.  ;; Your init file should contain only one such instance.
  66.  ;; If there is more than one, they won't work right.
  67.  '(column-number-mode t)
  68.  '(fringe-mode 0 nil (fringe))
  69.  '(line-number-mode t)
  70.  '(menu-bar-mode nil)
  71.  '(safe-local-variable-values (quote ((encoding . utf-8))))
  72.  '(scroll-bar-mode nil)
  73.  '(tab-width 2)
  74.  '(tool-bar-mode nil)
  75.  '(tooltip-mode nil))
  76.  
  77. (eval-after-load "color-theme"
  78.   '(progn
  79.      (color-theme-initialize)
  80.      (color-theme-midnight)
  81.      ))
  82.  
  83. (custom-set-faces
  84.  ;; custom-set-faces was added by Custom.
  85.  ;; If you edit it by hand, you could mess it up, so be careful.
  86.  ;; Your init file should contain only one such instance.
  87.  ;; If there is more than one, they won't work right.
  88.  '(mode-line ((t (:foreground "#ffffff" :background "#000000" :box (:line-width 1 :color "#000000" :style nil)))))
  89.  '(mode-line-inactive ((t (:foreground "#ffffff" :background "#000000" :box (:line-width 1 :color "#000000" :style nil)))))
  90.  '(rst-level-1-face ((t (:background "black"))) t)
  91.  '(rst-level-2-face ((t (:background "black"))) t)
  92.  '(rst-level-3-face ((t (:background "black"))) t)
  93.  '(rst-level-4-face ((t (:background "black"))) t)
  94.  '(rst-level-5-face ((t (:background "black"))) t)
  95.  '(rst-level-6-face ((t (:background "black"))) t))
  96.  
  97. ;;(set-face-foreground 'minibuffer-prompt "#111111")
  98. (set-face-background 'rst-level-1-face "black")
  99. (set-face-background 'rst-level-2-face "black")
  100. (set-face-background 'rst-level-3-face "black")
  101. (set-face-background 'rst-level-4-face "black")
  102. (set-face-background 'rst-level-5-face "black")
  103. (set-face-background 'rst-level-6-face "black")
  104.  
  105.  
  106. (require 'server)
  107. ;;(unless (server-running-p) (server-start)) ;; because macosx error
  108. (setq server-visit-hook
  109.       '(lambda ()
  110.      (raise-frame (selected-frame))
  111.      (x-forcus-frame (selected-frame))))
  112.  
  113. (setq inhibit-startup-message t)
  114. (global-set-key "\C-h" 'delete-backword-char)
  115. (keyboard-translate ?\C-h ?\C-?)
  116. (global-set-key "\C-h" nil)
  117. (global-set-key (kbd "C-x C-g") 'goto-line)
  118.  
  119. (define-key global-map [f1] 'start-kbd-macro)
  120. (define-key global-map [f2] 'end-kbd-macro)
  121. (define-key global-map [f3] 'call-last-kbd-macro)
  122. (fset 'tab-region [tab ?\C-n])
  123.  
  124.  
  125. ;; Emacs起動時にrst.elを読み込み
  126. (require 'rst)
  127. ;; 拡張子の*.rst, *.restのファイルをrst-modeで開く
  128. (setq auto-mode-alist
  129.       (append '(("\\.rst$" . rst-mode)
  130.         ("\\.rest$" . rst-mode)) auto-mode-alist))
  131. :;; 背景が黒い場合はこうしないと見出しが見づらい
  132. (setq frame-background-mode 'dark)
  133. ;; 全部スペースでインデントしましょう
  134. (add-hook 'rst-mode-hook '(lambda() (setq indent-tabs-mode nil)))
  135.  
  136. ;; macos x
  137. (setq default-input-method "MacOSX")
  138.  
  139. ;; Google日本語入力
  140. ;; (mac-set-input-method-parameter "com.goolge.inputmethod.Japanese.base" `title "あ")
  141.  
  142.  
  143. ;;; キーバインド
  144. ;(define-key global-map "\C-h" 'delete-backward-char) ; 削除
  145. ;(define-key global-map "\M-?" 'help-for-help)        ; ヘルプ
  146. ;(define-key global-map "\C-z" 'undo)                 ; undo
  147. ;(define-key global-map "\C-ci" 'indent-region)       ; インデント
  148. ;(define-key global-map "\C-c\C-i" 'dabbrev-expand)   ; 補完
  149. ;(define-key global-map "\C-c;" 'comment-region)      ; コメントアウト
  150. ;(define-key global-map "\C-c:" 'uncomment-region)    ; コメント解除
  151. ;(define-key global-map "\C-o" 'toggle-input-method)  ; 日本語入力切替
  152. ;(define-key global-map "\C-\\" nil) ; \C-\の日本語入力の設定を無効にする
  153. ;(define-key global-map "\C-c " 'other-frame)         ; フレーム移動
  154.  
  155. (put 'downcase-region 'disabled nil)
  156.  
  157.  
  158. (setq x-select-enable-clipboard t)
  159.  
  160. ;; for twitter
  161. (require 'twittering-mode)
  162. (setq twittering-account-authorization 'authorized)
  163. (setq twittering-oauth-access-token-alist
  164.       '(("oauth_token" . "")
  165.         ("oauth_token_secret" . "")
  166.         ("user_id" . "")
  167.         ("screen_name" . "")))
  168.  
  169. (setq twittering-tinyurl-service 'migre.me) ;; for mig.re
  170.  
  171.  
  172.  
  173. ;; clipboard
  174. ;(add-to-list 'load-path (concat (getenv "CLIPSS_PATH") "/emacs"))
  175. ;(require 'clipss)
  176. ;(setq clipss-path (getenv "CLIPSS_PATH") )
  177. ;(clipss-init)
  178.  
  179.  
  180. ;; 不要な空白を削除
  181. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  182.  
  183.  
  184. ;; sybows
  185. (set-language-environment "Japanese")
  186. (prefer-coding-system 'utf-8)
  187. (global-font-lock-mode 1)
  188. ; tab
  189. (setq-default tab-width 4
  190.               indent-tabs-mode nil)
  191.  
  192. ; daemon
  193. ;(server-start)
  194.  
  195. ;; auto-install
  196. ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/auto-install/"))
  197. ;; (require 'auto-install)
  198. ;; (auto-install-update-emacswiki-package-name t)
  199. ;; (auto-install-compatibility-setup)
  200.  
  201.  
  202. ;; mew
  203. (autoload 'mew "mew" nil t)
  204. (autoload 'mew-send "mew" nil t)
  205.  
  206. ;; Optional setup (Read Mail menu):
  207. (setq read-mail-command 'mew)
  208.  
  209. ;; Optional setup (e.g. C-xm for sending a message):
  210. (autoload 'mew-user-agent-compose "mew" nil t)
  211. (if (boundp 'mail-user-agent)
  212.     (setq mail-user-agent 'mew-user-agent))
  213. (if (fboundp 'define-mail-user-agent)
  214.     (define-mail-user-agent
  215.       'mew-user-agent
  216.       'mew-user-agent-compose
  217.       'mew-draft-send-message
  218.       'mew-draft-kill
  219.       'mew-send-hook))
  220.  
  221. ;; package
  222. (require 'package)
  223. ;; MELPAを追加
  224. (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
  225.  
  226. ;; Marmaladeを追加
  227. (add-to-list 'package-archives  '("marmalade" . "http://marmalade-repo.org/packages/"))
  228.  
  229. ;; 初期化
  230. (package-initialize)
  231.  
  232.  
  233. ;; ** for python **
  234. (add-hook 'python-mode-hook
  235.           (lambda ()
  236.             (c-set-offset 'statement-cont '++)
  237.             (c-set-offset 'arglist-intro '+)
  238.             (c-set-offset 'arglist-close 0)
  239.             (define-key python-mode-map "\"" 'electric-pair)
  240.             (define-key python-mode-map "\'" 'electric-pair)
  241.             (define-key python-mode-map "(" 'electric-pair)
  242.             (define-key python-mode-map "[" 'electric-pair)
  243.             (define-key python-mode-map "{" 'electric-pair)))
  244. (defun electric-pair ()
  245.   "Insert character pair without sournding spaces"
  246.   (interactive)
  247.   (let (parens-require-spaces)
  248.     (insert-pair)))
  249.  
  250. (add-hook 'python-mode-hook '(lambda ()
  251.      (define-key python-mode-map "\C-m" 'newline-and-indent)))
  252.  
  253. ;; flake8
  254. (require 'flymake-python-pyflakes)
  255. (add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
  256. (setq flymake-python-pyflakes-executable "flake8")
  257. ;(setq flymake-python-pyflakes-extra-arguments '("--ignore=W806"))
  258. ;; (custom-set-variables
  259. ;;  '(flymake-python-pyflakes-extra-arguments (quote ("--max-line-length=120" "--ignore=E128"))))
  260.  
  261.  
  262.  
  263. ;; flymake
  264. ;; setting for flymake
  265. (require 'flymake)
  266.  
  267. (global-set-key (kbd "M-e") 'flymake-goto-next-error)
  268. (global-set-key (kbd "M-E") 'flymake-goto-prev-error)
  269.  
  270. ;; Show error message under current line
  271. (require 'popup)
  272. (defun flymake-display-err-menu-for-current-line ()
  273.   (interactive)
  274.   (let* ((line-no (flymake-current-line-no))
  275.          (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))))
  276.     (when line-err-info-list
  277.       (let* ((count (length line-err-info-list))
  278.              (menu-item-text nil))
  279.         (while (> count 0)
  280.           (setq menu-item-text (flymake-ler-text (nth (1- count) line-err-info-list)))
  281.           (let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
  282.                  (line (flymake-ler-line (nth (1- count) line-err-info-list))))
  283.             (if file
  284.                 (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")"))))
  285.           (setq count (1- count))
  286.           (if (> count 0) (setq menu-item-text (concat menu-item-text "\n")))
  287.           )
  288.         (popup-tip menu-item-text)))))
  289.  
  290. ;; If you don't set :height, :bold face parameter of 'pop-tip-face,
  291. ;; then seting those default values
  292. (if (eq 'unspecified (face-attribute 'popup-tip-face :height))
  293.     (set-face-attribute 'popup-tip-face nil :height 1.0))
  294. (if (eq 'unspecified (face-attribute 'popup-tip-face :weight))
  295.     (set-face-attribute 'popup-tip-face nil :weight 'normal))
  296.  
  297. (defun my/display-error-message ()
  298.   (let ((orig-face (face-attr-construct 'popup-tip-face)))
  299.     (set-face-attribute 'popup-tip-face nil
  300.                         :height 1.5 :foreground "firebrick"
  301.                         :background "LightGoldenrod1" :bold t)
  302.     (unwind-protect
  303.         (flymake-display-err-menu-for-current-line)
  304.       (while orig-face
  305.         (set-face-attribute 'popup-tip-face nil (car orig-face) (cadr orig-face))
  306.         (setq orig-face (cddr orig-face))))))
  307.  
  308. (defadvice flymake-goto-prev-error (after flymake-goto-prev-error-display-message)
  309.   (my/display-error-message))
  310. (defadvice flymake-goto-next-error (after flymake-goto-next-error-display-message)
  311.   (my/display-error-message))
  312.  
  313. (ad-activate 'flymake-goto-prev-error 'flymake-goto-prev-error-display-message)
  314. (ad-activate 'flymake-goto-next-error 'flymake-goto-next-error-display-message)
  315.  
  316.  
  317.  
  318. ;; no backup file
  319. (setq make-backup-files nil)
  320. (setq version-control 'never)
  321.  
  322.  
  323.  
  324. ;; helm
  325. (when (require 'helm-config nil t)
  326.   (helm-mode 1)
  327.  
  328.   (define-key global-map (kbd "M-x")     'helm-M-x)
  329.   (define-key global-map (kbd "C-x C-f") 'helm-find-files)
  330.   (define-key global-map (kbd "C-x C-r") 'helm-recentf)
  331.   (define-key global-map (kbd "M-y")     'helm-show-kill-ring)
  332.   (define-key global-map (kbd "C-c i")   'helm-imenu)
  333.   (define-key global-map (kbd "C-x b")   'helm-buffers-list)
  334.  
  335.   (define-key helm-map (kbd "C-h") 'delete-backward-char)
  336.   (define-key helm-find-files-map (kbd "C-h") 'delete-backward-char)
  337.   (define-key helm-find-files-map (kbd "TAB") 'helm-execute-persistent-action)
  338.   (define-key helm-read-file-map (kbd "TAB") 'helm-execute-persistent-action)
  339.  
  340.   ;; Disable helm in some functions
  341.   (add-to-list 'helm-completing-read-handlers-alist '(find-alternate-file . nil))
  342.  
  343.   ;; Emulate `kill-line' in helm minibuffer
  344.   (setq helm-delete-minibuffer-contents-from-point t)
  345.   (defadvice helm-delete-minibuffer-contents (before helm-emulate-kill-line activate)
  346.     "Emulate `kill-line' in helm minibuffer"
  347.     (kill-new (buffer-substring (point) (field-end))))
  348.  
  349.   (defadvice helm-ff-kill-or-find-buffer-fname (around execute-only-if-exist activate)
  350.     "Execute command only if CANDIDATE exists"
  351.     (when (file-exists-p candidate)
  352.       ad-do-it))
  353.  
  354.   (defadvice helm-ff-transform-fname-for-completion (around my-transform activate)
  355.     "Transform the pattern to reflect my intention"
  356.     (let* ((pattern (ad-get-arg 0))
  357.            (input-pattern (file-name-nondirectory pattern))
  358.            (dirname (file-name-directory pattern)))
  359.       (setq input-pattern (replace-regexp-in-string "\\." "\\\\." input-pattern))
  360.       (setq ad-return-value
  361.             (concat dirname
  362.                     (if (string-match "^\\^" input-pattern)
  363.                         ;; '^' is a pattern for basename
  364.                         ;; and not required because the directory name is prepended
  365.                         (substring input-pattern 1)
  366.                       (concat ".*" input-pattern)))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement