;================================================================
; いろいろな設定
;================================================================
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)

(global-font-lock-mode t) ;文字装飾(カラー強調)
(setq-default transient-mark-mode t) ;リージョンのハイライト

(setq require-final-newline t)  ;最後に改行を追加

;; stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)

(when window-system
  (mwheel-install)   ;enable wheelmouse support by default
;; use extended compound-text coding for X clipboard
  (set-selection-coding-system 'compound-text-with-extensions)
)

(global-set-key [(ctrl z)] 'undo)  ;undoの設定

;; 起動時の画面を非表示にする
(setq inhibit-startup-message t)

;; load pathの追加
(setq load-path (append (list
                         (expand-file-name "/usr/local/share/emacs/site-lisp")
                         )
                        load-path))

(setq load-path (append (list
			 (expand-file-name "/usr/share/emacs/22.1/site-lisp")
                         )
                        load-path))
(setq load-path (append (list
                         (expand-file-name "/usr/share/emacs/site-lisp")
                         )
                        load-path))
;================================================================
; モードの設定
;================================================================
(setq auto-mode-alist
      (append
       '(
	 ("\\.h$"    . c++-mode)
	 ("\\.txt$"  . text-mode)
	 ("\\.htm" . html-mode)
	 ("\\.html$" . html-mode)
	 ("\\.php" . php-mode)
	 ) auto-mode-alist))

;================================================================
; ATOK for linx の設定
;===============================================================
(set-language-environment "japanese")  ;; 日本語環境の設定
(set-default-coding-systems 'euc-japan)
(set-terminal-coding-system 'euc-japan)
(set-keyboard-coding-system 'euc-japan)

(setq emacs-ime "atokx2")
(if  (equal emacs-ime "atokx2")
    (progn
      (require 'un-define)      
      (setq coding-category-utf-8 'utf-8)

      (setq iiimcf-server-control-hostlist '("localhost"))
      (setq iiimcf-server-control-default-language "ja")
      (setq default-input-method 'iiim-server-control)
      (require 'iiimcf-sc)

      (define-key global-map [?\S- ] 'toggle-input-method)
      (setcar default-mode-line-format "")

    )
)


;================================================================
; cssモード
;================================================================
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
      (cons '("\\.css\\'" . css-mode) auto-mode-alist))
(setq cssm-indent-function #'cssm-c-style-indenter)
(add-hook 'css-mode-hook
	  '(lambda ()
	     (define-key cssm-mode-map (read-kbd-macro "M-j") 'cssm-complete-property)))
(setq cssm-indent-function #'cssm-c-style-indenter)

;================================================================
; mmm-mode in php
;================================================================
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class nil "\\.php?\\'" 'html-php)
(mmm-add-classes
    '((html-php
    :submode php-mode
    :front "<\\?\\(php\\)?"
    :back "\\?>")))
(add-to-list 'auto-mode-alist '("\\.php?\\'" . php-mode)
	     (set-face-background 'mmm-default-submode-face nil))

(mmm-add-classes
 '((embedded-css
    :submode css-mode
    :front "<style[^>]*>"
    :back "</style>")))
(mmm-add-mode-ext-class nil "\\.php\\'" 'embedded-css)

;================================================================
; PHPの設定
;        http://itpro.nikkeibp.co.jp/article/COLUMN/20070219/262441/
;================================================================
(add-hook 'php-mode-user-hook
'(lambda ()
   (c-set-style "stroustrup")
   (c-set-offset 'comment-intro 0)
   (setq tab-width 4)
   (setq c-basic-offset 2)
   (setq indent-tabs-mode nil)
 )
)

;================================================================
; color設定
;================================================================
(setq default-frame-alist 
      (append 
       (list 
	'(mouse-color . "red");
	'(foreground-color . "bisque1") ; 文字の色
	'(background-color . "dark slate gray") ; 背景の色
	'(width . 84)                 ; ウインドウの幅
	'(height . 40)                ; ウインドウの高さ
;	'(top . 0)                    ; ウインドウ上端の位置
;	'(left . 5)                   ; ウインドウ左端の位置
	'(vertical-scroll-bars . t)   ; スクロールバーを出す
       )
      default-frame-alist)
)
(set-face-background 'modeline "grey")  ; モードラインの色
(set-face-foreground 'modeline "black") ; モードラインのフォントの色

 	
;;(mac-set-input-method-parameter 'roman 'cursor-color "dim gray")
;;(mac-set-input-method-parameter 'japanese 'cursor-color "magenta")



;=====================================================================
; カーソルの種類
;=====================================================================
(setq default-frame-alist
      (append '(
		(cursor-color . "GreenYellow")         ;; 色
		(cursor-type . (bar . 2))      ;; 形
               )
              default-frame-alist)
)

;=====================================================================
; modeline に行数と桁数を表示
;=====================================================================
(line-number-mode t) 
(column-number-mode t)


;=================================================================
; 全てのバックアップファイルを/tmp以下に保存する。
;http://satosan.jp/CustomizeEmacs.html
;=================================================================
(defun make-backup-file-name (filename)
  (expand-file-name
    (concat "/tmp/" (file-name-nondirectory filename) "~")
    (file-name-directory filename)))


;=================================================================
; YaTeXの設定    ref http://www.nk.rim.or.jp/~naru/yatex
;=================================================================
;; yatex-mode を起動させる設定

(setq auto-mode-alist 
      (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

;; 野鳥が置いてある directry の load-path 設定
;; default で load-path が通っている場合は必要ありません

(setq load-path
      (cons (expand-file-name
             "/usr/local/share/emacs/site-lisp/yatex") load-path))

(setq YaTeX-kanji-code 3)          ; 1:shift jis 2:ISO-2022-JP, 3:EUC-JP
(setq tex-command "platex")        ; tex の実行コマンド
(setq dvi2-command "pxdvi")        ; プレビューアのコマンド
(setq bibtex-command "jbibtex")    ; BibTeX のコマンド
(setq section-name "documentclass"); LaTeX2e では documentclass を使うのが標準
(setq YaTeX-nervous nil)           ; 辞書はユーザ辞書でよいと思う

;=====================================================================
;　辞書の設定
;=====================================================================

(setq ispell-dictionary "US-xlg")

;=====================================================================
; 日本語の混ざっている場合のチェックできるように
;=====================================================================
(eval-after-load
"ispell" 
   '(setq ispell-skip-region-alist 
	  (cons '("[^\000-\377]") ispell-skip-region-alist)))

;=====================================================================
;自動改行(auto-newline)を有効にする　改行後の生計 M-q
;=====================================================================
(setq text-mode-hook ' turn-on-auto-fill)
(add-hook 'text-mode-hook
	  '(lambda ()
	     (progn (set-fill-column 80)
		    (turn-on-auto-fill))))

;=====================================================================
; #filename というバックアップファイルを作らない
;=====================================================================
(setq make-backup-files nil)

;=====================================================================
;   ツールバーの設定
;=====================================================================
(tool-bar-mode -1)   ;M-x tool-bar-mode で表示非表示を切り替え


;=====================================================================
;   フォントの設定
;=====================================================================
(cond (window-system
       (set-default-font
	"-*-fixed-medium-r-normal--14-*-*-*-*-*-*-*")
       (progn
	 (set-face-font 'default
			"-shinonome-gothic-medium-r-normal--14-*-*-*-*-*-*-*")
	 (set-face-font 'bold
			"-shinonome-gothic-bold-r-normal--14-*-*-*-*-*-*-*")
	 (set-face-font 'italic
			"-shinonome-gothic-medium-i-normal--14-*-*-*-*-*-*-*")
	 (set-face-font 'bold-italic
			"-shinonome-gothic-bold-i-normal--14-*-*-*-*-*-*-*")
	 )))
(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.
 '(column-number-mode t)
 '(transient-mark-mode t))
(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.
 )
