メンバー > SGHR > ある日の.emacs

  1. ;; キーバインド
  2. (define-key global-map "\C-h" 'delete-backward-char) ; 削除
  3. (define-key global-map "\C-z" 'scroll-down) ; scroll-down
  4. (define-key global-map "\C-q" 'query-replace) ; 置換
  5. (define-key global-map "\C-xl" 'goto-line) ; 指定行に移動
  6. (define-key global-map "\C-xr" 'replace-regexp) ; 一括置換
  7. (define-key global-map "\C-xi" 'indent-region) ; regionをindent
  8. (define-key global-map "\C-xs" 'shell) ; shell起動
  9. (define-key global-map "\C-xp" 'compile) ; コンパイル
  10. (define-key global-map "\C-xf" 'occur) ; 検索
  11. (define-key global-map "\C-xg" 'rgrep) ; ディレクトリ以下を再帰的に検索
  12. (define-key global-map "\C-xu" 'revert-buffer) ; 更新
  13. (define-key global-map "\C-xd" 'delete-trailing-whitespace) ; 行末の空白削除
  14. (define-key global-map [C-tab] 'other-window) ; window移動
  15. (global-set-key "\C-x\C-b" 'buffer-menu) ; buffer-menuをその場で開く
  16.  
  17. ;; mozc
  18. (require 'mozc)
  19. (setq default-input-method "japanese-mozc")
  20.  
  21. ;; \C-lで現在行を移動する
  22. (setq recenter-positions '(top middle bottom))
  23.  
  24. ;; フォント
  25. (set-face-attribute 'default nil
  26. :family "RictyDiminished"
  27. :height 120)
  28.  
  29. ;; タイトルバーにファイルのフルパスを表示
  30. (setq frame-title-format "%f")
  31.  
  32. ;; 行番号を表示する
  33. (global-linum-mode t)
  34.  
  35. ;; 起動時の画面はいらない
  36. (setq inhibit-startup-message t)
  37. (setq initial-scratch-message "")
  38.  
  39. ;; リージョンを色付け
  40. (setq transient-mark-mode t)
  41. (setq highlight-nonselected-windows t)
  42.  
  43. ;; 現在行をハイライト
  44. (if window-system (global-hl-line-mode t))
  45. (if window-system (set-face-background 'hl-line "#112233"))
  46.  
  47. ;; 対応する括弧をハイライト
  48. (show-paren-mode t)
  49. (setq show-paren-style 'mixed)
  50.  
  51. ;; 保存時に行末の空白を削除
  52. ;(add-hook 'before-save-hook 'delete-trailing-whitespace)
  53.  
  54. ;; whitespace
  55. (require 'whitespace)
  56. (setq whitespace-style
  57. '(face ; faceで可視化
  58. trailing ; 行末
  59. tabs ; タブ
  60. empty ; 先頭/末尾の空行
  61. space-mark ; 表示のマッピング
  62. tab-mark
  63. ))
  64. (setq whitespace-display-mappings
  65. '((tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])))
  66. (global-whitespace-mode 1)
  67.  
  68. ;; インデントの設定
  69. (setq-default c-basic-offset 4
  70. tab-width 4
  71. indent-tabs-mode nil)
  72.  
  73. ;; 矩形選択
  74. (cua-mode t)
  75. (setq cua-enable-cua-keys nil)
  76.  
  77. ;; 初期フレームの設定
  78. (setq initial-frame-alist
  79. (append
  80. '((top . 45) ; フレームの Y 位置(ピクセル数)
  81. (left . 250) ; フレームの X 位置(ピクセル数)
  82. (width . 162) ; フレーム幅(文字数)
  83. (height . 58) ; フレーム高(文字数)
  84. )
  85. initial-frame-alist))
  86.  
  87. ;; \C-x@で横に3分割
  88. (defun split-window-horizontally-n (num_wins)
  89. (interactive "p")
  90. (if (= num_wins 2)
  91. (split-window-horizontally)
  92. (progn
  93. (split-window-horizontally
  94. (- (window-width) (/ (window-width) num_wins)))
  95. (split-window-horizontally-n (- num_wins 1)))))
  96. (global-set-key "\C-x@" '(lambda ()
  97. (interactive)
  98. (split-window-horizontally-n 3)))
  99.  
  100. ;; 起動時に2分割
  101. (if window-system
  102. (add-hook 'after-init-hook (lambda()
  103. (interactive)
  104. (split-window-horizontally-n 2))))
  105.  
  106. ;; shell-modeで矢印キーの上下でコマンド履歴を表示
  107. (setq shell-mode-hook
  108. (function (lambda ()
  109. (define-key shell-mode-map [up] 'comint-previous-input)
  110. (define-key shell-mode-map [down] 'comint-next-input))))
  111.  
  112. ;; 背景
  113. (set-background-color "Black")
  114. (set-foreground-color "White")
  115. (set-cursor-color "Gray")
  116. (set-frame-parameter nil 'alpha 80)
  117.  
  118. ;; バックアップを作らない
  119. (setq backup-inhibited t)
  120.  
  121. ;; オートセーブファイルを作らない
  122. (setq auto-save-default nil)
  123.  
  124. ;; 終了時にオートセーブファイルを消す
  125. ;(setq delete-auto-save-files t)
  126.  
  127. ;; ファイルに間違いがあれば無効
  128. (custom-set-variables
  129. '(ediff-window-setup-function (quote ediff-setup-windows-plain))
  130. '(inhibit-startup-screen t))
  131.  
  132. ;; yes or noをy or n
  133. (fset 'yes-or-no-p 'y-or-n-p)
  134.  
  135. ;; ファイル名が同じならバッファ名にディレクトリ名を追加
  136. (require 'uniquify)
  137. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  138.  
  139. ;; GCを減らす
  140. (setq gc-cons-threshold (* 10 gc-cons-threshold))
  141.  
  142. ;; 1行ずつスクロール
  143. (setq scroll-conservatively 35
  144. scroll-margin 0
  145. scroll-step 1)
  146. (setq comint-scroll-show-maximum-output t) ;; shell-mode
  147.  
  148. ;; wsgiファイルをpython-mode
  149. (setq auto-mode-alist
  150. (append '(("\\.wsgi$" . python-mode)) auto-mode-alist))
  151.  
  152. ;; パッケージ管理
  153. (require 'package)
  154. (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
  155. (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
  156. (package-initialize)
  157.  
  158. ;; auto-complete
  159. (require 'auto-complete-config)
  160. (ac-config-default)
  161. (setq ac-auto-start nil)
  162. (ac-set-trigger-key "\C-o")
  163. (setq ac-use-menu-map t) ; 補完メニュー表示時にC-n/C-pで補完候補選択
  164.  
  165. ;; jedi
  166. ;(require 'epc)
  167. ;(require 'python)
  168. ;(require 'jedi)
  169. ;(add-hook 'python-mode-hook 'auto-complete-mode)
  170. ;(add-hook 'python-mode-hook 'jedi:setup)
  171. ;(define-key python-mode-map (kbd "\C-o") 'jedi:complete)
  172. ;(setq jedi:complete-on-dot t)
  173.  
  174. ;; magit
  175. (require 'magit)
  176. (set-face-foreground 'magit-blame-heading "yellow")
  177.  
  178. ;; markdown-mode
  179. ;(autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
  180. ;(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist))
  181.  
  182. ;; python-modeで80文字を超えていたらハイライト
  183. (add-hook 'python-mode-hook
  184. (lambda ()
  185. (font-lock-add-keywords nil '(("^[^\n]\\{80\\}\\(.*\\)$" 1 font-lock-warning-face t)))))
最終更新:2015年09月27日 23:27