;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; .emacs for Debian GNU/Linux
;; file complied by me
;; This file is set for display which has light colour bgcolour
;; and dark colour fgcolour. The setting is adjusted to
;; use anthy on emacs.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Display settings ----------------------

;; Display
(setq default-frame-alist
'(
;-------------------------------------------------------------
; display setting is for courier 16pt and 14 inch display
; (top . 24) (left . 1)
(top . 5) (left . 25) ; note that this setting override settings in .Xresources.
(height . 46) (width . 100) ;height 43 width 105
;-------------------------------------------------------------
; display setting for courier 18pt on 14 inches display
;(top . 23) (left . 45)
;(height . 34) (width . 92)
;-------------------------------------------------------------
(cursor-color . "black") ;darkslategrey
(mouse-color . "darkcyan")
(background-color . "grey85") ;;moccasin, lemon chiffon, NavajoWhite3
(foreground-color . "black")
;--------------------------------------------------------------
;; (cursor-color . "yellow") ;darkslategrey
;; (mouse-color . "yellow")
;; (background-color . "darkslategrey") ;;moccasin, lemon chiffon, NavajoWhite3
;; (foreground-color . "grey90")
;--------------------------------------------------------------
(scroll-bar-width . 12)
))

;; Replace yes/no+enter prompts with y/n prompts
(fset 'yes-or-no-p 'y-or-n-p)

;; remove tool-bar
(tool-bar-mode 0)

;; Show line number on mode-line.
(line-number-mode t)

;; show column number on mode-line.
(column-number-mode t)

