emacsの設定ファイル[init.el]

emacsを使っているので、設定ファイルを失うとemacs-lispをスラスラと読めない私には
環境を戻すのが面倒

現在の、スパゲティ設定ファイルを保存。あぁ、恥ずかしい。

;;; ~/.emacs.d/init.el
;;;---------------------------------
;;; 基本設定
;;;---------------------------------
;; 自分でダウンロードした *.el, *.elc のディレクトリ
(setq my-site-lisp (expand-file-name "~/.emacs.d/site-lisp"))
;; my-site-lisp を load-path に追加
(add-to-list 'load-path my-site-lisp)
;; 起動メッセージを表示しない
(setq inhibit-startup-message t)
;; キャレットが '(' や ')' の直後にある場合に対応する括弧を強調
(show-paren-mode t)
;;スペースを表示
;;(global-whitespace-mode 1)
;; スペースの定義は全角スペースとする。
;;(setq whitespace-space-regexp "\x3000+")

;; 改行の色を変更
;;(set-face-foreground 'whitespace-newline "gray40")

;; 強調したくない要素を削除
;(dolist (d '(face lines space-before-tab
 ;                 indentation empty space-after-tab tab-mark))
  ;(setq whitespace-style (delq d whitespace-style)))



;; Emacs サーバを起動する
;; R だと edit や fix を実行する時に必要
(when (require 'server nil t)
  (if (not (server-running-p))
    (server-start)))

;; 日本語を utf-8 に統一
(set-language-environment "Japanese")
(setq default-buffer-file-coding-system 'utf-8)

(set-buffer-file-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;; comint-mode で重複するコマンドは履歴に保存しない
(add-hook 'comint-mode-hook
          (lambda ()
	    (setq comint-input-ignoredups t)))
		
		
		;;;---------------------------------
;;; 必須の便利機能
;;;---------------------------------
;; *.el のインストール用
(when (require 'auto-install nil t)
  (setq auto-install-directory (expand-file-name my-site-lisp))
  (if (executable-find auto-install-wget-command)
      (auto-install-update-emacswiki-package-name t)
    (message (format "Error: %s command not found." auto-install-wget-command)))
  (auto-install-compatibility-setup))


;; 補完機能の追加
(when (require 'auto-complete-config nil t)
  (global-auto-complete-mode t)
  (add-to-list 'ac-dictionary-directories (expand-file-name "~/.emacs.d/site-lisp/ac-dict"))
  (ac-config-default)
  ;; 補完候補が表示されている間のみ有効な ac-menu-map を有効にする
  ;; デフォルトで C-n, C-p が利用可能
  ;; TAB を2回押して(ac-expand が2回実行されて)補完候補が表示された時に有効にならないので(バグ?)使わない
  ;;(setq ac-use-menu-map t)
  ;; 補完候補が表示されている時に M-h を押すと即座にドキュメントが表示されるようにする
  ;; (define-key ac-completing-map (kbd "M-h") (lambda () (interactive) (ac-quick-help t))) だとダメ
  (defun ac-quick-help-force ()
    (interactive)
    (ac-quick-help t))
  (define-key ac-completing-map (kbd "M-h") 'ac-quick-help-force)
  (define-key ac-completing-map (kbd "C-n") 'ac-next)
  (define-key ac-completing-map (kbd "C-p") 'ac-previous))

;;ess
(load "~/ess-12.09/lisp/ess-site.el")
(require 'ess-site)

;;(add-to-list 'load-path "~/.emacs.d/")
;;(require 'auto-complete-config)
;;(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
;;(ac-config-default)
;;(require 'popup)
;;(require 'ess-R-object-popup)

(setq auto-mode-alist
     (cons (cons "\\.R$" 'R-mode) auto-mode-alist))
(autoload 'R-mode "ess-site" "Emacs Speaks Statistics mode" t)
(setq ess-ask-for-ess-directory nil)
(setq ess-pre-run-hook
    '((lambda ()
    (setq default-process-coding-system '(utf-8 . utf-8))
    (auto-complete-mode))))



;;; Rの設定
(global-font-lock-mode t)                                        ; S/R   TeX
(set-face-foreground 'font-lock-comment-face       "Firebrick")  ; #com  %com
(set-face-foreground 'font-lock-string-face         "SeaGreen")  ; "str" "str"
;(set-face-foreground 'font-lock-keyword-face      "MediumBlue")  ; if    \end
(set-face-foreground 'font-lock-keyword-face      "DeepSkyBlue")  ; if    \end
(set-face-foreground 'font-lock-constant-face      "VioletRed")  ; fun<- {ctr}
(set-face-foreground 'font-lock-type-face      "DarkGoldenrod")  ; T,F    ?
;(set-face-foreground 'font-lock-variable-name-face      "Blue")  ; xv
(set-face-foreground 'font-lock-variable-name-face      "DeepPink")  ; xv
(set-face-foreground 'font-lock-function-name-face "VioletRed")  ; <-    {eq1}

(setq auto-mode-alist
     (cons (cons "\\.R$" 'R-mode) auto-mode-alist))
(autoload 'R-mode "ess-site" "Emacs Speaks Statistics mode" t)
 (setq ess-ask-for-ess-directory nil)
 (setq ess-pre-run-hook
     '((lambda ()
     (setq default-process-coding-system '(utf-8 . utf-8))
     (auto-complete-mode))))
		
		
		
		
		;;;---------------------------------
;;; R & ESS の設定
;;;---------------------------------
;; パスの追加
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/ess")
;; 拡張子が r, R の場合に R-mode を起動
(add-to-list 'auto-mode-alist '("\\.[rR]$" . R-mode))
;; R-mode を起動する時に ess-site をロード
(autoload 'R-mode "ess-site" "Emacs Speaks Statistics mode" t)
;; R を起動する時に ess-site をロード
(autoload 'R "ess-site" "start R" t)


;; R-mode 起動直後の処理
;(add-hook 'R-mode-hook 'ess-load-hook)

;; R 起動直前の処理
;(add-hook 'ess-pre-run-hook (lambda () (ess-load-hook t)))


;; YaTeX
;;texファイルを起動したときには自動的にYatexモードにする
(setq auto-mode-alist 
      (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
(setq tex-command "platex-utf8")

;;ReTex自動起動
;(add-hook 'yatex-mode-hook'turn-on-reftex)
;(setq TeX-parse-sefl t)
;(setq-default TeX-master nill)

;;漢字設定(UTF8)
(setq YaTeX-kanji-code 4)

(setq load-path (cons (expand-file-name "/usr/local/share/emacs/site-lisp/yatex") load-path))
(setq tex-command "/usr/texbin/platex"   ;;"~/Library/TeXShop/bin/platex2pdf-utf8"   ; eucの場合はplatex2pdf-euc
     dvi2-command "open -a Preview")  ; Preview.appを使ってPDFを開く

(setenv "PATH" 
(concat "/usr/local/texlive/2012/bin/x86_64-darwin" (getenv "PATH"))) 
(put 'upcase-region 'disabled nil)

;;便利機能
;; ミニバッファ履歴リストの最大長:tなら無限
(setq history-length t)
;; session.el
;;   kill-ringやミニバッファで過去に開いたファイルなどの履歴を保存する
(when (require 'session nil t)
  (setq session-initialize '(de-saveplace session keys menus places)
        session-globals-include '((kill-ring 50)
                                  (session-file-alist 500 t)
                                  (file-name-history 10000)))
  (add-hook 'after-init-hook 'session-initialize)
  ;; 前回閉じたときの位置にカーソルを復帰
  (setq session-undo-check -1))
;; minibuf-isearch
;;   minibufでisearchを使えるようにする
(require 'minibuf-isearch nil t)
(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.
 '(custom-enabled-themes (quote (manoj-dark)))
 '(session-use-package t nil (session)))
(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.
 )

;;magit
(add-to-list 'load-path "~/.emacs.d/site-lisp/magit")
(require 'magit)

;;install-elispの設定--------------------------
;; まず、install-elisp のコマンドを使える様にします。
(require 'install-elisp)
;; 次に、Elisp ファイルをインストールする場所を指定します。
(setq install-elisp-repository-directory "~/.emacs.d/site-lisp/")

;;Ruby-modeの設定----------------
(autoload 'ruby-mode "ruby-mode"                                                        
  "Mode for editing ruby source files" t)                                               
(setq auto-mode-alist                                                                   
      (append '(("\\.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)))                                                           
(global-font-lock-mode 1)                                                               
(setq default-frame-alist                                                               
      (append                                                                           
       '((foreground-color . "gray")  ;                                                 
         (background-color . "black") ;                                                 
         (cursor-color     . "blue")  ;                                                                                                 
	 )                                                                               
       default-frame-alist))                                                                  


;;ruby smart0compile.el
;;(load "~/.emacs.d/site-lisp/smart-compile.el")
;;(require 'smart-compile)
;;(define-key ruby-mode-map (kbd "C-c c") 'smart-compile)
;;(define-key ruby-mode-map (kbd "C-c C-c") (kbd "C-c c C-m"))

(setq c-basic-offset 8)