;(set-face-foreground 'modeline "grey60") ;slate grey, lightskyblue4, dark goldenrod, oritinally: snow
;(set-face-background 'modeline "darkslategrey") ;originally: black

;; Show current bus on title bar
(defvar dired-mode-p nil)
(add-hook 'dired-mode-hook
(lambda ()
(make-local-variabe 'dired-mode-p)
(setq dired-mode-p t)))
(setq frame-title-format-orig frame-title-format)
(setq frame-title-format
'((buffer-file-name "%f"
(dired-mode-p default-directory
mode-line-buffer-identification))))


;; Functions ------------------------------------
;; font-lock
(setq global-font-lock-mode t)

;; Speeding up loading files with use font-lock mode (only effective for emacs21)
(setq font-lock-support-mode 'jit-lock-mode)

;; Move around windows with [S-[up, down, left, right]]
(windmove-default-keybindings)

;; Hilight marked region
(setq transient-mark-mode t)
(set-face-foreground 'region "white") ;originally: white
(set-face-background 'region "cornflower blue") ;dim gray,cyan, blue, navy, cornflower blue

;; highlight
(show-paren-mode t)

;; enable scroll with mouse
;; sources: http://emacs-21.ki.nu/dot.emacs/mouse.html
;; normal scroll 5 line
;; mouse2 + shift key: 1 line
;; mouse2 + C half: page
(global-set-key [mouse-4] '(lambda () (interactive) (scroll-down 5)))
(global-set-key [mouse-5] '(lambda () (interactive) (scroll-up 5)))
; Shift
(global-set-key [S-mouse-4] '(lambda () (interactive) (scroll-down 1)))
(global-set-key [S-mouse-5] '(lambda () (interactive) (scroll-up 1)))
; Control
(global-set-key [C-mouse-5] '(lambda () (interactive) (scroll-up (/ (window-height) 2))))
(global-set-key [C-mouse-4] '(lambda () (interactive) (scroll-down (/ (window-height) 2))))


;;;; 便利な設定 (自動置換関係)-------------

;; 余分な空白を削除する
;; -> http://www3.big.or.jp/~sian/linux/tips/
(defun trim-buffer ()
"Delete excess white space."
(interactive)
(save-excursion
;; 行末の空白を削除する
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(replace-match "" nil nil))
;; ファイルの終わりにある空白行を削除する
(goto-char (point-max))
(delete-blank-lines)
;; ;; タブに変換できる空白は変換する
;; (mark-whole-buffer)
;; (tabify (region-beginning) (region-end))
))
(add-hook 'write-file-hooks 'trim-buffer)


;; ;;---------------------------------------------------------------
;; ;; Mew
;; ;; loading Mew
;; (setq load-path (cons "/usr/local/share/emacs/site-lisp/mew/" load-path))
;; (autoload 'mew "mew" nil t)
;; (autoload 'mew-send "mew" nil t)
;; (setq mew-icon-directory "/usr/share/pixmaps/mew/")
;; ;(setq mew-icon-directory "icon directory")
;; (if (boundp 'read-mail-command)
;; (setq read-mail-command 'mew))
;;
;; ;; Viewing URL from Mew by Mozzila-firefox
;; (setq browse-url-browser-function 'browse-url-netscape)
;; (autoload 'browse-url-at-mouse "browse-url"
;; "Ask a WWW browser to load a URL clicked with the mouse." t)
;; (add-hook 'mew-message-mode-hook
;; (function
;; (lambda()
;; (local-set-key [mouse-2] 'browse-url-at-mouse))))
;;
;; (setq browse-url-netscape-program "mozilla-firefox")
;;
;; (setq mew-mode-hook '(lambda ()
;; (auto-fill-mode 1)
;; (setq fill-column 60)))
;;
;;-------------------------------------------------------------------
;; Yatex
;; Yatex will be autolatically loaded when opening *.tex file.
(setq auto-mode-alist
(cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

;; Kanji code (Linux) 1. JIS shift 2. JIS 3.EUC
(setq YaTeX-kanji-code 3)

;; type-setter
(setq tex-command "latex")

;; viewer
;(setq dvi2-command "xdvi -s 4")
;(setq dvi2-command "gs")
(setq dvi2-command "kdvi")

;; Additional syntax hilighting for YaTeX
(setq my-YaTeX-font-lock-keywords
'(("\\(\\\\\\(left\\|right\\)\\([][().|]\\|\\\\[{}]\\)\\)"
(0 font-lock-warning-face))
("\\(|\\|&\\|\\\\[{}]\\|\\\\\\\\\\)" (0 font-lock-warning-face))

("\\\\[a-zA-Z]*" (0 font-lock-builtin-face))
))
(add-hook 'yatex-mode-hook
'(lambda ()
(setq
YaTeX-font-lock-keywords
(append YaTeX-font-lock-keywords my-YaTeX-font-lock-keywords))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; for gb4e ;;
(setq yatex-mode-load-hook
'(lambda() (YaTeX-define-begend-key "x" "exe")))


;; html -------------------------------------------------------------------
;; html-helper-mode
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))

;; fonthtml
(setq load-path (cons "/home/tatsuya/emacs/site-lisp/html-helper-mode/" load-path))
(add-hook 'html-helper-load-hook
(function (lambda () (load "fonthtml.elc"))))

;; Anthy on emacs
(push "/usr/local/share/emacs/site-lisp/anthy/" load-path)
(load-library "anthy") [load anthy.el]
(setq default-input-method "japanese-anthy")

;; ;; Yahtml
;; ;; Yahtml will be autolatically loaded when opening *.html file.
;; (setq auto-mode-alist
;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
;; (autoload 'yahtml-mode "yahtml" "Yet Another html-mode" t)
;; ;;(setq yahtml-kanji-code 3)

;; ;; set browser
;; (setq yahtml-www-browser "mozzila")
;; ;(setq yahtml-lint-program "weblint")


;; diary and calendar----------------------
(display-time)
(setq european-calendar-style t)
;(calendar)
(setq mark-diary-entries-in-calendar t)
(setq view-calendar-holidays-initially t)
;(diary)

;;;;;; end of my own settings ;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Tections below is automatically generated when installing
;;;;;;; Japanese language setting.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ---- language-env DON'T MODIFY THIS LINE!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 日本語表示の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if (featurep 'mule)
(progn
(set-language-environment "Japanese")
(prefer-coding-system 'euc-jp-unix)
(set-keyboard-coding-system 'euc-jp-unix)
(if (not window-system) (set-terminal-coding-system 'euc-jp-unix))
;;
))
; 日本語 info が文字化けしないように
(auto-compression-mode t)
; xemacs の shell-mode で 日本語 EUC が使えるようにする
(if (featurep 'xemacs)
(add-hook 'shell-mode-hook (function
(lambda () (set-buffer-process-coding-system 'euc-japan 'euc-japan))))
)
; 日本語 grep
(if (file-exists-p "/usr/bin/lgrep")
(setq grep-command "lgrep -n ")
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 漢字変換 (Anthy) の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-input-method "japanese-anthy")
(toggle-input-method nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Xでのカラー表示
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'font-lock)
(if (not (featurep 'xemacs))
(global-font-lock-mode t)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C プログラムの書式
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(defun my-c-mode-common-hook ()
; (c-set-style "linux") (setq indent-tabs-mode t) ;linux 式がいいとき
; /usr/src/linux/Documentation/CodingStyle 参照
; (c-set-style "k&r") ;k&r式がいいときはこれを有効にする
; (c-set-style "gnu") ;デフォルトの設定
; )
;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; いろいろ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Deleteキーでカーソル位置の文字が消えるようにする
(global-set-key [delete] 'delete-char)
;; C-h キーでカーソルの左の文字が消えるようにする。
;; ただし、もともと C-h はヘルプなので、
;; これを有効にすると、ヘルプを使うときには
;; M-x help や F1 を使う必要があります。
;(global-set-key "\C-h" 'backward-delete-char)

; ---- language-env end DON'T MODIFY THIS LINE!